From owner-svn-src-stable-11@freebsd.org Mon Mar 16 21:12:33 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DEA3F26FB1E; Mon, 16 Mar 2020 21:12:33 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48h8C54bMLz3KQP; Mon, 16 Mar 2020 21:12:33 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6884E26914; Mon, 16 Mar 2020 21:12:33 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02GLCXIq080550; Mon, 16 Mar 2020 21:12:33 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02GLCX22080549; Mon, 16 Mar 2020 21:12:33 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202003162112.02GLCX22080549@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Mon, 16 Mar 2020 21:12:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359020 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: bz X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 359020 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2020 21:12:34 -0000 Author: bz Date: Mon Mar 16 21:12:32 2020 New Revision: 359020 URL: https://svnweb.freebsd.org/changeset/base/359020 Log: MFC r358992: kern_jail: missing \0 termination check on osrelease parameter If a user spplies a non-\0 terminated osrelease parameter reading it back may disclose kernel memory. This is a problem in case of nested jails (children.max > 0, which is not the default). Otherwise root outside the jail has access to kernel memory by other means and root inside a jail cannot create a child jail. Add the proper \0 check at the end of a supplied osrelease parameter and make sure any copies of the field will be \0-terminated. Submitted by: Hans Christian Woithe (chwoithe yahoo.com) Modified: stable/11/sys/kern/kern_jail.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_jail.c ============================================================================== --- stable/11/sys/kern/kern_jail.c Mon Mar 16 19:33:50 2020 (r359019) +++ stable/11/sys/kern/kern_jail.c Mon Mar 16 21:12:32 2020 (r359020) @@ -881,8 +881,12 @@ kern_jail_set(struct thread *td, struct uio *optuio, i "osrelease cannot be changed after creation"); goto done_errmsg; } - if (len == 0 || len >= OSRELEASELEN) { + if (len == 0 || osrelstr[len - 1] != '\0') { error = EINVAL; + goto done_free; + } + if (len >= OSRELEASELEN) { + error = ENAMETOOLONG; vfs_opterror(opts, "osrelease string must be 1-%d bytes long", OSRELEASELEN - 1); @@ -1272,9 +1276,11 @@ kern_jail_set(struct thread *td, struct uio *optuio, i pr->pr_osreldate = osreldt ? osreldt : ppr->pr_osreldate; if (osrelstr == NULL) - strcpy(pr->pr_osrelease, ppr->pr_osrelease); + strlcpy(pr->pr_osrelease, ppr->pr_osrelease, + sizeof(pr->pr_osrelease)); else - strcpy(pr->pr_osrelease, osrelstr); + strlcpy(pr->pr_osrelease, osrelstr, + sizeof(pr->pr_osrelease)); LIST_INIT(&pr->pr_children); mtx_init(&pr->pr_mtx, "jail mutex", NULL, MTX_DEF | MTX_DUPOK); From owner-svn-src-stable-11@freebsd.org Mon Mar 16 23:15:21 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 95F4B2733DD; Mon, 16 Mar 2020 23:15:21 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48hBwn35Zhz4TcV; Mon, 16 Mar 2020 23:15:21 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 471A127F3E; Mon, 16 Mar 2020 23:15:21 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02GNFK7v052754; Mon, 16 Mar 2020 23:15:20 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02GNFKvb052752; Mon, 16 Mar 2020 23:15:20 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202003162315.02GNFKvb052752@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Mon, 16 Mar 2020 23:15:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359024 - stable/11/sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/11/sys/net X-SVN-Commit-Revision: 359024 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2020 23:15:21 -0000 Author: brooks Date: Mon Mar 16 23:15:20 2020 New Revision: 359024 URL: https://svnweb.freebsd.org/changeset/base/359024 Log: MFC r358592: Expose ifr_buffer_get_(buffer|length) outside if.c. This is a preparatory commit for D23933. Reviewed by: jhb Obtained from: CheriBSD Sponsored by: DARPA Modified: stable/11/sys/net/if.c stable/11/sys/net/if_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/if.c ============================================================================== --- stable/11/sys/net/if.c Mon Mar 16 23:09:25 2020 (r359023) +++ stable/11/sys/net/if.c Mon Mar 16 23:15:20 2020 (r359024) @@ -2422,7 +2422,7 @@ ifunit(const char *name) return (ifp); } -static void * +void * ifr_buffer_get_buffer(void *data) { union ifreq_union *ifrup; @@ -2450,7 +2450,7 @@ ifr_buffer_set_buffer_null(void *data) ifrup->ifr.ifr_ifru.ifru_buffer.buffer = NULL; } -static size_t +size_t ifr_buffer_get_length(void *data) { union ifreq_union *ifrup; Modified: stable/11/sys/net/if_var.h ============================================================================== --- stable/11/sys/net/if_var.h Mon Mar 16 23:09:25 2020 (r359023) +++ stable/11/sys/net/if_var.h Mon Mar 16 23:15:20 2020 (r359024) @@ -667,6 +667,8 @@ int if_hw_tsomax_update(if_t ifp, struct ifnet_hw_tsom /* accessors for struct ifreq */ void *ifr_data_get_ptr(void *ifrp); +void *ifr_buffer_get_buffer(void *data); +size_t ifr_buffer_get_length(void *data); int ifhwioctl(u_long, struct ifnet *, caddr_t, struct thread *); From owner-svn-src-stable-11@freebsd.org Mon Mar 16 23:29:04 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1232A27377F; Mon, 16 Mar 2020 23:29:04 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48hCDb5jKlz46lB; Mon, 16 Mar 2020 23:29:03 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BD2C219A; Mon, 16 Mar 2020 23:29:03 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02GNT38l058672; Mon, 16 Mar 2020 23:29:03 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02GNT3Yp058671; Mon, 16 Mar 2020 23:29:03 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202003162329.02GNT3Yp058671@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Mon, 16 Mar 2020 23:29:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359026 - stable/11/sys/dev/bnxt X-SVN-Group: stable-11 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/11/sys/dev/bnxt X-SVN-Commit-Revision: 359026 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2020 23:29:04 -0000 Author: brooks Date: Mon Mar 16 23:29:03 2020 New Revision: 359026 URL: https://svnweb.freebsd.org/changeset/base/359026 Log: MFC r358630: bnxt(4): Fix ioctls when user addresses are inaccessable. Check copyin's error code (differ adding copyout checks at this time). Don't directly access user memory in the switch statement. Since bnxt_ioctl_data isn't all that big, use a stack allocation. Reviewed by: jhb Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23933 Modified: stable/11/sys/dev/bnxt/if_bnxt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/bnxt/if_bnxt.c ============================================================================== --- stable/11/sys/dev/bnxt/if_bnxt.c Mon Mar 16 23:20:56 2020 (r359025) +++ stable/11/sys/dev/bnxt/if_bnxt.c Mon Mar 16 23:29:03 2020 (r359026) @@ -1636,25 +1636,26 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t { struct bnxt_softc *softc = iflib_get_softc(ctx); struct ifreq *ifr = (struct ifreq *)data; - struct ifreq_buffer *ifbuf = &ifr->ifr_ifru.ifru_buffer; - struct bnxt_ioctl_header *ioh = - (struct bnxt_ioctl_header *)(ifbuf->buffer); + struct bnxt_ioctl_header *ioh; + size_t iol; int rc = ENOTSUP; - struct bnxt_ioctl_data *iod = NULL; + struct bnxt_ioctl_data iod_storage, *iod = &iod_storage; + switch (command) { case SIOCGPRIVATE_0: if ((rc = priv_check(curthread, PRIV_DRIVER)) != 0) goto exit; - iod = malloc(ifbuf->length, M_DEVBUF, M_NOWAIT | M_ZERO); - if (!iod) { - rc = ENOMEM; + ioh = ifr_buffer_get_buffer(ifr); + iol = ifr_buffer_get_length(ifr); + if (iol > sizeof(iod_storage)) + return (EINVAL); + + if ((rc = copyin(ioh, iod, iol)) != 0) goto exit; - } - copyin(ioh, iod, ifbuf->length); - switch (ioh->type) { + switch (iod->hdr.type) { case BNXT_HWRM_NVM_FIND_DIR_ENTRY: { struct bnxt_ioctl_hwrm_nvm_find_dir_entry *find = @@ -1672,7 +1673,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1712,7 +1713,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t remain -= csize; } if (iod->hdr.rc == 0) - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); iflib_dma_free(&dma_data); rc = 0; @@ -1732,7 +1733,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1752,7 +1753,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1774,7 +1775,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1793,7 +1794,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1813,7 +1814,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1840,7 +1841,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t copyout(dma_data.idi_vaddr, get->data, get->entry_length * get->entries); iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } iflib_dma_free(&dma_data); @@ -1861,7 +1862,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1883,7 +1884,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1902,7 +1903,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1923,7 +1924,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1944,7 +1945,7 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } else { iod->hdr.rc = 0; - copyout(iod, ioh, ifbuf->length); + copyout(iod, ioh, iol); } rc = 0; @@ -1955,8 +1956,6 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t } exit: - if (iod) - free(iod, M_DEVBUF); return rc; } From owner-svn-src-stable-11@freebsd.org Tue Mar 17 23:58:59 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8424E2763BB; Tue, 17 Mar 2020 23:58:59 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48hqrg25mpz4RMg; Tue, 17 Mar 2020 23:58:59 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E60B01945D; Tue, 17 Mar 2020 23:58:58 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02HNwwWW040643; Tue, 17 Mar 2020 23:58:58 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02HNwwqZ040642; Tue, 17 Mar 2020 23:58:58 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <202003172358.02HNwwqZ040642@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Tue, 17 Mar 2020 23:58:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359056 - stable/11/sys/dev/usb/input X-SVN-Group: stable-11 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: stable/11/sys/dev/usb/input X-SVN-Commit-Revision: 359056 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2020 23:58:59 -0000 Author: wulf Date: Tue Mar 17 23:58:58 2020 New Revision: 359056 URL: https://svnweb.freebsd.org/changeset/base/359056 Log: MFC r358824: wmt(4): Fix Synaptics Touch Digitizer V04 attachment Touch Digitizer V04 report descriptor declares 'Contact Count Maximum' usage as constant. That was not supported by descriptor parser. PR: 232040 Reported by: Sergei Akhmatdinov Modified: stable/11/sys/dev/usb/input/wmt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/input/wmt.c ============================================================================== --- stable/11/sys/dev/usb/input/wmt.c Tue Mar 17 23:57:06 2020 (r359055) +++ stable/11/sys/dev/usb/input/wmt.c Tue Mar 17 23:58:58 2020 (r359056) @@ -626,9 +626,8 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, thqa_cert_rid = hi.report_ID; break; } - if (hi.collevel == 1 && touch_coll && - WMT_HI_ABSOLUTE(hi) && hi.usage == - HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACT_MAX)) { + if (hi.collevel == 1 && touch_coll && hi.usage == + HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACT_MAX)) { cont_count_max = hi.logical_maximum; cont_max_rid = hi.report_ID; if (sc != NULL) From owner-svn-src-stable-11@freebsd.org Wed Mar 18 01:55:28 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B494278BFD; Wed, 18 Mar 2020 01:55:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48htR41vG1z3DBc; Wed, 18 Mar 2020 01:55:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1B8CB1AA3F; Wed, 18 Mar 2020 01:55:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02I1tRY9012997; Wed, 18 Mar 2020 01:55:27 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02I1tRBs012996; Wed, 18 Mar 2020 01:55:27 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202003180155.02I1tRBs012996@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 18 Mar 2020 01:55:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359059 - in stable: 11/lib/libssp 12/lib/libssp X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/lib/libssp 12/lib/libssp X-SVN-Commit-Revision: 359059 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 01:55:28 -0000 Author: kevans Date: Wed Mar 18 01:55:27 2020 New Revision: 359059 URL: https://svnweb.freebsd.org/changeset/base/359059 Log: MFC r358993: libssp: don't compile with -fstack-protector* This similarly matches what we do in libc; compiling libssp with -fstack-protector* is actively harmful. For instance, if the canary ctor ends up with a stack protector then it will trivially trigger a false positive as the canary's being initialized. This was noted by the reporter as irc/ircd-hybrid started crashing at start after our libssp was MFC'd to stable/11, as its build will explicitly link in libssp. On FreeBSD, this isn't necessary as SSP bits are included in libc, but it should absolutely not trigger runtime breakage -- it does mean that the canary will get initialized twice, but as this is happening early on in application startup it should just be redundant work. Modified: stable/11/lib/libssp/Makefile Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/lib/libssp/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/11/lib/libssp/Makefile ============================================================================== --- stable/11/lib/libssp/Makefile Wed Mar 18 01:09:43 2020 (r359058) +++ stable/11/lib/libssp/Makefile Wed Mar 18 01:55:27 2020 (r359059) @@ -17,4 +17,8 @@ SRCS= stack_protector.c fortify_stubs.c CFLAGS.fortify_stubs.c= -Wno-unused-parameter +# Stack protection on libssp symbols should be considered harmful, as we may +# be talking about, for example, the guard setup constructor. +SSP_CFLAGS:= + .include From owner-svn-src-stable-11@freebsd.org Wed Mar 18 17:35:36 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD1212673D7; Wed, 18 Mar 2020 17:35:36 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jHHr4lcvz4N5y; Wed, 18 Mar 2020 17:35:36 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 589FD257BD; Wed, 18 Mar 2020 17:35:36 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02IHZaqe084692; Wed, 18 Mar 2020 17:35:36 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02IHZaXS084691; Wed, 18 Mar 2020 17:35:36 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <202003181735.02IHZaXS084691@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 18 Mar 2020 17:35:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359074 - in stable: 11/sys/netinet6 12/sys/netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: hrs X-SVN-Commit-Paths: in stable: 11/sys/netinet6 12/sys/netinet6 X-SVN-Commit-Revision: 359074 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 17:35:36 -0000 Author: hrs Date: Wed Mar 18 17:35:35 2020 New Revision: 359074 URL: https://svnweb.freebsd.org/changeset/base/359074 Log: MFC from r347887: Fix hostname to be returned in an ICMPv6 NI Reply message defined in RFC 4620, ICMPv6 Node Information Queries. A vnet jail with an IPv6 address sent a hostname of the host environment, not the jail, even if another hostname was set to the jail. This change can be tested by the following commands: # ifconfig epair0 create # jail -c -n j1 vnet host.hostname=vnetjail path=/ persist # ifconfig epair0b vnet j1 # ifconfig epair0a inet6 -ifdisabled auto_linklocal up # jexec j1 ifconfig epair0b inet6 -ifdisabled auto_linklocal up # ping6 -w ff02::1%epair0a Differential Revision: https://reviews.freebsd.org/D20207 Modified: stable/11/sys/netinet6/icmp6.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/netinet6/icmp6.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/netinet6/icmp6.c ============================================================================== --- stable/11/sys/netinet6/icmp6.c Wed Mar 18 17:01:03 2020 (r359073) +++ stable/11/sys/netinet6/icmp6.c Wed Mar 18 17:35:35 2020 (r359074) @@ -138,7 +138,7 @@ static int icmp6_rip6_input(struct mbuf **, int); static int icmp6_ratelimit(const struct in6_addr *, const int, const int); static const char *icmp6_redirect_diag(struct in6_addr *, struct in6_addr *, struct in6_addr *); -static struct mbuf *ni6_input(struct mbuf *, int); +static struct mbuf *ni6_input(struct mbuf *, int, struct prison *); static struct mbuf *ni6_nametodns(const char *, int, int); static int ni6_dnsmatch(const char *, int, const char *, int); static int ni6_addrs(struct icmp6_nodeinfo *, struct mbuf *, @@ -625,6 +625,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) case ICMP6_WRUREQUEST: /* ICMP6_FQDN_QUERY */ { enum { WRU, FQDN } mode; + struct prison *pr; if (!V_icmp6_nodeinfo) break; @@ -636,6 +637,14 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) else goto badlen; + pr = NULL; + sx_slock(&allprison_lock); + TAILQ_FOREACH(pr, &allprison, pr_list) + if (pr->pr_vnet == ifp->if_vnet) + break; + sx_sunlock(&allprison_lock); + if (pr == NULL) + pr = curthread->td_ucred->cr_prison; if (mode == FQDN) { #ifndef PULLDOWN_TEST IP6_EXTHDR_CHECK(m, off, sizeof(struct icmp6_nodeinfo), @@ -643,11 +652,10 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) #endif n = m_copy(m, 0, M_COPYALL); if (n) - n = ni6_input(n, off); + n = ni6_input(n, off, pr); /* XXX meaningless if n == NULL */ noff = sizeof(struct ip6_hdr); } else { - struct prison *pr; u_char *p; int maxhlen, hlen; @@ -681,13 +689,6 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) n = NULL; break; } - maxhlen = M_TRAILINGSPACE(n) - - (sizeof(*nip6) + sizeof(*nicmp6) + 4); - pr = curthread->td_ucred->cr_prison; - mtx_lock(&pr->pr_mtx); - hlen = strlen(pr->pr_hostname); - if (maxhlen > hlen) - maxhlen = hlen; /* * Copy IPv6 and ICMPv6 only. */ @@ -697,6 +698,13 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) bcopy(icmp6, nicmp6, sizeof(struct icmp6_hdr)); p = (u_char *)(nicmp6 + 1); bzero(p, 4); + + maxhlen = M_TRAILINGSPACE(n) - + (sizeof(*nip6) + sizeof(*nicmp6) + 4); + mtx_lock(&pr->pr_mtx); + hlen = strlen(pr->pr_hostname); + if (maxhlen > hlen) + maxhlen = hlen; /* meaningless TTL */ bcopy(pr->pr_hostname, p + 4, maxhlen); mtx_unlock(&pr->pr_mtx); @@ -1166,11 +1174,10 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int va * with hostname changes by sethostname(3) */ static struct mbuf * -ni6_input(struct mbuf *m, int off) +ni6_input(struct mbuf *m, int off, struct prison *pr) { struct icmp6_nodeinfo *ni6, *nni6; struct mbuf *n = NULL; - struct prison *pr; u_int16_t qtype; int subjlen; int replylen = sizeof(struct ip6_hdr) + sizeof(struct icmp6_nodeinfo); @@ -1322,7 +1329,6 @@ ni6_input(struct mbuf *m, int off) * wildcard match, if gethostname(3) side has * truncated hostname. */ - pr = curthread->td_ucred->cr_prison; mtx_lock(&pr->pr_mtx); n = ni6_nametodns(pr->pr_hostname, strlen(pr->pr_hostname), 0); @@ -1447,7 +1453,6 @@ ni6_input(struct mbuf *m, int off) /* * XXX do we really have FQDN in hostname? */ - pr = curthread->td_ucred->cr_prison; mtx_lock(&pr->pr_mtx); n->m_next = ni6_nametodns(pr->pr_hostname, strlen(pr->pr_hostname), oldfqdn); From owner-svn-src-stable-11@freebsd.org Wed Mar 18 17:42:19 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B934A267811; Wed, 18 Mar 2020 17:42:19 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jHRb3xjxz4dxr; Wed, 18 Mar 2020 17:42:19 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3B03225996; Wed, 18 Mar 2020 17:42:19 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02IHgJlJ090499; Wed, 18 Mar 2020 17:42:19 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02IHgITt090497; Wed, 18 Mar 2020 17:42:18 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <202003181742.02IHgITt090497@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 18 Mar 2020 17:42:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359075 - in stable: 11/share/vt/keymaps 12/share/vt/keymaps X-SVN-Group: stable-11 X-SVN-Commit-Author: hrs X-SVN-Commit-Paths: in stable: 11/share/vt/keymaps 12/share/vt/keymaps X-SVN-Commit-Revision: 359075 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 17:42:19 -0000 Author: hrs Date: Wed Mar 18 17:42:18 2020 New Revision: 359075 URL: https://svnweb.freebsd.org/changeset/base/359075 Log: MFC of r358061: Use 0x5c for the scan code 0x7d. Japanese keyboards traditionally use 0x5c for both Japanese yen sign key and backslash key. While a Japanese yen sign is depicted on the keytop, most of Japanese expect that the scan code 0x7d gives a backslash (0x5c), not a Japanese yen sign (0xa5). This is because JIS X 0201 encoding (aka ISO/IEC 646-JA, an extended version of ASCII which is very popular in Japan) has Japanese yen sign at 0x5c and no backslash. On the other hand, ISO/IEC 8859-1 has Japanese yen sign at 0xa5. This difference has caused a confusion after Unicode became popular since ISO/IEC 10646 adopted 8859-1 for the plane 0. Modified: stable/11/share/vt/keymaps/jp.capsctrl.kbd stable/11/share/vt/keymaps/jp.kbd Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/share/vt/keymaps/jp.capsctrl.kbd stable/12/share/vt/keymaps/jp.kbd Directory Properties: stable/12/ (props changed) Modified: stable/11/share/vt/keymaps/jp.capsctrl.kbd ============================================================================== --- stable/11/share/vt/keymaps/jp.capsctrl.kbd Wed Mar 18 17:35:35 2020 (r359074) +++ stable/11/share/vt/keymaps/jp.capsctrl.kbd Wed Mar 18 17:42:18 2020 (r359075) @@ -117,4 +117,4 @@ 115 '\' '_' fs us '\' '_' fs us O 121 ' ' ' ' nul ' ' ' ' ' ' susp ' ' O 123 ' ' ' ' nul ' ' ' ' ' ' susp ' ' O - 125 0xa5 '|' fs us 0xa5 '|' fs us O + 125 '\' '|' fs us 0xa5 '|' fs us O Modified: stable/11/share/vt/keymaps/jp.kbd ============================================================================== --- stable/11/share/vt/keymaps/jp.kbd Wed Mar 18 17:35:35 2020 (r359074) +++ stable/11/share/vt/keymaps/jp.kbd Wed Mar 18 17:42:18 2020 (r359075) @@ -115,4 +115,4 @@ 115 '\' '_' fs us '\' '_' fs us O 121 ' ' ' ' nul ' ' ' ' ' ' susp ' ' O 123 ' ' ' ' nul ' ' ' ' ' ' susp ' ' O - 125 0xa5 '|' fs us 0xa5 '|' fs us O + 125 '\' '|' fs us 0xa5 '|' fs us O From owner-svn-src-stable-11@freebsd.org Wed Mar 18 18:02:34 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69F42267FCF; Wed, 18 Mar 2020 18:02:34 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jHty2tsCz4SXx; Wed, 18 Mar 2020 18:02:34 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 45B6725D37; Wed, 18 Mar 2020 18:02:34 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02II2YsC002527; Wed, 18 Mar 2020 18:02:34 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02II2Xcd002522; Wed, 18 Mar 2020 18:02:33 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <202003181802.02II2Xcd002522@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 18 Mar 2020 18:02:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359076 - in stable: 11/share/man/man4 11/sys/dev/acpica 11/usr.sbin/acpi/acpiconf 12/share/man/man4 12/sys/dev/acpica 12/usr.sbin/acpi/acpiconf X-SVN-Group: stable-11 X-SVN-Commit-Author: hrs X-SVN-Commit-Paths: in stable: 11/share/man/man4 11/sys/dev/acpica 11/usr.sbin/acpi/acpiconf 12/share/man/man4 12/sys/dev/acpica 12/usr.sbin/acpi/acpiconf X-SVN-Commit-Revision: 359076 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 18:02:34 -0000 Author: hrs Date: Wed Mar 18 18:02:33 2020 New Revision: 359076 URL: https://svnweb.freebsd.org/changeset/base/359076 Log: MFC of r355574, r358095, and r358395: Add ACPI battery subsystem man page. Add _BIX (Battery Information Extended) object support. ACPI Control Method Batteries have a _BIF and/or _BIX object which provide static properties of the battery. FreeBSD acpi_cmbat module supported _BIF object only, which was deprecated as of ACPI 4.0. _BIX is an extended version of _BIF defined in ACPI 4.0 or later. As of writing, _BIX has two revisions. One is in ACPI 4.0 (rev.0) and another is in ACPI 6.0 (rev.1). It seems that hardware vendors still stick to _BIF only or _BIX rev.0 + _BIF for the maximum compatibility. Microsoft requires _BIX rev.0 for Windows machines, so there are some laptop machines with _BIX rev.0 only. In this case, FreeBSD does not recognize the battery information. After this change, the acpi_cmbat module gets battery information from _BIX or _BIF object and internally uses _BIX rev.1 data structure as the primary information store in the kernel. ACPIIO_BATT_GET_BI[FX] returns an acpi_bi[fx] structure built by using information obtained from a _BIF or a _BIX object found on the system. The revision number field can be used to check which field is available. The acpiconf(8) utility will show additional information if _BIX is available. Although ABIs of ACPIIO_BATT_* were changed, the existing APIs for userland utilities are not changed and the backward-compatible ABIs are provided. This means that older versions of acpiconf(8) can also work with the new kernel. The (union acpi_battery_ioctl_arg) was padded to 256 byte long to avoid another ABI change in the future. A _BIX object with its revision number >1 will be treated as compatible with the rev.1 _BIX format. Add workaround for models which do not follow the ACPI specification strictly. Extra objects are now simply ignored instead of rejecting everything. Differential Revision: https://reviews.freebsd.org/D22556 Differential Revision: https://reviews.freebsd.org/D23728 Added: stable/11/share/man/man4/acpi_battery.4 - copied, changed from r355574, head/share/man/man4/acpi_battery.4 Modified: stable/11/share/man/man4/Makefile stable/11/sys/dev/acpica/acpi_battery.c stable/11/sys/dev/acpica/acpi_cmbat.c stable/11/sys/dev/acpica/acpi_if.m stable/11/sys/dev/acpica/acpi_package.c stable/11/sys/dev/acpica/acpi_smbat.c stable/11/sys/dev/acpica/acpiio.h stable/11/sys/dev/acpica/acpivar.h stable/11/usr.sbin/acpi/acpiconf/acpiconf.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Added: stable/12/share/man/man4/acpi_battery.4 - copied, changed from r355574, head/share/man/man4/acpi_battery.4 Modified: stable/12/share/man/man4/Makefile stable/12/sys/dev/acpica/acpi_battery.c stable/12/sys/dev/acpica/acpi_cmbat.c stable/12/sys/dev/acpica/acpi_if.m stable/12/sys/dev/acpica/acpi_package.c stable/12/sys/dev/acpica/acpi_smbat.c stable/12/sys/dev/acpica/acpiio.h stable/12/sys/dev/acpica/acpivar.h stable/12/usr.sbin/acpi/acpiconf/acpiconf.c Directory Properties: stable/12/ (props changed) Modified: stable/11/share/man/man4/Makefile ============================================================================== --- stable/11/share/man/man4/Makefile Wed Mar 18 17:42:18 2020 (r359075) +++ stable/11/share/man/man4/Makefile Wed Mar 18 18:02:33 2020 (r359076) @@ -18,6 +18,7 @@ MAN= aac.4 \ ${_acpi_rapidstart.4} \ ${_acpi_sony.4} \ acpi_thermal.4 \ + acpi_battery.4 \ ${_acpi_toshiba.4} \ acpi_video.4 \ ${_acpi_wmi.4} \ Copied and modified: stable/11/share/man/man4/acpi_battery.4 (from r355574, head/share/man/man4/acpi_battery.4) ============================================================================== --- head/share/man/man4/acpi_battery.4 Tue Dec 10 02:19:07 2019 (r355574, copy source) +++ stable/11/share/man/man4/acpi_battery.4 Wed Mar 18 18:02:33 2020 (r359076) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 26, 2019 +.Dd February 16, 2020 .Dt ACPI_BATTERY 4 .Os .Sh NAME @@ -37,6 +37,7 @@ The .Nm is a driver for battery management features of the ACPI module. +.Pp An ACPI-compatible battery device supports either a Control Method Battery interface or a Smart Battery subsystem interface. The former is accessed by the AML @@ -45,7 +46,8 @@ code control methods, and the latter is controlled directly through the ACPI EC .Pq Embedded Controller typically via an SMBus interface. -This driver supports the +.Pp +This driver supports the .Xr sysctl 8 and .Xr ioctl 2 @@ -59,60 +61,86 @@ driver takes a single integer value for the battery un number as an argument, and returns a specific structure for each request. A special unit number -.Li ACPI_BATTERY_ALL_UNITS +.Dv ACPI_BATTERY_ALL_UNITS specifies all of the attached units and reports accumulated information. .Bl -tag -width indent -.It ACPIIO_BATT_GET_UNITS Vt int +.It Dv ACPIIO_BATT_GET_UNITS Vt int Returns the number of battery units in the system. The unit number argument will be ignored. -.It ACPIIO_BATT_GET_BATTINFO Vt struct acpi_battinfo +.It Dv ACPIIO_BATT_GET_BATTINFO Vt struct acpi_battinfo Returns the following: .Bl -tag -width indent -.It cap +.It Va cap Battery capacity in percent, -.It min +.It Va min Remaining battery life in minutes, -.It state +.It Va state Current status of the battery encoded in the following: .Bl -tag -width indent -.It ACPI_BATT_STAT_DISCHARG Pq 0x0001 +.It Dv ACPI_BATT_STAT_DISCHARG Pq 0x0001 Battery is discharging, -.It ACPI_BATT_STAT_CHARGING Pq 0x0002 +.It Dv ACPI_BATT_STAT_CHARGING Pq 0x0002 Battery is being charged, or -.It ACPI_BATT_STAT_CRITICAL Pq 0x0004 +.It Dv ACPI_BATT_STAT_CRITICAL Pq 0x0004 Remaining battery life is critically low. .El .Pp Note that the status bits of each battery will be consolidated when -.Li ACPI_BATTERY_ALL_UNITS +.Dv ACPI_BATTERY_ALL_UNITS is specified. -.It rate +.It Va rate Current battery discharging rate in mW. .Li -1 means not discharging right now. .El -.It ACPIIO_BATT_GET_BIF Vt struct acpi_bif +.It Dv ACPIIO_BATT_GET_BIX Vt struct acpi_bix Returns battery information given by the ACPI -.Li _BIF Pq Battery Information +.Li _BIX Pq Battery Information object, which is the static portion of the Control Method Battery information. -In the case of a Smart Battery attached to SMBus, +In the case of a Smart Battery attached to +SMBus or a Control Method Battery with a +.Li _BIF +object, this ioctl will build a -.Vt struct acpi_bif +.Vt struct acpi_bix structure based on the obtained information and return it. .Bl -tag -width indent -.It units +.It Va rev +Revision number of the object. +There are the following well-known values: +.Bl -tag -width indent +.It Dv ACPI_BIX_REV_0 Pq 0x0000 +A +.Li _BIX +object in ACPI 4.0. +.It Dv ACPI_BIX_REV_1 Pq 0x0001 +A +.Li _BIX +object in ACPI 6.0. +.It Dv ACPI_BIX_REV_BIF Pq 0xffff +A +.Li _BIX +object built from the +.Li _BIF +object found on the system. +.El +.Pp +Note that this field should be checked by using +.Fn ACPI_BIX_REV_MIN_CHECK var rev +macro when checking the minimum revision number. +.It Va units Indicates the units used by the battery to report its capacity and charge rate encoded in the following: .Bl -tag -width indent -.It ACPI_BIF_UNITS_MW Pq 0x00000000 +.It ACPI_BIX_UNITS_MW Pq 0x00000000 in mW .Pq power -.It ACPI_BIF_UNITS_MA Pq 0x00000001 +.It ACPI_BIX_UNITS_MA Pq 0x00000001 in mA .Pq current .El @@ -120,31 +148,69 @@ in mA Note that capacity is expressed in mWh or mAh, and rate is expressed in mW or mA, respectively. -.It dcap +.It Va dcap The Battery's design capacity, which is the nominal capacity of a new battery. This is expressed as power or current depending on the value of .Va units . -.It lfcap +.It Va lfcap Predicted battery capacity when fully charged. Typically this will decrease every charging cycle. .It btech Battery technology: .Bl -tag -width indent .It 0x00000000 Primary cell Pq non-rechargable -.It 0x00000001 Secondery cell Pq rechargable +.It 0x00000001 Secondary cell Pq rechargable .El -.It dvol +.It Va dvol Design voltage in mV, which is the nominal voltage of a new battery. -.It wcap +.It Va wcap Design capacity of warning. When a discharging battery device reaches this capacity, notification is sent to the system. -.It lcap +.It Va lcap Design capacity of low. -.It gra1 +.It Va cycles +.Pq rev 0 or newer +The number of cycles the battery has experienced. +A cycle means an amount of discharge occurred which was +approximately equal to the value of Design Capacity. +.It Va accuracy +.Pq rev 0 or newer +The accuracy of the battery capacity measurement, +in thousandth of a percent. +.It Va stmax +.Pq rev 0 or newer +The Maximum Sampling Time of the battery in +milliseconds. +This is the maximum duration between two consecutive +measurements of the battery's capacities specified in +.Li _BST . +If two succeeding readings of +.Li _BST +beyond this duration occur, +two different results can be returned. +.It Va stmin +.Pq rev 0 or newer +The Minimum Sampling Time of the battery in +milliseconds. +.It Va aimax +.Pq rev 0 or newer +The Maximum Average Interval of the battery in +milliseconds. +This is the length of time within which the battery +averages the capacity measurements specified in +.Li _BST . +The Sampling Time specifies the frequency of measurements, +and the Average Interval specifies the width of the time +window of every measurement. +.It Va aimin +.Pq rev 0 or newer +The Minimum Average Interval of the battery in +milliseconds. +.It Va gra1 Battery capacity granularity between .Va low and @@ -152,7 +218,7 @@ and This is expressed as power or current depending on the value of .Va units . -.It gra2 +.It Va gra2 Battery capacity granularity between .Va warning and @@ -160,15 +226,41 @@ and This is expressed as power or current depending on the value of .Va units . -.It model +.It Va model Model number of the battery as a string. -.It serial +.It Va serial Serial number of the battery as a string. -.It type +.It Va type Type identifier of the battery as a string. -.It oeminfo +.It Va oeminfo OEM-specific information of the battery as a string. +.It Va scap +.Pq rev 1 or newer +Battery swapping capability encoded in the following: +.Bl -tag -width indent +.It ACPI_BIX_SCAP_NO Pq 0x00000000 +Non-swappable +.It ACPI_BIX_SCAP_COLD Pq 0x00000001 +Cold-swappable +.It ACPI_BIX_SCAP_HOT Pq 0x00000010 +Hot-swappable .El +.El +.It Dv ACPIIO_BATT_GET_BIF Vt struct acpi_bif +.Pq deprecated +Returns battery information given by the ACPI +.Li _BIF Pq Battery Information +object, +which was deprecated in ACPI 4.0 specification. +The data structure is a subset of +.Vt struct acpi_bix . +.Pp +Note that this ioctl will built a +.Vt struct acpi_bif +structure based on the obtained information +even if this object is not available and a +.Li _BIX +object is found. .It ACPIIO_BATT_GET_BST Vt struct acpi_bst Returns battery information given by the ACPI .Li _BST Pq Battery Status @@ -180,25 +272,25 @@ this ioctl will build a structure based on the obtained information and return it. .Bl -tag -width indent -.It state +.It Va state Battery state. The value is encoded in the same way as .Va state of .Vt struct acpi_battinfo . -.It rate +.It Va rate Battery present rate of charging or discharging. The unit of the value depends on .Va unit of .Vt struct acpi_bif . -.It cap +.It Va cap Battery remaining capacity. The unit of this value depends on .Va unit of .Vt struct acpi_bif . -.It volt +.It Va volt Battery present voltage. .El .El @@ -212,6 +304,8 @@ connected batteries: .It Va hw.acpi.battery.info_expire Information cache expiration time in seconds. The battery information obtained by +.Li _BIX +or .Li _BIF object will be stored and reused for successive read access to this MIB within the specified period. @@ -276,8 +370,11 @@ Battery information was changed. .An Munehiro Matsuda , .An Takanori Watanabe Aq Mt takawata@FreeBSD.org , .An Mitsuru IWASAKI Aq Mt iwasaki@FreeBSD.org , +.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org , and -.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org . +.An Hiroki Sato Aq Mt hrs@FreeBSD.org . .Pp This manual page was written by -.An Takanori Watanabe Aq Mt takawata@FreeBSD.org . +.An Takanori Watanabe Aq Mt takawata@FreeBSD.org +and +.An Hiroki Sato Aq Mt hrs@FreeBSD.org . Modified: stable/11/sys/dev/acpica/acpi_battery.c ============================================================================== --- stable/11/sys/dev/acpica/acpi_battery.c Wed Mar 18 17:42:18 2020 (r359075) +++ stable/11/sys/dev/acpica/acpi_battery.c Wed Mar 18 18:02:33 2020 (r359076) @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); /* Default seconds before re-sampling the battery state. */ #define ACPI_BATTERY_INFO_EXPIRE 5 -static int acpi_batteries_initted; +static int acpi_batteries_initialized; static int acpi_battery_info_expire = ACPI_BATTERY_INFO_EXPIRE; static struct acpi_battinfo acpi_battery_battinfo; static struct sysctl_ctx_list acpi_battery_sysctl_ctx; @@ -65,11 +65,10 @@ acpi_battery_register(device_t dev) { int error; - error = 0; ACPI_SERIAL_BEGIN(battery); - if (!acpi_batteries_initted) - error = acpi_battery_init(); + error = acpi_battery_init(); ACPI_SERIAL_END(battery); + return (error); } @@ -107,11 +106,12 @@ acpi_battery_bst_valid(struct acpi_bst *bst) bst->cap != ACPI_BATT_UNKNOWN && bst->volt != ACPI_BATT_UNKNOWN); } -/* Check _BIF results for validity. */ +/* Check _BI[FX] results for validity. */ int -acpi_battery_bif_valid(struct acpi_bif *bif) +acpi_battery_bix_valid(struct acpi_bix *bix) { - return (bif->lfcap != 0); + + return (bix->lfcap != 0); } /* Get info about one or all batteries. */ @@ -123,7 +123,7 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba devclass_t batt_dc; device_t batt_dev; struct acpi_bst *bst; - struct acpi_bif *bif; + struct acpi_bix *bix; struct acpi_battinfo *bi; /* @@ -139,11 +139,11 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba /* * Allocate storage for all _BST data, their derived battinfo data, - * and the current battery's _BIF data. + * and the current battery's _BIX (or _BIF) data. */ bst = malloc(devcount * sizeof(*bst), M_TEMP, M_WAITOK | M_ZERO); bi = malloc(devcount * sizeof(*bi), M_TEMP, M_WAITOK | M_ZERO); - bif = malloc(sizeof(*bif), M_TEMP, M_WAITOK | M_ZERO); + bix = malloc(sizeof(*bix), M_TEMP, M_WAITOK | M_ZERO); /* * Pass 1: for each battery that is present and valid, get its status, @@ -176,12 +176,12 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba */ if (!acpi_BatteryIsPresent(batt_dev) || ACPI_BATT_GET_STATUS(batt_dev, &bst[i]) != 0 || - ACPI_BATT_GET_INFO(batt_dev, bif) != 0) + ACPI_BATT_GET_INFO(batt_dev, bix, sizeof(*bix)) != 0) continue; /* If a battery is not installed, we sometimes get strange values. */ if (!acpi_battery_bst_valid(&bst[i]) || - !acpi_battery_bif_valid(bif)) + !acpi_battery_bix_valid(bix)) continue; /* @@ -200,18 +200,18 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba * is 0 (due to some error reading the battery), skip this * conversion. */ - if (bif->units == ACPI_BIF_UNITS_MA && bif->dvol != 0 && dev == NULL) { - bst[i].rate = (bst[i].rate * bif->dvol) / 1000; - bst[i].cap = (bst[i].cap * bif->dvol) / 1000; - bif->lfcap = (bif->lfcap * bif->dvol) / 1000; + if (bix->units == ACPI_BIX_UNITS_MA && bix->dvol != 0 && dev == NULL) { + bst[i].rate = (bst[i].rate * bix->dvol) / 1000; + bst[i].cap = (bst[i].cap * bix->dvol) / 1000; + bix->lfcap = (bix->lfcap * bix->dvol) / 1000; } /* - * The calculation above may set bif->lfcap to zero. This was + * The calculation above may set bix->lfcap to zero. This was * seen on a laptop with a broken battery. The result of the * division was rounded to zero. */ - if (!acpi_battery_bif_valid(bif)) + if (!acpi_battery_bix_valid(bix)) continue; /* @@ -219,16 +219,16 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba * "real-capacity" when the battery is fully charged. That breaks * the above arithmetic as it needs to be 100% maximum. */ - if (bst[i].cap > bif->lfcap) - bst[i].cap = bif->lfcap; + if (bst[i].cap > bix->lfcap) + bst[i].cap = bix->lfcap; /* Calculate percent capacity remaining. */ - bi[i].cap = (100 * bst[i].cap) / bif->lfcap; + bi[i].cap = (100 * bst[i].cap) / bix->lfcap; /* If this battery is not present, don't use its capacity. */ if (bi[i].cap != -1) { total_cap += bst[i].cap; - total_lfcap += bif->lfcap; + total_lfcap += bix->lfcap; } /* @@ -294,12 +294,9 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba error = 0; out: - if (bi) - free(bi, M_TEMP); - if (bif) - free(bif, M_TEMP); - if (bst) - free(bst, M_TEMP); + free(bi, M_TEMP); + free(bix, M_TEMP); + free(bst, M_TEMP); return (error); } @@ -368,7 +365,8 @@ acpi_battery_ioctl(u_long cmd, caddr_t addr, void *arg unit = 0; dev = NULL; ioctl_arg = NULL; - if (IOCPARM_LEN(cmd) == sizeof(*ioctl_arg)) { + if (IOCPARM_LEN(cmd) == sizeof(union acpi_battery_ioctl_arg) || + IOCPARM_LEN(cmd) == sizeof(union acpi_battery_ioctl_arg_v1)) { ioctl_arg = (union acpi_battery_ioctl_arg *)addr; unit = ioctl_arg->unit; if (unit != ACPI_BATTERY_ALL_UNITS) @@ -379,12 +377,14 @@ acpi_battery_ioctl(u_long cmd, caddr_t addr, void *arg * No security check required: information retrieval only. If * new functions are added here, a check might be required. */ + /* Unit check */ switch (cmd) { case ACPIIO_BATT_GET_UNITS: *(int *)addr = acpi_battery_get_units(); error = 0; break; case ACPIIO_BATT_GET_BATTINFO: + case ACPIIO_BATT_GET_BATTINFO_V1: if (dev != NULL || unit == ACPI_BATTERY_ALL_UNITS) { bzero(&ioctl_arg->battinfo, sizeof(ioctl_arg->battinfo)); error = acpi_battery_get_battinfo(dev, &ioctl_arg->battinfo); @@ -393,24 +393,19 @@ acpi_battery_ioctl(u_long cmd, caddr_t addr, void *arg case ACPIIO_BATT_GET_BIF: if (dev != NULL) { bzero(&ioctl_arg->bif, sizeof(ioctl_arg->bif)); - error = ACPI_BATT_GET_INFO(dev, &ioctl_arg->bif); - - /* - * Remove invalid characters. Perhaps this should be done - * within a convenience function so all callers get the - * benefit. - */ - acpi_battery_clean_str(ioctl_arg->bif.model, - sizeof(ioctl_arg->bif.model)); - acpi_battery_clean_str(ioctl_arg->bif.serial, - sizeof(ioctl_arg->bif.serial)); - acpi_battery_clean_str(ioctl_arg->bif.type, - sizeof(ioctl_arg->bif.type)); - acpi_battery_clean_str(ioctl_arg->bif.oeminfo, - sizeof(ioctl_arg->bif.oeminfo)); + error = ACPI_BATT_GET_INFO(dev, &ioctl_arg->bif, + sizeof(ioctl_arg->bif)); } break; + case ACPIIO_BATT_GET_BIX: + if (dev != NULL) { + bzero(&ioctl_arg->bix, sizeof(ioctl_arg->bix)); + error = ACPI_BATT_GET_INFO(dev, &ioctl_arg->bix, + sizeof(ioctl_arg->bix)); + } + break; case ACPIIO_BATT_GET_BST: + case ACPIIO_BATT_GET_BST_V1: if (dev != NULL) { bzero(&ioctl_arg->bst, sizeof(ioctl_arg->bst)); error = ACPI_BATT_GET_STATUS(dev, &ioctl_arg->bst); @@ -420,6 +415,25 @@ acpi_battery_ioctl(u_long cmd, caddr_t addr, void *arg error = EINVAL; } + /* Sanitize the string members. */ + switch (cmd) { + case ACPIIO_BATT_GET_BIX: + case ACPIIO_BATT_GET_BIF: + /* + * Remove invalid characters. Perhaps this should be done + * within a convenience function so all callers get the + * benefit. + */ + acpi_battery_clean_str(ioctl_arg->bix.model, + sizeof(ioctl_arg->bix.model)); + acpi_battery_clean_str(ioctl_arg->bix.serial, + sizeof(ioctl_arg->bix.serial)); + acpi_battery_clean_str(ioctl_arg->bix.type, + sizeof(ioctl_arg->bix.type)); + acpi_battery_clean_str(ioctl_arg->bix.oeminfo, + sizeof(ioctl_arg->bix.oeminfo)); + }; + return (error); } @@ -453,27 +467,30 @@ acpi_battery_init(void) ACPI_SERIAL_ASSERT(battery); + if (acpi_batteries_initialized) + return(0); + error = ENXIO; dev = devclass_get_device(devclass_find("acpi"), 0); if (dev == NULL) goto out; sc = device_get_softc(dev); - error = acpi_register_ioctl(ACPIIO_BATT_GET_UNITS, acpi_battery_ioctl, - NULL); - if (error != 0) - goto out; - error = acpi_register_ioctl(ACPIIO_BATT_GET_BATTINFO, acpi_battery_ioctl, - NULL); - if (error != 0) - goto out; - error = acpi_register_ioctl(ACPIIO_BATT_GET_BIF, acpi_battery_ioctl, NULL); - if (error != 0) - goto out; - error = acpi_register_ioctl(ACPIIO_BATT_GET_BST, acpi_battery_ioctl, NULL); - if (error != 0) - goto out; +#define ACPI_REGISTER_IOCTL(a, b, c) do { \ + error = acpi_register_ioctl(a, b, c); \ + if (error) \ + goto out; \ + } while (0) + ACPI_REGISTER_IOCTL(ACPIIO_BATT_GET_UNITS, acpi_battery_ioctl, NULL); + ACPI_REGISTER_IOCTL(ACPIIO_BATT_GET_BATTINFO, acpi_battery_ioctl, NULL); + ACPI_REGISTER_IOCTL(ACPIIO_BATT_GET_BATTINFO_V1, acpi_battery_ioctl, NULL); + ACPI_REGISTER_IOCTL(ACPIIO_BATT_GET_BIF, acpi_battery_ioctl, NULL); + ACPI_REGISTER_IOCTL(ACPIIO_BATT_GET_BIX, acpi_battery_ioctl, NULL); + ACPI_REGISTER_IOCTL(ACPIIO_BATT_GET_BST, acpi_battery_ioctl, NULL); + ACPI_REGISTER_IOCTL(ACPIIO_BATT_GET_BST_V1, acpi_battery_ioctl, NULL); +#undef ACPI_REGISTER_IOCTL + sysctl_ctx_init(&acpi_battery_sysctl_ctx); acpi_battery_sysctl_tree = SYSCTL_ADD_NODE(&acpi_battery_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, "battery", CTLFLAG_RD, @@ -508,14 +525,17 @@ acpi_battery_init(void) &acpi_battery_info_expire, 0, "time in seconds until info is refreshed"); - acpi_batteries_initted = TRUE; + acpi_batteries_initialized = TRUE; out: - if (error != 0) { + if (error) { acpi_deregister_ioctl(ACPIIO_BATT_GET_UNITS, acpi_battery_ioctl); acpi_deregister_ioctl(ACPIIO_BATT_GET_BATTINFO, acpi_battery_ioctl); + acpi_deregister_ioctl(ACPIIO_BATT_GET_BATTINFO_V1, acpi_battery_ioctl); acpi_deregister_ioctl(ACPIIO_BATT_GET_BIF, acpi_battery_ioctl); + acpi_deregister_ioctl(ACPIIO_BATT_GET_BIX, acpi_battery_ioctl); acpi_deregister_ioctl(ACPIIO_BATT_GET_BST, acpi_battery_ioctl); + acpi_deregister_ioctl(ACPIIO_BATT_GET_BST_V1, acpi_battery_ioctl); } return (error); } Modified: stable/11/sys/dev/acpica/acpi_cmbat.c ============================================================================== --- stable/11/sys/dev/acpica/acpi_cmbat.c Wed Mar 18 17:42:18 2020 (r359075) +++ stable/11/sys/dev/acpica/acpi_cmbat.c Wed Mar 18 18:02:33 2020 (r359076) @@ -61,12 +61,13 @@ ACPI_MODULE_NAME("BATTERY") #define ACPI_BATTERY_BST_CHANGE 0x80 #define ACPI_BATTERY_BIF_CHANGE 0x81 +#define ACPI_BATTERY_BIX_CHANGE ACPI_BATTERY_BIF_CHANGE struct acpi_cmbat_softc { device_t dev; int flags; - struct acpi_bif bif; + struct acpi_bix bix; struct acpi_bst bst; struct timespec bst_lastupdated; }; @@ -82,10 +83,10 @@ static void acpi_cmbat_notify_handler(ACPI_HANDLE h, static int acpi_cmbat_info_expired(struct timespec *lastupdated); static void acpi_cmbat_info_updated(struct timespec *lastupdated); static void acpi_cmbat_get_bst(void *arg); -static void acpi_cmbat_get_bif_task(void *arg); -static void acpi_cmbat_get_bif(void *arg); -static int acpi_cmbat_bst(device_t dev, struct acpi_bst *bstp); -static int acpi_cmbat_bif(device_t dev, struct acpi_bif *bifp); +static void acpi_cmbat_get_bix_task(void *arg); +static void acpi_cmbat_get_bix(void *arg); +static int acpi_cmbat_bst(device_t, struct acpi_bst *); +static int acpi_cmbat_bix(device_t, void *, size_t); static void acpi_cmbat_init_battery(void *arg); static device_method_t acpi_cmbat_methods[] = { @@ -96,7 +97,7 @@ static device_method_t acpi_cmbat_methods[] = { DEVMETHOD(device_resume, acpi_cmbat_resume), /* ACPI battery interface */ - DEVMETHOD(acpi_batt_get_info, acpi_cmbat_bif), + DEVMETHOD(acpi_batt_get_info, acpi_cmbat_bix), DEVMETHOD(acpi_batt_get_status, acpi_cmbat_bst), DEVMETHOD_END @@ -204,12 +205,12 @@ acpi_cmbat_notify_handler(ACPI_HANDLE h, UINT32 notify timespecclear(&sc->bst_lastupdated); break; case ACPI_NOTIFY_BUS_CHECK: - case ACPI_BATTERY_BIF_CHANGE: + case ACPI_BATTERY_BIX_CHANGE: /* * Queue a callback to get the current battery info from thread * context. It's not safe to block in a notify handler. */ - AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_get_bif_task, dev); + AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_cmbat_get_bix_task, dev); break; } @@ -268,15 +269,15 @@ acpi_cmbat_get_bst(void *arg) as = AcpiEvaluateObject(h, "_BST", NULL, &bst_buffer); if (ACPI_FAILURE(as)) { ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "error fetching current battery status -- %s\n", - AcpiFormatException(as)); + "error fetching current battery status -- %s\n", + AcpiFormatException(as)); goto end; } res = (ACPI_OBJECT *)bst_buffer.Pointer; if (!ACPI_PKG_VALID(res, 4)) { ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "battery status corrupted\n"); + "battery status corrupted\n"); goto end; } @@ -306,119 +307,207 @@ acpi_cmbat_get_bst(void *arg) sc->flags &= ~ACPI_BATT_STAT_CRITICAL; end: - if (bst_buffer.Pointer != NULL) - AcpiOsFree(bst_buffer.Pointer); + AcpiOsFree(bst_buffer.Pointer); } /* XXX There should be a cleaner way to do this locking. */ static void -acpi_cmbat_get_bif_task(void *arg) +acpi_cmbat_get_bix_task(void *arg) { ACPI_SERIAL_BEGIN(cmbat); - acpi_cmbat_get_bif(arg); + acpi_cmbat_get_bix(arg); ACPI_SERIAL_END(cmbat); } static void -acpi_cmbat_get_bif(void *arg) +acpi_cmbat_get_bix(void *arg) { struct acpi_cmbat_softc *sc; ACPI_STATUS as; ACPI_OBJECT *res; ACPI_HANDLE h; - ACPI_BUFFER bif_buffer; + ACPI_BUFFER bix_buffer; device_t dev; + int i, n; + const struct { + enum { _BIX, _BIF } type; + char *name; + } bobjs[] = { + { _BIX, "_BIX"}, + { _BIF, "_BIF"}, + }; ACPI_SERIAL_ASSERT(cmbat); dev = arg; sc = device_get_softc(dev); h = acpi_get_handle(dev); - bif_buffer.Pointer = NULL; - bif_buffer.Length = ACPI_ALLOCATE_BUFFER; + bix_buffer.Pointer = NULL; + bix_buffer.Length = ACPI_ALLOCATE_BUFFER; - as = AcpiEvaluateObject(h, "_BIF", NULL, &bif_buffer); - if (ACPI_FAILURE(as)) { + for (n = 0; n < sizeof(bobjs); n++) { + as = AcpiEvaluateObject(h, bobjs[n].name, NULL, &bix_buffer); + if (!ACPI_FAILURE(as)) { + res = (ACPI_OBJECT *)bix_buffer.Pointer; + break; + } + AcpiOsFree(bix_buffer.Pointer); + bix_buffer.Pointer = NULL; + bix_buffer.Length = ACPI_ALLOCATE_BUFFER; + } + /* Both _BIF and _BIX were not found. */ + if (n == sizeof(bobjs)) { ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "error fetching current battery info -- %s\n", - AcpiFormatException(as)); + "error fetching current battery info -- %s\n", + AcpiFormatException(as)); goto end; } - res = (ACPI_OBJECT *)bif_buffer.Pointer; - if (!ACPI_PKG_VALID(res, 13)) { - ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "battery info corrupted\n"); - goto end; + /* + * ACPI _BIX and _BIF revision mismatch check: + * + * 1. _BIF has no revision field. The number of fields must be 13. + * + * 2. _BIX has a revision field. As of ACPI 6.3 it must be "0" or + * "1". The number of fields will be checked---20 and 21, + * respectively. + * + * If the revision number is grater than "1" and the number of + * fields is grater than 21, it will be treated as compatible with + * ACPI 6.0 _BIX. If not, it will be ignored. + */ + i = 0; + switch (bobjs[n].type) { + case _BIX: + if (acpi_PkgInt16(res, i++, &sc->bix.rev) != 0) { + ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), + "_BIX revision error\n"); + goto end; + } +#define ACPI_BIX_REV_MISMATCH_ERR(x, r) do { \ + ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), \ + "_BIX revision mismatch (%u != %u)\n", x, r); \ + goto end; \ + } while (0) + + if (ACPI_PKG_VALID_EQ(res, 21)) { /* ACPI 6.0 _BIX */ + /* + * Some models have rev.0 _BIX with 21 members. + * In that case, treat the first 20 members as rev.0 _BIX. + */ + if (sc->bix.rev != ACPI_BIX_REV_0 && + sc->bix.rev != ACPI_BIX_REV_1) + ACPI_BIX_REV_MISMATCH_ERR(sc->bix.rev, ACPI_BIX_REV_1); + } else if (ACPI_PKG_VALID_EQ(res, 20)) {/* ACPI 4.0 _BIX */ + if (sc->bix.rev != ACPI_BIX_REV_0) + ACPI_BIX_REV_MISMATCH_ERR(sc->bix.rev, ACPI_BIX_REV_0); + } else if (ACPI_PKG_VALID(res, 22)) { + /* _BIX with 22 or more members. */ + if (ACPI_BIX_REV_MIN_CHECK(sc->bix.rev, ACPI_BIX_REV_1 + 1)) { + /* + * Unknown revision number. + * Assume 21 members are compatible with 6.0 _BIX. + */ + ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), + "Unknown _BIX revision(%u). " + "Assuming compatible with revision %u.\n", + sc->bix.rev, ACPI_BIX_REV_1); + } else { + /* + * Known revision number. Ignore the extra members. + */ + ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), + "Extra objects found in _BIX were ignored.\n"); + } + } else { + /* Invalid _BIX. Ignore it. */ + ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), + "Invalid _BIX found (rev=%u, count=%u). Ignored.\n", + sc->bix.rev, res->Package.Count); + goto end; + } + break; +#undef ACPI_BIX_REV_MISMATCH_ERR + case _BIF: + if (ACPI_PKG_VALID_EQ(res, 13)) /* _BIF */ + sc->bix.rev = ACPI_BIX_REV_BIF; + else { + ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), + "Invalid _BIF found (count=%u). Ignored.\n", + res->Package.Count); + goto end; + } + break; } - if (acpi_PkgInt32(res, 0, &sc->bif.units) != 0) - goto end; - if (acpi_PkgInt32(res, 1, &sc->bif.dcap) != 0) - goto end; - if (acpi_PkgInt32(res, 2, &sc->bif.lfcap) != 0) - goto end; - if (acpi_PkgInt32(res, 3, &sc->bif.btech) != 0) - goto end; - if (acpi_PkgInt32(res, 4, &sc->bif.dvol) != 0) - goto end; - if (acpi_PkgInt32(res, 5, &sc->bif.wcap) != 0) - goto end; - if (acpi_PkgInt32(res, 6, &sc->bif.lcap) != 0) - goto end; - if (acpi_PkgInt32(res, 7, &sc->bif.gra1) != 0) - goto end; - if (acpi_PkgInt32(res, 8, &sc->bif.gra2) != 0) - goto end; - if (acpi_PkgStr(res, 9, sc->bif.model, ACPI_CMBAT_MAXSTRLEN) != 0) - goto end; - if (acpi_PkgStr(res, 10, sc->bif.serial, ACPI_CMBAT_MAXSTRLEN) != 0) - goto end; - if (acpi_PkgStr(res, 11, sc->bif.type, ACPI_CMBAT_MAXSTRLEN) != 0) - goto end; - if (acpi_PkgStr(res, 12, sc->bif.oeminfo, ACPI_CMBAT_MAXSTRLEN) != 0) - goto end; + ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), + "rev = %04x\n", sc->bix.rev); +#define BIX_GETU32(NAME) do { \ + ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), \ + #NAME " = %u\n", sc->bix.NAME); \ + if (acpi_PkgInt32(res, i++, &sc->bix.NAME) != 0) \ + goto end; \ + } while (0) + BIX_GETU32(units); + BIX_GETU32(dcap); + BIX_GETU32(lfcap); + BIX_GETU32(btech); + BIX_GETU32(dvol); + BIX_GETU32(wcap); + BIX_GETU32(lcap); + if (ACPI_BIX_REV_MIN_CHECK(sc->bix.rev, ACPI_BIX_REV_0)) { + BIX_GETU32(cycles); + BIX_GETU32(accuracy); + BIX_GETU32(stmax); + BIX_GETU32(stmin); + BIX_GETU32(aimax); + BIX_GETU32(aimin); + } + BIX_GETU32(gra1); + BIX_GETU32(gra2); + if (acpi_PkgStr(res, i++, sc->bix.model, ACPI_CMBAT_MAXSTRLEN) != 0) + goto end; + if (acpi_PkgStr(res, i++, sc->bix.serial, ACPI_CMBAT_MAXSTRLEN) != 0) + goto end; + if (acpi_PkgStr(res, i++, sc->bix.type, ACPI_CMBAT_MAXSTRLEN) != 0) + goto end; + if (acpi_PkgStr(res, i++, sc->bix.oeminfo, ACPI_CMBAT_MAXSTRLEN) != 0) + goto end; + if (ACPI_BIX_REV_MIN_CHECK(sc->bix.rev, ACPI_BIX_REV_1)) + BIX_GETU32(scap); +#undef BIX_GETU32 end: - if (bif_buffer.Pointer != NULL) - AcpiOsFree(bif_buffer.Pointer); + AcpiOsFree(bix_buffer.Pointer); } static int -acpi_cmbat_bif(device_t dev, struct acpi_bif *bifp) +acpi_cmbat_bix(device_t dev, void *bix, size_t len) { struct acpi_cmbat_softc *sc; + if (len != sizeof(struct acpi_bix) && + len != sizeof(struct acpi_bif)) + return (-1); + sc = device_get_softc(dev); /* * Just copy the data. The only value that should change is the * last-full capacity, so we only update when we get a notify that says * the info has changed. Many systems apparently take a long time to - * process a _BIF call so we avoid it if possible. + * process a _BI[FX] call so we avoid it if possible. */ ACPI_SERIAL_BEGIN(cmbat); - bifp->units = sc->bif.units; - bifp->dcap = sc->bif.dcap; - bifp->lfcap = sc->bif.lfcap; - bifp->btech = sc->bif.btech; - bifp->dvol = sc->bif.dvol; - bifp->wcap = sc->bif.wcap; - bifp->lcap = sc->bif.lcap; - bifp->gra1 = sc->bif.gra1; - bifp->gra2 = sc->bif.gra2; - strncpy(bifp->model, sc->bif.model, sizeof(sc->bif.model)); - strncpy(bifp->serial, sc->bif.serial, sizeof(sc->bif.serial)); - strncpy(bifp->type, sc->bif.type, sizeof(sc->bif.type)); - strncpy(bifp->oeminfo, sc->bif.oeminfo, sizeof(sc->bif.oeminfo)); + memcpy(bix, &sc->bix, len); ACPI_SERIAL_END(cmbat); return (0); } static int -acpi_cmbat_bst(device_t dev, struct acpi_bst *bstp) +acpi_cmbat_bst(device_t dev, struct acpi_bst *bst) { struct acpi_cmbat_softc *sc; @@ -427,12 +516,9 @@ acpi_cmbat_bst(device_t dev, struct acpi_bst *bstp) ACPI_SERIAL_BEGIN(cmbat); if (acpi_BatteryIsPresent(dev)) { acpi_cmbat_get_bst(dev); - bstp->state = sc->bst.state; - bstp->rate = sc->bst.rate; - bstp->cap = sc->bst.cap; - bstp->volt = sc->bst.volt; + memcpy(bst, &sc->bst, sizeof(*bst)); } else - bstp->state = ACPI_BATT_STAT_NOT_PRESENT; + bst->state = ACPI_BATT_STAT_NOT_PRESENT; ACPI_SERIAL_END(cmbat); return (0); @@ -447,7 +533,7 @@ acpi_cmbat_init_battery(void *arg) dev = (device_t)arg; ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), - "battery initialization start\n"); + "battery enitialization start\n"); /* * Try repeatedly to get valid data from the battery. Since the @@ -486,11 +572,11 @@ acpi_cmbat_init_battery(void *arg) timespecclear(&sc->bst_lastupdated); acpi_cmbat_get_bst(dev); } - if (retry == 0 || !acpi_battery_bif_valid(&sc->bif)) - acpi_cmbat_get_bif(dev); + if (retry == 0 || !acpi_battery_bix_valid(&sc->bix)) + acpi_cmbat_get_bix(dev); valid = acpi_battery_bst_valid(&sc->bst) && - acpi_battery_bif_valid(&sc->bif); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Wed Mar 18 18:10:45 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8A5326821D; Wed, 18 Mar 2020 18:10:45 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jJ4P2k2Lz4gWB; Wed, 18 Mar 2020 18:10:45 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ECB2225E45; Wed, 18 Mar 2020 18:10:44 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02IIAiRa003016; Wed, 18 Mar 2020 18:10:44 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02IIAiYi003015; Wed, 18 Mar 2020 18:10:44 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <202003181810.02IIAiYi003015@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Wed, 18 Mar 2020 18:10:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359077 - in stable: 11/bin/sh 12/bin/sh X-SVN-Group: stable-11 X-SVN-Commit-Author: hrs X-SVN-Commit-Paths: in stable: 11/bin/sh 12/bin/sh X-SVN-Commit-Revision: 359077 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 18:10:45 -0000 Author: hrs Date: Wed Mar 18 18:10:44 2020 New Revision: 359077 URL: https://svnweb.freebsd.org/changeset/base/359077 Log: MFC of r358152 and r328235: Improve performance of "read" built-in command when using a seekable fd. The read built-in command calls read(2) with a 1-byte buffer because newline characters need to be detected even on a byte stream which comes from a non-seekable file descriptor. Because of this, the following script calls >6,000 read(2) to show a 6-KiB file: while read IN; do echo "$IN"; done < /COPYRIGHT When the input byte stream is seekable, it is possible to read a data block and then reposition the file pointer to where a newline character found. This change adds a small buffer to do this and reduces the number of read(2) calls. Theoretically, multiple built-in commands reading the same seekable byte stream in a single pipe chain can share the buffer. However, this change just makes a single invocation of the read built-in allocate a buffer and deallocate it every time for simplicity. Although this causes read(2) to read the same regions multiple times, the performance penalty should be small compared to the reduction of read(2) calls. Reviewed by: jilles Differential Revision: https://reviews.freebsd.org/D23747 Modified: stable/11/bin/sh/miscbltin.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/bin/sh/miscbltin.c Directory Properties: stable/12/ (props changed) Modified: stable/11/bin/sh/miscbltin.c ============================================================================== --- stable/11/bin/sh/miscbltin.c Wed Mar 18 18:02:33 2020 (r359076) +++ stable/11/bin/sh/miscbltin.c Wed Mar 18 18:10:44 2020 (r359077) @@ -64,10 +64,79 @@ __FBSDID("$FreeBSD$"); #undef eflag +#define READ_BUFLEN 1024 +struct fdctx { + int fd; + size_t off; /* offset in buf */ + size_t buflen; + char *ep; /* tail pointer */ + char buf[READ_BUFLEN]; +}; + +static void fdctx_init(int, struct fdctx *); +static void fdctx_destroy(struct fdctx *); +static ssize_t fdgetc(struct fdctx *, char *); int readcmd(int, char **); int umaskcmd(int, char **); int ulimitcmd(int, char **); +static void +fdctx_init(int fd, struct fdctx *fdc) +{ + off_t cur; + + /* Check if fd is seekable. */ + cur = lseek(fd, 0, SEEK_CUR); + *fdc = (struct fdctx){ + .fd = fd, + .buflen = (cur != -1) ? READ_BUFLEN : 1, + .ep = &fdc->buf[0], /* No data */ + }; +} + +static ssize_t +fdgetc(struct fdctx *fdc, char *c) +{ + ssize_t nread; + + if (&fdc->buf[fdc->off] == fdc->ep) { + nread = read(fdc->fd, fdc->buf, fdc->buflen); + if (nread > 0) { + fdc->off = 0; + fdc->ep = fdc->buf + nread; + } else + return (nread); + } + *c = fdc->buf[fdc->off++]; + + return (1); +} + +static void +fdctx_destroy(struct fdctx *fdc) +{ + off_t residue; + + if (fdc->buflen > 1) { + /* + * Reposition the file offset. Here is the layout of buf: + * + * | off + * v + * |*****************|-------| + * buf ep buf+buflen + * |<- residue ->| + * + * off: current character + * ep: offset just after read(2) + * residue: length for reposition + */ + residue = (fdc->ep - fdc->buf) - fdc->off; + if (residue > 0) + (void) lseek(fdc->fd, -residue, SEEK_CUR); + } +} + /* * The read builtin. The -r option causes backslashes to be treated like * ordinary characters. @@ -106,6 +175,7 @@ readcmd(int argc __unused, char **argv __unused) fd_set ifds; ssize_t nread; int sig; + struct fdctx fdctx; rflag = 0; prompt = NULL; @@ -171,8 +241,9 @@ readcmd(int argc __unused, char **argv __unused) backslash = 0; STARTSTACKSTR(p); lastnonifs = lastnonifsws = -1; + fdctx_init(STDIN_FILENO, &fdctx); for (;;) { - nread = read(STDIN_FILENO, &c, 1); + nread = fdgetc(&fdctx, &c); if (nread == -1) { if (errno == EINTR) { sig = pendingsig; @@ -258,6 +329,7 @@ readcmd(int argc __unused, char **argv __unused) STARTSTACKSTR(p); lastnonifs = lastnonifsws = -1; } + fdctx_destroy(&fdctx); STACKSTRNUL(p); /* From owner-svn-src-stable-11@freebsd.org Wed Mar 18 23:21:50 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E12A12708E0; Wed, 18 Mar 2020 23:21:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jQzL2N5yz4HQY; Wed, 18 Mar 2020 23:21:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DF47A1810; Wed, 18 Mar 2020 23:21:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02INLnH0094612; Wed, 18 Mar 2020 23:21:49 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02INLnnJ094611; Wed, 18 Mar 2020 23:21:49 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202003182321.02INLnnJ094611@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 18 Mar 2020 23:21:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359107 - stable/11/sys/dev/ciss X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ciss X-SVN-Commit-Revision: 359107 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 23:21:51 -0000 Author: mav Date: Wed Mar 18 23:21:49 2020 New Revision: 359107 URL: https://svnweb.freebsd.org/changeset/base/359107 Log: MFC r331528 (by scottl): Update a TBD string with a real model number Modified: stable/11/sys/dev/ciss/ciss.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ciss/ciss.c ============================================================================== --- stable/11/sys/dev/ciss/ciss.c Wed Mar 18 22:47:14 2020 (r359106) +++ stable/11/sys/dev/ciss/ciss.c Wed Mar 18 23:21:49 2020 (r359107) @@ -358,7 +358,7 @@ static struct { 0x103C, 0x21C8, CISS_BOARD_SA5, "HP Smart Array H241" }, { 0x103C, 0x21CA, CISS_BOARD_SA5, "HP Smart Array P246br" }, { 0x103C, 0x21CB, CISS_BOARD_SA5, "HP Smart Array P840" }, - { 0x103C, 0x21CC, CISS_BOARD_SA5, "HP Smart Array TBD" }, + { 0x103C, 0x21CC, CISS_BOARD_SA5, "HP Smart Array P542d" }, { 0x103C, 0x21CD, CISS_BOARD_SA5, "HP Smart Array P240nr" }, { 0x103C, 0x21CE, CISS_BOARD_SA5, "HP Smart Array H240nr" }, { 0, 0, 0, NULL } From owner-svn-src-stable-11@freebsd.org Wed Mar 18 23:53:35 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8535C27103B; Wed, 18 Mar 2020 23:53:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jRgz0Spgz3CVQ; Wed, 18 Mar 2020 23:53:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E43361ECE; Wed, 18 Mar 2020 23:53:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02INrY0Q014242; Wed, 18 Mar 2020 23:53:34 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02INrYwn014241; Wed, 18 Mar 2020 23:53:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202003182353.02INrYwn014241@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 18 Mar 2020 23:53:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359109 - stable/11/sys/dev/ciss X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ciss X-SVN-Commit-Revision: 359109 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 23:53:35 -0000 Author: mav Date: Wed Mar 18 23:53:34 2020 New Revision: 359109 URL: https://svnweb.freebsd.org/changeset/base/359109 Log: MFC r349011 (by imp): Don't print the request we may be aborting in ciss_notify_abort as part of ciss_detach. It's a left-over debug that isn't needed and also discloses a kernel address. Only root could provoke as part of a devctl or kldunload. Submitted by: Fuqian Huang Modified: stable/11/sys/dev/ciss/ciss.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ciss/ciss.c ============================================================================== --- stable/11/sys/dev/ciss/ciss.c Wed Mar 18 23:53:07 2020 (r359108) +++ stable/11/sys/dev/ciss/ciss.c Wed Mar 18 23:53:34 2020 (r359109) @@ -105,6 +105,10 @@ #include #include +#ifdef CISS_DEBUG +#include "opt_ddb.h" +#endif + static MALLOC_DEFINE(CISS_MALLOC_CLASS, "ciss_data", "ciss internal data buffers"); @@ -195,7 +199,9 @@ static void ciss_notify_logical(struct ciss_softc *sc, static void ciss_notify_physical(struct ciss_softc *sc, struct ciss_notify *cn); /* debugging output */ +#ifdef DDB static void ciss_print_request(struct ciss_request *cr); +#endif static void ciss_print_ldrive(struct ciss_softc *sc, struct ciss_ldrive *ld); static const char *ciss_name_ldrive_status(int status); static int ciss_decode_ldrive_status(int status); @@ -3806,8 +3812,9 @@ ciss_notify_abort(struct ciss_softc *sc) cnc->opcode = CISS_OPCODE_WRITE; cnc->command = CISS_COMMAND_ABORT_NOTIFY; cnc->length = htonl(CISS_NOTIFY_DATA_SIZE); - +#if 0 ciss_print_request(cr); +#endif /* * Submit the request and wait for it to complete. @@ -4232,6 +4239,7 @@ ciss_kill_notify_thread(struct ciss_softc *sc) /************************************************************************ * Print a request. */ +#ifdef DDB static void ciss_print_request(struct ciss_request *cr) { @@ -4285,6 +4293,7 @@ ciss_print_request(struct ciss_request *cr) } } } +#endif /************************************************************************ * Print information about the status of a logical drive. @@ -4348,8 +4357,6 @@ ciss_print_ldrive(struct ciss_softc *sc, struct ciss_l } } -#ifdef CISS_DEBUG -#include "opt_ddb.h" #ifdef DDB #include /************************************************************************ @@ -4403,7 +4410,6 @@ DB_COMMAND(ciss_prt, db_ciss_prt) ciss_print_adapter(sc); } } -#endif #endif /************************************************************************ From owner-svn-src-stable-11@freebsd.org Thu Mar 19 02:22:09 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 437CD276EF3; Thu, 19 Mar 2020 02:22:09 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jVzP05GXz4HlL; Thu, 19 Mar 2020 02:22:09 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D80943DCD; Thu, 19 Mar 2020 02:22:08 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02J2M8ik003393; Thu, 19 Mar 2020 02:22:08 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02J2M8rL003242; Thu, 19 Mar 2020 02:22:08 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <202003190222.02J2M8rL003242@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Thu, 19 Mar 2020 02:22:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359114 - stable/11/sys/dev/sound/pci/hda X-SVN-Group: stable-11 X-SVN-Commit-Author: gonzo X-SVN-Commit-Paths: stable/11/sys/dev/sound/pci/hda X-SVN-Commit-Revision: 359114 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 02:22:09 -0000 Author: gonzo Date: Thu Mar 19 02:22:08 2020 New Revision: 359114 URL: https://svnweb.freebsd.org/changeset/base/359114 Log: MFC r352775-r352776 r352775: snd_hda: Add Intel Cannon Lake support Add PCI ids for Intel Cannon Lake PCH Tested on: HP Spectre x360 13-p0043dx PR: 240574 Submitted by: Neel Chauhan Reviewed by: imp, mizhka, ray Differential Revision: https://reviews.freebsd.org/D21789 r352776: snd_hda: Add Intel Cannon Lake support Add missing header change ommitted in r352775 X-MFC-with: 352775 Modified: stable/11/sys/dev/sound/pci/hda/hdac.c stable/11/sys/dev/sound/pci/hda/hdac.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.c Thu Mar 19 01:50:24 2020 (r359113) +++ stable/11/sys/dev/sound/pci/hda/hdac.c Thu Mar 19 02:22:08 2020 (r359114) @@ -99,6 +99,7 @@ static const struct { { HDA_INTEL_KBLK, "Intel Kaby Lake", 0, 0 }, { HDA_INTEL_KBLKH, "Intel Kaby Lake-H", 0, 0 }, { HDA_INTEL_CFLK, "Intel Coffee Lake", 0, 0 }, + { HDA_INTEL_CNLK, "Intel Cannon Lake", 0, 0 }, { HDA_INTEL_82801F, "Intel 82801F", 0, 0 }, { HDA_INTEL_63XXESB, "Intel 631x/632xESB", 0, 0 }, { HDA_INTEL_82801G, "Intel 82801G", 0, 0 }, Modified: stable/11/sys/dev/sound/pci/hda/hdac.h ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.h Thu Mar 19 01:50:24 2020 (r359113) +++ stable/11/sys/dev/sound/pci/hda/hdac.h Thu Mar 19 02:22:08 2020 (r359114) @@ -75,6 +75,7 @@ #define HDA_INTEL_KBLK HDA_MODEL_CONSTRUCT(INTEL, 0xa171) #define HDA_INTEL_KBLKH HDA_MODEL_CONSTRUCT(INTEL, 0xa2f0) #define HDA_INTEL_CFLK HDA_MODEL_CONSTRUCT(INTEL, 0xa348) +#define HDA_INTEL_CNLK HDA_MODEL_CONSTRUCT(INTEL, 0x9dc8) #define HDA_INTEL_ALL HDA_MODEL_CONSTRUCT(INTEL, 0xffff) /* Nvidia */ From owner-svn-src-stable-11@freebsd.org Thu Mar 19 03:29:47 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EE2F8278EFD; Thu, 19 Mar 2020 03:29:47 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jXTR3lmzz3wfl; Thu, 19 Mar 2020 03:29:47 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B9DD4A11; Thu, 19 Mar 2020 03:29:47 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02J3TljI041531; Thu, 19 Mar 2020 03:29:47 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02J3TlV4041530; Thu, 19 Mar 2020 03:29:47 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202003190329.02J3TlV4041530@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 19 Mar 2020 03:29:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359115 - in stable: 11/lib/libpam/modules/pam_login_access 12/lib/libpam/modules/pam_login_access X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/lib/libpam/modules/pam_login_access 12/lib/libpam/modules/pam_login_access X-SVN-Commit-Revision: 359115 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 03:29:48 -0000 Author: cy Date: Thu Mar 19 03:29:46 2020 New Revision: 359115 URL: https://svnweb.freebsd.org/changeset/base/359115 Log: MFC r358065: The words ALL, LOCAL, and EXCEPT have special meaning and are documented as in the login.access(5) man page. However strcasecmp() is used to compare for these special strings. Because of this User accounts and groups with the corresponding lowercase names are misintrepreted to have special whereas they should not. This commit fixes this, conforming to the man page and to how the Linux pam_access(8) handles these special words. Approved by: des (implicit, blanket) Modified: stable/11/lib/libpam/modules/pam_login_access/login_access.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/lib/libpam/modules/pam_login_access/login_access.c Directory Properties: stable/12/ (props changed) Modified: stable/11/lib/libpam/modules/pam_login_access/login_access.c ============================================================================== --- stable/11/lib/libpam/modules/pam_login_access/login_access.c Thu Mar 19 02:22:08 2020 (r359114) +++ stable/11/lib/libpam/modules/pam_login_access/login_access.c Thu Mar 19 03:29:46 2020 (r359115) @@ -125,7 +125,7 @@ list_match(char *list, const char *item, */ for (tok = strtok(list, sep); tok != NULL; tok = strtok((char *) 0, sep)) { - if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */ + if (strcmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */ break; if ((match = (*match_fn)(tok, item)) != 0) /* YES */ break; @@ -133,7 +133,7 @@ list_match(char *list, const char *item, /* Process exceptions to matches. */ if (match != NO) { - while ((tok = strtok((char *) 0, sep)) && strcasecmp(tok, "EXCEPT")) + while ((tok = strtok((char *) 0, sep)) && strcmp(tok, "EXCEPT")) /* VOID */ ; if (tok == NULL || list_match((char *) 0, item, match_fn) == NO) return (match); @@ -219,7 +219,7 @@ from_match(const char *tok, const char *string) if ((str_len = strlen(string)) > (tok_len = strlen(tok)) && strcasecmp(tok, string + str_len - tok_len) == 0) return (YES); - } else if (strcasecmp(tok, "LOCAL") == 0) { /* local: no dots */ + } else if (strcmp(tok, "LOCAL") == 0) { /* local: no dots */ if (strchr(string, '.') == NULL) return (YES); } else if (tok[(tok_len = strlen(tok)) - 1] == '.' /* network */ @@ -240,7 +240,7 @@ string_match(const char *tok, const char *string) * Otherwise, return YES if the token fully matches the string. */ - if (strcasecmp(tok, "ALL") == 0) { /* all: always matches */ + if (strcmp(tok, "ALL") == 0) { /* all: always matches */ return (YES); } else if (strcasecmp(tok, string) == 0) { /* try exact match */ return (YES); From owner-svn-src-stable-11@freebsd.org Thu Mar 19 03:31:12 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB7D6279030; Thu, 19 Mar 2020 03:31:12 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jXW44RbBz40BM; Thu, 19 Mar 2020 03:31:12 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9202A4A56; Thu, 19 Mar 2020 03:31:12 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02J3VChu042783; Thu, 19 Mar 2020 03:31:12 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02J3VCIk042770; Thu, 19 Mar 2020 03:31:12 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202003190331.02J3VCIk042770@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 19 Mar 2020 03:31:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359116 - in stable: 11/lib/libpam/modules/pam_login_access 12/lib/libpam/modules/pam_login_access X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/lib/libpam/modules/pam_login_access 12/lib/libpam/modules/pam_login_access X-SVN-Commit-Revision: 359116 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 03:31:12 -0000 Author: cy Date: Thu Mar 19 03:31:12 2020 New Revision: 359116 URL: https://svnweb.freebsd.org/changeset/base/359116 Log: MFC r358066: When pam_login_access(5) fails to match a username it attempts to match the primary group a user belongs to. This commit extends the match to secondary groups a user belongs to as well, just as the Linux pam_access(5) does. Approved by: des (implicit, blanket) Modified: stable/11/lib/libpam/modules/pam_login_access/login_access.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/lib/libpam/modules/pam_login_access/login_access.c Directory Properties: stable/12/ (props changed) Modified: stable/11/lib/libpam/modules/pam_login_access/login_access.c ============================================================================== --- stable/11/lib/libpam/modules/pam_login_access/login_access.c Thu Mar 19 03:29:46 2020 (r359115) +++ stable/11/lib/libpam/modules/pam_login_access/login_access.c Thu Mar 19 03:31:12 2020 (r359116) @@ -17,10 +17,12 @@ static char sccsid[] = "%Z% %M% %I% %E% %U%"; __FBSDID("$FreeBSD$"); #include +#include #include #include #include #include +#include #include #include #include @@ -174,6 +176,9 @@ static int user_match(const char *tok, const char *string) { struct group *group; + struct passwd *passwd; + gid_t *grouplist; + int ngroups = NGROUPS; int i; /* @@ -186,10 +191,37 @@ user_match(const char *tok, const char *string) return (netgroup_match(tok + 1, (char *) 0, string)); } else if (string_match(tok, string)) { /* ALL or exact match */ return (YES); - } else if ((group = getgrnam(tok)) != NULL) {/* try group membership */ - for (i = 0; group->gr_mem[i]; i++) - if (strcasecmp(string, group->gr_mem[i]) == 0) + } else { + if ((passwd = getpwnam(string)) == NULL) + return (NO); + errno = 0; + if ((group = getgrnam(tok)) == NULL) {/* try group membership */ + if (errno != 0) { + syslog(LOG_ERR, "getgrnam() failed for %s: %s", string, strerror(errno)); + } else { + syslog(LOG_NOTICE, "group not found: %s", string); + } + return (NO); + } + errno = 0; + if ((grouplist = calloc(ngroups, sizeof(gid_t))) == NULL) { + if (errno == ENOMEM) { + syslog(LOG_ERR, "cannot allocate memory for grouplist: %s", string); + } + return (NO); + } + if (getgrouplist(string, passwd->pw_gid, grouplist, &ngroups) != 0) { + syslog(LOG_ERR, "getgrouplist() failed for %s", string); + free(grouplist); + return (NO); + } + for (i = 0; i < ngroups; i++) { + if (grouplist[i] == group->gr_gid) { + free(grouplist); return (YES); + } + } + free(grouplist); } return (NO); } From owner-svn-src-stable-11@freebsd.org Thu Mar 19 03:37:04 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A581427928E; Thu, 19 Mar 2020 03:37:04 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jXdr44Dmz4Bcn; Thu, 19 Mar 2020 03:37:04 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 18BF34BDF; Thu, 19 Mar 2020 03:37:04 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02J3b427047338; Thu, 19 Mar 2020 03:37:04 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02J3b3Uc047331; Thu, 19 Mar 2020 03:37:03 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202003190337.02J3b3Uc047331@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 19 Mar 2020 03:37:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359117 - in stable: 11/lib/libpam/modules/pam_login_access 12/lib/libpam/modules/pam_login_access X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/lib/libpam/modules/pam_login_access 12/lib/libpam/modules/pam_login_access X-SVN-Commit-Revision: 359117 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 03:37:04 -0000 Author: cy Date: Thu Mar 19 03:37:02 2020 New Revision: 359117 URL: https://svnweb.freebsd.org/changeset/base/359117 Log: MFC r358070: This commit makes significant changes to pam_login_access(8) to bring it up to par with the Linux pam_access(8). Like the Linux pam_access(8) our pam_login_access(8) is a service module for pam(3) that allows a administrator to limit access from specified remote hosts or terminals. Unlike the Linux pam_access, pam_login_access is missing some features which are added by this commit: Access file can now be specified. The default remains /etc/access.conf. The syntax is consistent with Linux pam_access. By default usernames are matched. If the username fails to match a match against a group name is attempted. The new nodefgroup module option will only match a username and no attempt to match a group name is made. Group names must be specified in brackets, "()" when nodefgroup is specified. Otherwise the old backward compatible behavior is used. This is consistent with Linux pam_access. A new field separator module option allows the replacement of the default colon (:) with any other character. This facilitates potential future specification of X displays. This is also consistent with Linux pam_access. A new list separator module option to replace the default space/comma/tab with another character. This too is consistent with Linux pam_access. Linux pam_access options not implemented in this commit are the debug and audit options. These will be implemented at a later date. Reviewed by: bjk, bcr (for manpages) Approved by: des (blanket, implicit) Differential Revision: https://reviews.freebsd.org/D23198 Modified: stable/11/lib/libpam/modules/pam_login_access/login.access.5 stable/11/lib/libpam/modules/pam_login_access/login_access.c stable/11/lib/libpam/modules/pam_login_access/pam_login_access.8 stable/11/lib/libpam/modules/pam_login_access/pam_login_access.c stable/11/lib/libpam/modules/pam_login_access/pam_login_access.h Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/lib/libpam/modules/pam_login_access/login.access.5 stable/12/lib/libpam/modules/pam_login_access/login_access.c stable/12/lib/libpam/modules/pam_login_access/pam_login_access.8 stable/12/lib/libpam/modules/pam_login_access/pam_login_access.c stable/12/lib/libpam/modules/pam_login_access/pam_login_access.h Directory Properties: stable/12/ (props changed) Modified: stable/11/lib/libpam/modules/pam_login_access/login.access.5 ============================================================================== --- stable/11/lib/libpam/modules/pam_login_access/login.access.5 Thu Mar 19 03:31:12 2020 (r359116) +++ stable/11/lib/libpam/modules/pam_login_access/login.access.5 Thu Mar 19 03:37:02 2020 (r359117) @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 27, 2020 +.Dd January 30, 2020 .Dt LOGIN.ACCESS 5 .Os .Sh NAME @@ -34,6 +34,13 @@ character. .Pp The second field should be a list of one or more login names, group names, or ALL (always matches). +Group names must be enclosed in +parentheses if the pam module specification for +.Pa pam_login_access +specifies the +.Pa nodefgroup +option. +Otherwise, group names will only match if no usernames match. .Pp The third field should be a list of one or more tty names (for non-networked logins), host names, domain Modified: stable/11/lib/libpam/modules/pam_login_access/login_access.c ============================================================================== --- stable/11/lib/libpam/modules/pam_login_access/login_access.c Thu Mar 19 03:31:12 2020 (r359116) +++ stable/11/lib/libpam/modules/pam_login_access/login_access.c Thu Mar 19 03:37:02 2020 (r359117) @@ -31,29 +31,26 @@ __FBSDID("$FreeBSD$"); #include "pam_login_access.h" -#define _PATH_LOGACCESS "/etc/login.access" - - /* Delimiters for fields and for lists of users, ttys or hosts. */ - -static char fs[] = ":"; /* field separator */ -static char sep[] = ", \t"; /* list-element separator */ - /* Constants to be used in assignments only, not in comparisons... */ #define YES 1 #define NO 0 -static int from_match(const char *, const char *); +static int from_match(const char *, const char *, struct pam_login_access_options *); static int list_match(char *, const char *, - int (*)(const char *, const char *)); + int (*)(const char *, const char *, + struct pam_login_access_options *), + struct pam_login_access_options *); static int netgroup_match(const char *, const char *, const char *); static int string_match(const char *, const char *); -static int user_match(const char *, const char *); +static int user_match(const char *, const char *, struct pam_login_access_options *); +static int group_match(const char *, const char *); /* login_access - match username/group and host/tty with access control file */ int -login_access(const char *user, const char *from) +login_access(const char *user, const char *from, + struct pam_login_access_options *login_access_opts) { FILE *fp; char line[BUFSIZ]; @@ -63,6 +60,7 @@ login_access(const char *user, const char *from) int match = NO; int end; int lineno = 0; /* for diagnostics */ + const char *fieldsep = login_access_opts->fieldsep; /* * Process the table one line at a time and stop at the first match. @@ -72,12 +70,12 @@ login_access(const char *user, const char *from) * non-existing table means no access control. */ - if ((fp = fopen(_PATH_LOGACCESS, "r")) != NULL) { + if ((fp = fopen(login_access_opts->accessfile, "r")) != NULL) { while (!match && fgets(line, sizeof(line), fp)) { lineno++; if (line[end = strlen(line) - 1] != '\n') { syslog(LOG_ERR, "%s: line %d: missing newline or line too long", - _PATH_LOGACCESS, lineno); + login_access_opts->accessfile, lineno); continue; } if (line[0] == '#') @@ -87,25 +85,25 @@ login_access(const char *user, const char *from) line[end] = 0; /* strip trailing whitespace */ if (line[0] == 0) /* skip blank lines */ continue; - if (!(perm = strtok(line, fs)) - || !(users = strtok((char *) 0, fs)) - || !(froms = strtok((char *) 0, fs)) - || strtok((char *) 0, fs)) { - syslog(LOG_ERR, "%s: line %d: bad field count", _PATH_LOGACCESS, + if (!(perm = strtok(line, fieldsep)) + || !(users = strtok((char *) 0, fieldsep)) + || !(froms = strtok((char *) 0, fieldsep)) + || strtok((char *) 0, fieldsep)) { + syslog(LOG_ERR, "%s: line %d: bad field count", login_access_opts->accessfile, lineno); continue; } if (perm[0] != '+' && perm[0] != '-') { - syslog(LOG_ERR, "%s: line %d: bad first field", _PATH_LOGACCESS, + syslog(LOG_ERR, "%s: line %d: bad first field", login_access_opts->accessfile, lineno); continue; } - match = (list_match(froms, from, from_match) - && list_match(users, user, user_match)); + match = (list_match(froms, from, from_match, login_access_opts) + && list_match(users, user, user_match, login_access_opts)); } (void) fclose(fp); } else if (errno != ENOENT) { - syslog(LOG_ERR, "cannot open %s: %m", _PATH_LOGACCESS); + syslog(LOG_ERR, "cannot open %s: %m", login_access_opts->accessfile); } return (match == 0 || (line[0] == '+')); } @@ -114,10 +112,12 @@ login_access(const char *user, const char *from) static int list_match(char *list, const char *item, - int (*match_fn)(const char *, const char *)) + int (*match_fn)(const char *, const char *, struct pam_login_access_options *), + struct pam_login_access_options *login_access_opts) { char *tok; int match = NO; + const char *listsep = login_access_opts->listsep; /* * Process tokens one at a time. We have exhausted all possible matches @@ -126,19 +126,22 @@ list_match(char *list, const char *item, * the match is affected by any exceptions. */ - for (tok = strtok(list, sep); tok != NULL; tok = strtok((char *) 0, sep)) { + for (tok = strtok(list, listsep); tok != NULL; tok = strtok((char *) 0, listsep)) { if (strcmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */ break; - if ((match = (*match_fn)(tok, item)) != 0) /* YES */ + if ((match = (*match_fn)(tok, item, login_access_opts)) != 0) /* YES */ break; } /* Process exceptions to matches. */ if (match != NO) { - while ((tok = strtok((char *) 0, sep)) && strcmp(tok, "EXCEPT")) + while ((tok = strtok((char *) 0, listsep)) && strcmp(tok, "EXCEPT")) { /* VOID */ ; - if (tok == NULL || list_match((char *) 0, item, match_fn) == NO) - return (match); + if (tok == NULL || list_match((char *) 0, item, match_fn, + login_access_opts) == NO) { + return (match); + } + } } return (NO); } @@ -170,17 +173,50 @@ netgroup_match(const char *group, const char *machine, return (NO); } -/* user_match - match a username against one token */ +/* group_match - match a group against one token */ -static int -user_match(const char *tok, const char *string) +int +group_match(const char *tok, const char *username) { struct group *group; struct passwd *passwd; gid_t *grouplist; - int ngroups = NGROUPS; - int i; + int i, ret, ngroups = NGROUPS; + if ((passwd = getpwnam(username)) == NULL) + return (NO); + errno = 0; + if ((group = getgrnam(tok)) == NULL) { + if (errno != 0) + syslog(LOG_ERR, "getgrnam() failed for %s: %s", username, strerror(errno)); + else + syslog(LOG_NOTICE, "group not found: %s", username); + return (NO); + } + if ((grouplist = calloc(ngroups, sizeof(gid_t))) == NULL) { + syslog(LOG_ERR, "cannot allocate memory for grouplist: %s", username); + return (NO); + } + ret = NO; + if (getgrouplist(username, passwd->pw_gid, grouplist, &ngroups) != 0) + syslog(LOG_ERR, "getgrouplist() failed for %s", username); + for (i = 0; i < ngroups; i++) + if (grouplist[i] == group->gr_gid) + ret = YES; + free(grouplist); + return (ret); +} + +/* user_match - match a username against one token */ + +static int +user_match(const char *tok, const char *string, + struct pam_login_access_options *login_access_opts) +{ + size_t stringlen; + char *grpstr; + int rc; + /* * If a token has the magic value "ALL" the match always succeeds. * Otherwise, return YES if the token fully matches the username, or if @@ -189,39 +225,18 @@ user_match(const char *tok, const char *string) if (tok[0] == '@') { /* netgroup */ return (netgroup_match(tok + 1, (char *) 0, string)); - } else if (string_match(tok, string)) { /* ALL or exact match */ - return (YES); - } else { - if ((passwd = getpwnam(string)) == NULL) - return (NO); - errno = 0; - if ((group = getgrnam(tok)) == NULL) {/* try group membership */ - if (errno != 0) { - syslog(LOG_ERR, "getgrnam() failed for %s: %s", string, strerror(errno)); - } else { - syslog(LOG_NOTICE, "group not found: %s", string); - } + } else if (tok[0] == '(' && tok[(stringlen = strlen(&tok[1]))] == ')') { /* group */ + if ((grpstr = strndup(&tok[1], stringlen - 1)) == NULL) { + syslog(LOG_ERR, "cannot allocate memory for %s", string); return (NO); } - errno = 0; - if ((grouplist = calloc(ngroups, sizeof(gid_t))) == NULL) { - if (errno == ENOMEM) { - syslog(LOG_ERR, "cannot allocate memory for grouplist: %s", string); - } - return (NO); - } - if (getgrouplist(string, passwd->pw_gid, grouplist, &ngroups) != 0) { - syslog(LOG_ERR, "getgrouplist() failed for %s", string); - free(grouplist); - return (NO); - } - for (i = 0; i < ngroups; i++) { - if (grouplist[i] == group->gr_gid) { - free(grouplist); - return (YES); - } - } - free(grouplist); + rc = group_match(grpstr, string); + free(grpstr); + return (rc); + } else if (string_match(tok, string)) { /* ALL or exact match */ + return (YES); + } else if (login_access_opts->defgroup == true) {/* try group membership */ + return (group_match(tok, string)); } return (NO); } @@ -229,7 +244,8 @@ user_match(const char *tok, const char *string) /* from_match - match a host or tty against a list of tokens */ static int -from_match(const char *tok, const char *string) +from_match(const char *tok, const char *string, + struct pam_login_access_options *login_access_opts __unused) { int tok_len; int str_len; Modified: stable/11/lib/libpam/modules/pam_login_access/pam_login_access.8 ============================================================================== --- stable/11/lib/libpam/modules/pam_login_access/pam_login_access.8 Thu Mar 19 03:31:12 2020 (r359116) +++ stable/11/lib/libpam/modules/pam_login_access/pam_login_access.8 Thu Mar 19 03:37:02 2020 (r359117) @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 24, 2002 +.Dd January 30, 2020 .Dt PAM_LOGIN_ACCESS 8 .Os .Sh NAME @@ -63,13 +63,46 @@ The .Pa login.access account management component .Pq Fn pam_sm_acct_mgmt , -returns success if and only the user is allowed to log in on the +returns success if and only the user is allowed to login on the specified tty (in the case of a local login) or from the specified remote host (in the case of a remote login), according to the restrictions listed in .Xr login.access 5 . +.Bl -tag -width ".Cm accessfile=pathname" +.It Cm accessfile Ns = Ns Ar pathname +specifies a non-standard location for the +.Pa login.access +configuration file +(normally located in +.Pa /etc/login.access ) . +.It Cm nodefgroup +makes tokens not enclosed in parentheses only match users, requiring groups +to be specified in parentheses. +Without +.Cm nodefgroup +user and group names are intermingled, with user entries taking precedence +over group entries. +This is not backwards compatible with legacy +.Pa login.access +configuration files. +However this mitigates confusion between users and +groups of the same name. +.It Cm fieldsep Ns = Ns Ar separators +changes the field separator from the default ":". +More than one separator +may be specified. +.It Cm listsep Ns = Ns Ar separators +changes the field separator from the default space (''), tab (\\t) and +comma (,). +More than one separator may be specified. +For example, listsep=; +will replace the default with a semicolon (;). +This option may be useful when specifying Active Directory groupnames which +typically contain spaces. +.El .Sh SEE ALSO .Xr pam 3 , +.Xr syslog 3 , .Xr login.access 5 , .Xr pam.conf 5 .Sh AUTHORS Modified: stable/11/lib/libpam/modules/pam_login_access/pam_login_access.c ============================================================================== --- stable/11/lib/libpam/modules/pam_login_access/pam_login_access.c Thu Mar 19 03:31:12 2020 (r359116) +++ stable/11/lib/libpam/modules/pam_login_access/pam_login_access.c Thu Mar 19 03:37:02 2020 (r359117) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #define _BSD_SOURCE #include +#include #include #include @@ -49,13 +50,25 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "pam_login_access.h" +#define OPT_ACCESSFILE "accessfile" +#define OPT_NOAUDIT "noaudit" +#define OPT_FIELDSEP "fieldsep" +#define OPT_LISTSEP "listsep" +#define OPT_NODEFGROUP "nodefgroup" + +#define _PATH_LOGACCESS "/etc/login.access" +#define _FIELD_SEPARATOR ":" +#define _LIST_SEPARATOR ", \t" + PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, int argc __unused, const char *argv[] __unused) { + struct pam_login_access_options login_access_opts; const void *rhost, *tty, *user; char hostname[MAXHOSTNAMELEN]; int pam_err; @@ -78,25 +91,33 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unuse return (pam_err); gethostname(hostname, sizeof hostname); + login_access_opts.defgroup = openpam_get_option(pamh, OPT_NODEFGROUP) == NULL ? true : false; + login_access_opts.audit = openpam_get_option(pamh, OPT_NOAUDIT) == NULL ? true : false; + if ((login_access_opts.accessfile = openpam_get_option(pamh, OPT_ACCESSFILE)) == NULL) + login_access_opts.accessfile = _PATH_LOGACCESS; + if ((login_access_opts.fieldsep = openpam_get_option(pamh, OPT_FIELDSEP)) == NULL) + login_access_opts.fieldsep = _FIELD_SEPARATOR; + if ((login_access_opts.listsep = openpam_get_option(pamh, OPT_LISTSEP)) == NULL) + login_access_opts.listsep = _LIST_SEPARATOR; if (rhost != NULL && *(const char *)rhost != '\0') { PAM_LOG("Checking login.access for user %s from host %s", (const char *)user, (const char *)rhost); - if (login_access(user, rhost) != 0) + if (login_access(user, rhost, &login_access_opts) != 0) return (PAM_SUCCESS); PAM_VERBOSE_ERROR("%s is not allowed to log in from %s", (const char *)user, (const char *)rhost); } else if (tty != NULL && *(const char *)tty != '\0') { PAM_LOG("Checking login.access for user %s on tty %s", (const char *)user, (const char *)tty); - if (login_access(user, tty) != 0) + if (login_access(user, tty, &login_access_opts) != 0) return (PAM_SUCCESS); PAM_VERBOSE_ERROR("%s is not allowed to log in on %s", (const char *)user, (const char *)tty); } else { PAM_LOG("Checking login.access for user %s", (const char *)user); - if (login_access(user, "***unknown***") != 0) + if (login_access(user, "***unknown***", &login_access_opts) != 0) return (PAM_SUCCESS); PAM_VERBOSE_ERROR("%s is not allowed to log in", (const char *)user); Modified: stable/11/lib/libpam/modules/pam_login_access/pam_login_access.h ============================================================================== --- stable/11/lib/libpam/modules/pam_login_access/pam_login_access.h Thu Mar 19 03:31:12 2020 (r359116) +++ stable/11/lib/libpam/modules/pam_login_access/pam_login_access.h Thu Mar 19 03:37:02 2020 (r359117) @@ -36,4 +36,15 @@ * $FreeBSD$ */ -extern int login_access(const char *, const char *); +#include + +struct pam_login_access_options { + bool defgroup; + bool audit; + const char *accessfile; + /* Delimiters for fields and for lists of users, ttys or hosts. */ + const char *fieldsep; /* field separator */ + const char *listsep; /* list-element separator */ +}; + +extern int login_access(const char *, const char *, struct pam_login_access_options *); From owner-svn-src-stable-11@freebsd.org Thu Mar 19 09:20:05 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6FEB32597FC; Thu, 19 Mar 2020 09:20:05 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jhFc6hV2z3C9m; Thu, 19 Mar 2020 09:20:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7BE7F8A73; Thu, 19 Mar 2020 09:20:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02J9K48m053537; Thu, 19 Mar 2020 09:20:04 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02J9K4rp053536; Thu, 19 Mar 2020 09:20:04 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202003190920.02J9K4rp053536@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 19 Mar 2020 09:20:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359122 - stable/11/sys/ofed/drivers/infiniband/ulp/ipoib X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/ofed/drivers/infiniband/ulp/ipoib X-SVN-Commit-Revision: 359122 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 09:20:05 -0000 Author: hselasky Date: Thu Mar 19 09:20:04 2020 New Revision: 359122 URL: https://svnweb.freebsd.org/changeset/base/359122 Log: MFC r359014: Fix for double unlock in ipoib. The ipoib_unicast_send() function is not supposed to unlock the priv lock. Sponsored by: Mellanox Technologies Modified: stable/11/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c ============================================================================== --- stable/11/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Thu Mar 19 09:19:22 2020 (r359121) +++ stable/11/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Thu Mar 19 09:20:04 2020 (r359122) @@ -725,7 +725,6 @@ ipoib_unicast_send(struct mbuf *mb, struct ipoib_dev_p } if (!path->query && path_rec_start(priv, path)) { - spin_unlock_irqrestore(&priv->lock, flags); if (new_path) ipoib_path_free(priv, path); return; From owner-svn-src-stable-11@freebsd.org Thu Mar 19 10:32:40 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 347A825B4E1; Thu, 19 Mar 2020 10:32:40 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jjsM6DzYz4T4r; Thu, 19 Mar 2020 10:32:39 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6A5799925; Thu, 19 Mar 2020 10:32:39 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02JAWdmm001434; Thu, 19 Mar 2020 10:32:39 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02JAWdeJ001433; Thu, 19 Mar 2020 10:32:39 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202003191032.02JAWdeJ001433@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Thu, 19 Mar 2020 10:32:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359128 - stable/11/lib/libc/gen X-SVN-Group: stable-11 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/11/lib/libc/gen X-SVN-Commit-Revision: 359128 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 10:32:40 -0000 Author: 0mp (doc,ports committer) Date: Thu Mar 19 10:32:38 2020 New Revision: 359128 URL: https://svnweb.freebsd.org/changeset/base/359128 Log: MFC 358674, 358916: ftw.3: Add examples PR: 173448 [1] Submitted by: fernape@ (previous version) [1] Reviewed by: jilles Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D21750 ftw.3: Follow style(9) in the example Reported by: oshogbo Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D24043 Modified: stable/11/lib/libc/gen/ftw.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/ftw.3 ============================================================================== --- stable/11/lib/libc/gen/ftw.3 Thu Mar 19 10:31:46 2020 (r359127) +++ stable/11/lib/libc/gen/ftw.3 Thu Mar 19 10:32:38 2020 (r359128) @@ -20,7 +20,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 5, 2004 +.Dd March 12, 2020 .Dt FTW 3 .Os .Sh NAME @@ -157,6 +157,66 @@ and will stop processing the tree and return the value from .Fa fn . Both functions return \-1 if an error is detected. +.Sh EXAMPLES +Following there is an example that shows how +.Nm nftw +can be used. +It traverses the file tree starting at the directory pointed +by the only program argument and shows the complete path and a brief +indicator about the file type. +.Bd -literal -offset 2n +#include +#include +#include + +int +nftw_callback(const char *path, const struct stat *sb, int typeflag, struct FTW *ftw) +{ + char type; + + switch(typeflag) { + case FTW_F: + type = 'F'; + break; + case FTW_D: + type = 'D'; + break; + case FTW_DNR: + type = '-'; + break; + case FTW_DP: + type = 'd'; + break; + case FTW_NS: + type = 'X'; + break; + case FTW_SL: + type = 'S'; + break; + case FTW_SLN: + type = 's'; + break; + default: + type = '?'; + break; + } + + printf("[%c] %s\\n", type, path); + + return (0); +} + +int +main(int argc, char **argv) +{ + + if (argc != 2) { + printf("Usage %s \\n", argv[0]); + return (EX_USAGE); + } else + return (nftw(argv[1], nftw_callback, /* UNUSED */ 1, 0)); +} +.Ed .Sh ERRORS The .Fn ftw From owner-svn-src-stable-11@freebsd.org Thu Mar 19 17:59:29 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8E34D26C636; Thu, 19 Mar 2020 17:59:29 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48jvmw6q0tz458h; Thu, 19 Mar 2020 17:59:28 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AE3DFECAD; Thu, 19 Mar 2020 17:59:28 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02JHxSZU066922; Thu, 19 Mar 2020 17:59:28 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02JHxShn066921; Thu, 19 Mar 2020 17:59:28 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <202003191759.02JHxShn066921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 19 Mar 2020 17:59:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359148 - stable/11/release/doc/share/xml X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/11/release/doc/share/xml X-SVN-Commit-Revision: 359148 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 17:59:29 -0000 Author: gjb Date: Thu Mar 19 17:59:28 2020 New Revision: 359148 URL: https://svnweb.freebsd.org/changeset/base/359148 Log: Document EN-20:03-06, SA-20:04-09. Sponsored by: Rubicon Communications, LLC (netgate.com) Modified: stable/11/release/doc/share/xml/errata.xml stable/11/release/doc/share/xml/security.xml Modified: stable/11/release/doc/share/xml/errata.xml ============================================================================== --- stable/11/release/doc/share/xml/errata.xml Thu Mar 19 17:27:08 2020 (r359147) +++ stable/11/release/doc/share/xml/errata.xml Thu Mar 19 17:59:28 2020 (r359148) @@ -69,6 +69,20 @@ 28 January 2020 Invalid pointer dereference + + + FreeBSD-EN-20:04.pfctl + 18 March 2020 + Missing &man.pfctl.8; tunable + + + + FreeBSD-EN-20:06.ipv6 + 18 March 2020 + Incorrect checksum calculations + Modified: stable/11/release/doc/share/xml/security.xml ============================================================================== --- stable/11/release/doc/share/xml/security.xml Thu Mar 19 17:27:08 2020 (r359147) +++ stable/11/release/doc/share/xml/security.xml Thu Mar 19 17:59:28 2020 (r359148) @@ -139,6 +139,45 @@ 28 January 2020 Kernel stack data disclosure + + + FreeBSD-SA-20:04.tcp + 18 March 2020 + TCP IPv6 SYN cache kernel information + disclosure + + + + FreeBSD-SA-20:05.if_oce_ioctl + 18 March 2020 + Insufficient &man.ioctl.2; privilege + checking + + + + FreeBSD-SA-20:07.epair + 18 March 2020 + Incorrect user-controlled pointer + use + + + + FreeBSD-SA-20:08.jail + 18 March 2020 + Kernel memory disclosure with nested + jails + + + + FreeBSD-SA-20:09.ntp + 18 March 2020 + Multiple denial of service + From owner-svn-src-stable-11@freebsd.org Sat Mar 21 18:24:35 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4029C268F4F; Sat, 21 Mar 2020 18:24:35 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48l8Dz0WHmz45WC; Sat, 21 Mar 2020 18:24:34 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C73E918D24; Sat, 21 Mar 2020 18:24:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02LIOXcq015448; Sat, 21 Mar 2020 18:24:33 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02LIOXwu015447; Sat, 21 Mar 2020 18:24:33 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202003211824.02LIOXwu015447@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sat, 21 Mar 2020 18:24:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359196 - stable/11/lib/libc/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/lib/libc/sys X-SVN-Commit-Revision: 359196 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Mar 2020 18:24:35 -0000 Author: asomers Date: Sat Mar 21 18:24:33 2020 New Revision: 359196 URL: https://svnweb.freebsd.org/changeset/base/359196 Log: MFC r352231: getsockopt.2: clarify that SO_TIMESTAMP is not 100% reliable When SO_TIMESTAMP is set, the kernel will attempt to attach a timestamp as ancillary data to each IP datagram that is received on the socket. However, it may fail, for example due to insufficient memory. In that case the packet will still be received but not timestamp will be attached. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D21607 Modified: stable/11/lib/libc/sys/getsockopt.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/getsockopt.2 ============================================================================== --- stable/11/lib/libc/sys/getsockopt.2 Sat Mar 21 16:12:19 2020 (r359195) +++ stable/11/lib/libc/sys/getsockopt.2 Sat Mar 21 18:24:33 2020 (r359196) @@ -28,7 +28,7 @@ .\" @(#)getsockopt.2 8.4 (Berkeley) 5/2/95 .\" $FreeBSD$ .\" -.Dd April 5, 2013 +.Dd September 11, 2019 .Dt GETSOCKOPT 2 .Os .Sh NAME @@ -419,7 +419,8 @@ option is enabled on a .Dv SOCK_DGRAM socket, the .Xr recvmsg 2 -call will return a timestamp corresponding to when the datagram was received. +call may return a timestamp corresponding to when the datagram was received. +However, it may not, for example due to a resource shortage. The .Va msg_control field in the