From owner-svn-src-stable-10@freebsd.org Mon Jul 30 09:16:48 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8362A104FD97; Mon, 30 Jul 2018 09:16:48 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 384FD8F164; Mon, 30 Jul 2018 09:16:48 +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 196BC2254F; Mon, 30 Jul 2018 09:16:48 +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 w6U9GlTU018493; Mon, 30 Jul 2018 09:16:47 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6U9Gldr018492; Mon, 30 Jul 2018 09:16:47 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201807300916.w6U9Gldr018492@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 30 Jul 2018 09:16:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r336884 - stable/10/lib/libusb X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/lib/libusb X-SVN-Commit-Revision: 336884 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 09:16:48 -0000 Author: hselasky Date: Mon Jul 30 09:16:47 2018 New Revision: 336884 URL: https://svnweb.freebsd.org/changeset/base/336884 Log: MFC r335669: Improve the userspace USB string reading function in LibUSB. Some USB devices does not allow a partial descriptor readout. Found by: bz @ Sponsored by: Mellanox Technologies Modified: stable/10/lib/libusb/libusb20.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libusb/libusb20.c ============================================================================== --- stable/10/lib/libusb/libusb20.c Mon Jul 30 09:15:09 2018 (r336883) +++ stable/10/lib/libusb/libusb20.c Mon Jul 30 09:16:47 2018 (r336884) @@ -794,6 +794,7 @@ libusb20_dev_req_string_sync(struct libusb20_device *p { struct LIBUSB20_CONTROL_SETUP_DECODED req; int error; + int flags; /* make sure memory is initialised */ memset(ptr, 0, len); @@ -820,22 +821,24 @@ libusb20_dev_req_string_sync(struct libusb20_device *p error = libusb20_dev_request_sync(pdev, &req, ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK); if (error) { - return (error); + /* try to request full string */ + req.wLength = 255; + flags = 0; + } else { + /* extract length and request full string */ + req.wLength = *(uint8_t *)ptr; + flags = LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK; } - req.wLength = *(uint8_t *)ptr; /* bytes */ if (req.wLength > len) { /* partial string read */ req.wLength = len; } - error = libusb20_dev_request_sync(pdev, &req, - ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK); - - if (error) { + error = libusb20_dev_request_sync(pdev, &req, ptr, NULL, 1000, flags); + if (error) return (error); - } - if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING) { + + if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING) return (LIBUSB20_ERROR_OTHER); - } return (0); /* success */ } From owner-svn-src-stable-10@freebsd.org Mon Jul 30 09:21:20 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8C921050173; Mon, 30 Jul 2018 09:21:20 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6E66E8F898; Mon, 30 Jul 2018 09:21:20 +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 4FA4A22687; Mon, 30 Jul 2018 09:21:20 +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 w6U9LKH6018885; Mon, 30 Jul 2018 09:21:20 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6U9LK50018884; Mon, 30 Jul 2018 09:21:20 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201807300921.w6U9LK50018884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 30 Jul 2018 09:21:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r336887 - stable/10/sys/dev/usb X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/sys/dev/usb X-SVN-Commit-Revision: 336887 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 09:21:20 -0000 Author: hselasky Date: Mon Jul 30 09:21:19 2018 New Revision: 336887 URL: https://svnweb.freebsd.org/changeset/base/336887 Log: MFC r335700: Improve the kernel's USB descriptor reading function. Some USB devices does not allow a partial descriptor readout. Found by: bz@ Sponsored by: Mellanox Technologies Modified: stable/10/sys/dev/usb/usb_request.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/usb_request.c ============================================================================== --- stable/10/sys/dev/usb/usb_request.c Mon Jul 30 09:20:17 2018 (r336886) +++ stable/10/sys/dev/usb/usb_request.c Mon Jul 30 09:21:19 2018 (r336887) @@ -988,7 +988,7 @@ usbd_req_get_desc(struct usb_device *udev, uint8_t retries) { struct usb_device_request req; - uint8_t *buf; + uint8_t *buf = desc; usb_error_t err; DPRINTFN(4, "id=%d, type=%d, index=%d, max_len=%d\n", @@ -1010,6 +1010,32 @@ usbd_req_get_desc(struct usb_device *udev, err = usbd_do_request_flags(udev, mtx, &req, desc, 0, NULL, 500 /* ms */); + if (err != 0 && err != USB_ERR_TIMEOUT && + min_len != max_len) { + /* clear descriptor data */ + memset(desc, 0, max_len); + + /* try to read full descriptor length */ + USETW(req.wLength, max_len); + + err = usbd_do_request_flags(udev, mtx, &req, + desc, USB_SHORT_XFER_OK, NULL, 500 /* ms */); + + if (err == 0) { + /* verify length */ + if (buf[0] > max_len) + buf[0] = max_len; + else if (buf[0] < 2) + err = USB_ERR_INVAL; + + min_len = buf[0]; + + /* enforce descriptor type */ + buf[1] = type; + goto done; + } + } + if (err) { if (!retries) { goto done; @@ -1020,7 +1046,6 @@ usbd_req_get_desc(struct usb_device *udev, continue; } - buf = desc; if (min_len == max_len) { From owner-svn-src-stable-10@freebsd.org Mon Jul 30 09:28:01 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 700331050581; Mon, 30 Jul 2018 09:28:01 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 253048FE41; Mon, 30 Jul 2018 09:28:01 +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 06405226E5; Mon, 30 Jul 2018 09:28:01 +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 w6U9S0oq023947; Mon, 30 Jul 2018 09:28:00 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6U9S00g023946; Mon, 30 Jul 2018 09:28:00 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201807300928.w6U9S00g023946@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 30 Jul 2018 09:28:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r336890 - stable/10/sys/dev/sound/pcm X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/sys/dev/sound/pcm X-SVN-Commit-Revision: 336890 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 09:28:01 -0000 Author: hselasky Date: Mon Jul 30 09:28:00 2018 New Revision: 336890 URL: https://svnweb.freebsd.org/changeset/base/336890 Log: MFC r336632: Update modify counter when setting a mixer control. PR: 229969 Modified: stable/10/sys/dev/sound/pcm/mixer.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sound/pcm/mixer.c ============================================================================== --- stable/10/sys/dev/sound/pcm/mixer.c Mon Jul 30 09:25:56 2018 (r336889) +++ stable/10/sys/dev/sound/pcm/mixer.c Mon Jul 30 09:28:00 2018 (r336890) @@ -323,6 +323,7 @@ mixer_set(struct snd_mixer *m, u_int dev, u_int lev) MIXER_SET_LOCK(m, dropmtx); m->level[dev] = l | (r << 8); + m->modify_counter++; return 0; } From owner-svn-src-stable-10@freebsd.org Mon Jul 30 12:17:12 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 268C11055483; Mon, 30 Jul 2018 12:17:12 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7A3D196FFA; Mon, 30 Jul 2018 12:17:11 +0000 (UTC) (envelope-from rmacklem@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 5B63724310; Mon, 30 Jul 2018 12:17:11 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6UCHBer011763; Mon, 30 Jul 2018 12:17:11 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6UCHBTP011762; Mon, 30 Jul 2018 12:17:11 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807301217.w6UCHBTP011762@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Mon, 30 Jul 2018 12:17:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r336899 - in stable/10/sys/fs: nfs nfsclient X-SVN-Group: stable-10 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in stable/10/sys/fs: nfs nfsclient X-SVN-Commit-Revision: 336899 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 12:17:12 -0000 Author: rmacklem Date: Mon Jul 30 12:17:10 2018 New Revision: 336899 URL: https://svnweb.freebsd.org/changeset/base/336899 Log: MFC: r334966 Add a couple of safety belt checks to the NFSv4.1 client related to sessions. There were a couple of cases in newnfs_request() that it assumed that it was an NFSv4.1 mount with a session. This should always be the case when a Sequence operation is in the reply or the server replies NFSERR_BADSESSION. However, if a server was broken and sent an erroneous reply, these safety belt checks should avoid trouble. The one check required a small tweak to nfsmnt_mdssession() so that it returns NULL when there is no session instead of the offset of the field in the structure (0x8 for i386). This patch should have no effect on normal operation of the client. Found by inspection during pNFS server development. Modified: stable/10/sys/fs/nfs/nfs_commonkrpc.c stable/10/sys/fs/nfsclient/nfsmount.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfs/nfs_commonkrpc.c ============================================================================== --- stable/10/sys/fs/nfs/nfs_commonkrpc.c Mon Jul 30 12:10:23 2018 (r336898) +++ stable/10/sys/fs/nfs/nfs_commonkrpc.c Mon Jul 30 12:17:10 2018 (r336899) @@ -850,9 +850,9 @@ tryagain: if ((nmp != NULL && i == NFSV4OP_SEQUENCE && j != 0) || (clp != NULL && i == NFSV4OP_CBSEQUENCE && j != 0)) NFSCL_DEBUG(1, "failed seq=%d\n", j); - if ((nmp != NULL && i == NFSV4OP_SEQUENCE && j == 0) || - (clp != NULL && i == NFSV4OP_CBSEQUENCE && j == 0) - ) { + if (((nmp != NULL && i == NFSV4OP_SEQUENCE && j == 0) || + (clp != NULL && i == NFSV4OP_CBSEQUENCE && + j == 0)) && sep != NULL) { if (i == NFSV4OP_SEQUENCE) NFSM_DISSECT(tl, uint32_t *, NFSX_V4SESSIONID + @@ -894,7 +894,8 @@ tryagain: } if (nd->nd_repstat != 0) { if (nd->nd_repstat == NFSERR_BADSESSION && - nmp != NULL && dssep == NULL) { + nmp != NULL && dssep == NULL && + (nd->nd_flag & ND_NFSV41) != 0) { /* * If this is a client side MDS RPC, mark * the MDS session defunct and initiate Modified: stable/10/sys/fs/nfsclient/nfsmount.h ============================================================================== --- stable/10/sys/fs/nfsclient/nfsmount.h Mon Jul 30 12:10:23 2018 (r336898) +++ stable/10/sys/fs/nfsclient/nfsmount.h Mon Jul 30 12:17:10 2018 (r336899) @@ -122,8 +122,10 @@ nfsmnt_mdssession(struct nfsmount *nmp) { struct nfsclsession *tsep; + tsep = NULL; mtx_lock(&nmp->nm_mtx); - tsep = NFSMNT_MDSSESSION(nmp); + if (TAILQ_FIRST(&nmp->nm_sess) != NULL) + tsep = NFSMNT_MDSSESSION(nmp); mtx_unlock(&nmp->nm_mtx); return (tsep); } From owner-svn-src-stable-10@freebsd.org Mon Jul 30 19:29:32 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A5732105F034; Mon, 30 Jul 2018 19:29:32 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 570CB80C72; Mon, 30 Jul 2018 19:29:32 +0000 (UTC) (envelope-from rmacklem@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 32D55C24; Mon, 30 Jul 2018 19:29:32 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6UJTWYs033741; Mon, 30 Jul 2018 19:29:32 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6UJTW8M033740; Mon, 30 Jul 2018 19:29:32 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807301929.w6UJTW8M033740@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Mon, 30 Jul 2018 19:29:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r336928 - stable/10/sys/rpc X-SVN-Group: stable-10 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/10/sys/rpc X-SVN-Commit-Revision: 336928 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 19:29:32 -0000 Author: rmacklem Date: Mon Jul 30 19:29:31 2018 New Revision: 336928 URL: https://svnweb.freebsd.org/changeset/base/336928 Log: MFC: r335866 Fix the server side krpc so that the kernel nfsd threads terminate. Occationally the kernel nfsd threads would not terminate when a SIGKILL was posted for the kernel process (called nfsd (slave)). When this occurred, the thread associated with the process (called "ismaster") had returned from svc_run_internal() and was sleeping waiting for the other threads to terminate. The other threads (created by kthread_start()) were still in svc_run_internal() handling NFS RPCs. The only way this could occur is for the "ismaster" thread to return from svc_run_internal() without having called svc_exit(). There was only one place in the code where this could happen and this patch stops that from happening. Since the problem is intermittent, I cannot be sure if this has fixed the problem, but I have not seen an occurrence of the problem with this patch applied. Modified: stable/10/sys/rpc/svc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/rpc/svc.c ============================================================================== --- stable/10/sys/rpc/svc.c Mon Jul 30 19:23:52 2018 (r336927) +++ stable/10/sys/rpc/svc.c Mon Jul 30 19:29:31 2018 (r336928) @@ -1183,7 +1183,8 @@ svc_run_internal(SVCGROUP *grp, bool_t ismaster) /* * Enforce maxthreads count. */ - if (grp->sg_threadcount > grp->sg_maxthreads) + if (!ismaster && grp->sg_threadcount > + grp->sg_maxthreads) break; /* From owner-svn-src-stable-10@freebsd.org Tue Jul 31 00:37:27 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D0BC10663F5; Tue, 31 Jul 2018 00:37:27 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 40F268F2A3; Tue, 31 Jul 2018 00:37:27 +0000 (UTC) (envelope-from markj@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 0350243DD; Tue, 31 Jul 2018 00:37:27 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6V0bQsK099925; Tue, 31 Jul 2018 00:37:26 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6V0bPlm099916; Tue, 31 Jul 2018 00:37:25 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201807310037.w6V0bPlm099916@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 31 Jul 2018 00:37:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r336953 - in stable: 10/usr.bin/mail 11/usr.bin/mail X-SVN-Group: stable-10 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable: 10/usr.bin/mail 11/usr.bin/mail X-SVN-Commit-Revision: 336953 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jul 2018 00:37:28 -0000 Author: markj Date: Tue Jul 31 00:37:25 2018 New Revision: 336953 URL: https://svnweb.freebsd.org/changeset/base/336953 Log: Revert r335693, r335694, r335695 by eadler. They cause mail(1) to crash in certain scenarios. PR: 230196 Reported by: Pete French Modified: stable/10/usr.bin/mail/cmd1.c stable/10/usr.bin/mail/cmd2.c stable/10/usr.bin/mail/cmd3.c stable/10/usr.bin/mail/edit.c stable/10/usr.bin/mail/extern.h stable/10/usr.bin/mail/fio.c stable/10/usr.bin/mail/getname.c stable/10/usr.bin/mail/popen.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/usr.bin/mail/cmd1.c stable/11/usr.bin/mail/cmd2.c stable/11/usr.bin/mail/cmd3.c stable/11/usr.bin/mail/edit.c stable/11/usr.bin/mail/extern.h stable/11/usr.bin/mail/fio.c stable/11/usr.bin/mail/getname.c stable/11/usr.bin/mail/popen.c Directory Properties: stable/11/ (props changed) Modified: stable/10/usr.bin/mail/cmd1.c ============================================================================== --- stable/10/usr.bin/mail/cmd1.c Tue Jul 31 00:34:39 2018 (r336952) +++ stable/10/usr.bin/mail/cmd1.c Tue Jul 31 00:37:25 2018 (r336953) @@ -439,7 +439,7 @@ folders(void) } if ((cmd = value("LISTER")) == NULL) cmd = "ls"; - (void)run_command(cmd, 0, -1, -1, dirname, NULL); + (void)run_command(cmd, 0, -1, -1, dirname, NULL, NULL); return (0); } Modified: stable/10/usr.bin/mail/cmd2.c ============================================================================== --- stable/10/usr.bin/mail/cmd2.c Tue Jul 31 00:34:39 2018 (r336952) +++ stable/10/usr.bin/mail/cmd2.c Tue Jul 31 00:37:25 2018 (r336953) @@ -130,9 +130,8 @@ hitit: * so we can discard when the user quits. */ int -save(void *v) +save(char str[]) { - char *str = v; return (save1(str, 1, "save", saveignore)); } @@ -141,9 +140,8 @@ save(void *v) * Copy a message to a file without affected its saved-ness */ int -copycmd(void *v) +copycmd(char str[]) { - char *str = v; return (save1(str, 0, "copy", saveignore)); } Modified: stable/10/usr.bin/mail/cmd3.c ============================================================================== --- stable/10/usr.bin/mail/cmd3.c Tue Jul 31 00:34:39 2018 (r336952) +++ stable/10/usr.bin/mail/cmd3.c Tue Jul 31 00:37:25 2018 (r336953) @@ -79,7 +79,7 @@ dosh(char *str __unused) if ((sh = value("SHELL")) == NULL) sh = _PATH_CSHELL; - (void)run_command(sh, 0, -1, -1, NULL); + (void)run_command(sh, 0, -1, -1, NULL, NULL, NULL); (void)signal(SIGINT, sigint); printf("\n"); return (0); @@ -102,7 +102,7 @@ bangexp(char *str, size_t strsize) n = sizeof(bangbuf); while (*cp != '\0') { if (*cp == '!') { - if (n < (int)strlen(lastbang)) { + if (n < strlen(lastbang)) { overf: printf("Command buffer overflow\n"); return (-1); Modified: stable/10/usr.bin/mail/edit.c ============================================================================== --- stable/10/usr.bin/mail/edit.c Tue Jul 31 00:34:39 2018 (r336952) +++ stable/10/usr.bin/mail/edit.c Tue Jul 31 00:37:25 2018 (r336953) @@ -180,7 +180,7 @@ run_editor(FILE *fp, off_t size, int type, int readonl nf = NULL; if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NULL) edit = type == 'e' ? _PATH_EX : _PATH_VI; - if (run_command(edit, 0, -1, -1, tempname, NULL) < 0) { + if (run_command(edit, 0, -1, -1, tempname, NULL, NULL) < 0) { (void)rm(tempname); goto out; } Modified: stable/10/usr.bin/mail/extern.h ============================================================================== --- stable/10/usr.bin/mail/extern.h Tue Jul 31 00:34:39 2018 (r336952) +++ stable/10/usr.bin/mail/extern.h Tue Jul 31 00:37:25 2018 (r336953) @@ -49,7 +49,7 @@ char *copyin(char *, char **); char *detract(struct name *, int); char *expand(char *); char *getdeadletter(void); -char *getname(uid_t); +char *getname(int); char *hfield(const char *, struct message *); FILE *infix(struct header *, FILE *); char *ishfield(char [], char *, const char *); @@ -95,7 +95,7 @@ void collhup(int); void collint(int); void collstop(int); void commands(void); -int copycmd(void *v); +int copycmd(char []); int core(void); int count(struct name *); int delete(int []); @@ -130,7 +130,7 @@ int getfold(char *, int); int gethfield(FILE *, char [], int, char **); int getmsglist(char *, int *, int); int getrawlist(char [], char **, int); -uid_t getuserid(char []); +int getuserid(char []); int grabh(struct header *, int); int group(char **); void hangup(int); @@ -198,8 +198,8 @@ int respond(int *); int retfield(char *[]); int rexit(int); int rm(char *); -int run_command(char *, sigset_t *, int, int, ...); -int save(void *v); +int run_command(char *, sigset_t *, int, int, char *, char *, char *); +int save(char []); int save1(char [], int, const char *, struct ignoretab *); void savedeadletter(FILE *); int saveigfield(char *[]); @@ -223,7 +223,7 @@ void sort(char **); int source(char **); void spreserve(void); void sreset(void); -int start_command(char *, sigset_t *, int, int, ...); +int start_command(char *, sigset_t *, int, int, char *, char *, char *); void statusput(struct message *, FILE *, char *); void stop(int); int stouch(int []); Modified: stable/10/usr.bin/mail/fio.c ============================================================================== --- stable/10/usr.bin/mail/fio.c Tue Jul 31 00:34:39 2018 (r336952) +++ stable/10/usr.bin/mail/fio.c Tue Jul 31 00:37:25 2018 (r336953) @@ -235,7 +235,7 @@ makemessage(FILE *f, int omsgCount) size -= (omsgCount + 1) * sizeof(struct message); (void)fflush(f); (void)lseek(fileno(f), (off_t)sizeof(*message), 0); - if (read(fileno(f), (void *)&message[omsgCount], size) != size) + if (read(fileno(f), (char *)&message[omsgCount], size) != size) errx(1, "Message temporary file corrupted"); message[msgCount].m_size = 0; message[msgCount].m_lines = 0; Modified: stable/10/usr.bin/mail/getname.c ============================================================================== --- stable/10/usr.bin/mail/getname.c Tue Jul 31 00:34:39 2018 (r336952) +++ stable/10/usr.bin/mail/getname.c Tue Jul 31 00:37:25 2018 (r336953) @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); * Search the passwd file for a uid. Return name on success, NULL on failure. */ char * -getname(uid_t uid) +getname(int uid) { struct passwd *pw; @@ -58,7 +58,7 @@ getname(uid_t uid) * Convert the passed name to a user id and return it. Return -1 * on error. */ -uid_t +int getuserid(char name[]) { struct passwd *pw; Modified: stable/10/usr.bin/mail/popen.c ============================================================================== --- stable/10/usr.bin/mail/popen.c Tue Jul 31 00:34:39 2018 (r336952) +++ stable/10/usr.bin/mail/popen.c Tue Jul 31 00:37:25 2018 (r336953) @@ -38,8 +38,6 @@ __FBSDID("$FreeBSD$"); #include "rcv.h" #include #include -#include -#include #include "extern.h" #define READ 0 @@ -48,23 +46,22 @@ __FBSDID("$FreeBSD$"); struct fp { FILE *fp; int pipe; - pid_t pid; + int pid; struct fp *link; }; static struct fp *fp_head; struct child { - pid_t pid; + int pid; char done; char free; int status; struct child *link; }; -static struct child *child, *child_freelist = NULL; - +static struct child *child; +static struct child *findchild(int); static void delchild(struct child *); -static pid_t file_pid(FILE *); -static pid_t start_commandv(char *, sigset_t *, int, int, va_list); +static int file_pid(FILE *); FILE * Fopen(const char *path, const char *mode) @@ -93,7 +90,6 @@ Fdopen(int fd, const char *mode) int Fclose(FILE *fp) { - unregister_file(fp); return (fclose(fp)); } @@ -103,7 +99,7 @@ Popen(char *cmd, const char *mode) { int p[2]; int myside, hisside, fd0, fd1; - pid_t pid; + int pid; sigset_t nset; FILE *fp; @@ -113,15 +109,15 @@ Popen(char *cmd, const char *mode) (void)fcntl(p[WRITE], F_SETFD, 1); if (*mode == 'r') { myside = p[READ]; - hisside = fd0 = fd1 = p[WRITE]; + fd0 = -1; + hisside = fd1 = p[WRITE]; } else { myside = p[WRITE]; hisside = fd0 = p[READ]; fd1 = -1; } (void)sigemptyset(&nset); - pid = start_command(value("SHELL"), &nset, fd0, fd1, "-c", cmd, NULL); - if (pid < 0) { + if ((pid = start_command(cmd, &nset, fd0, fd1, NULL, NULL, NULL)) < 0) { (void)close(p[READ]); (void)close(p[WRITE]); return (NULL); @@ -162,7 +158,7 @@ close_all_files(void) } void -register_file(FILE *fp, int pipe, pid_t pid) +register_file(FILE *fp, int pipe, int pid) { struct fp *fpp; @@ -190,7 +186,7 @@ unregister_file(FILE *fp) /*NOTREACHED*/ } -pid_t +int file_pid(FILE *fp) { struct fp *p; @@ -204,17 +200,30 @@ file_pid(FILE *fp) /* * Run a command without a shell, with optional arguments and splicing - * of stdin (-1 means none) and stdout. The command name can be a sequence - * of words. + * of stdin and stdout. The command name can be a sequence of words. * Signals must be handled by the caller. - * "nset" contains the signals to ignore in the new process. - * SIGINT is enabled unless it's in "nset". + * "Mask" contains the signals to ignore in the new process. + * SIGINT is enabled unless it's in the mask. */ -static pid_t -start_commandv(char *cmd, sigset_t *nset, int infd, int outfd, va_list args) +/*VARARGS4*/ +int +run_command(char *cmd, sigset_t *mask, int infd, int outfd, char *a0, + char *a1, char *a2) { - pid_t pid; + int pid; + if ((pid = start_command(cmd, mask, infd, outfd, a0, a1, a2)) < 0) + return (-1); + return (wait_command(pid)); +} + +/*VARARGS4*/ +int +start_command(char *cmd, sigset_t *mask, int infd, int outfd, char *a0, + char *a1, char *a2) +{ + int pid; + if ((pid = fork()) < 0) { warn("fork"); return (-1); @@ -223,10 +232,11 @@ start_commandv(char *cmd, sigset_t *nset, int infd, in char *argv[100]; int i = getrawlist(cmd, argv, sizeof(argv) / sizeof(*argv)); - while ((argv[i++] = va_arg(args, char *))) - ; - argv[i] = NULL; - prepare_child(nset, infd, outfd); + if ((argv[i++] = a0) != NULL && + (argv[i++] = a1) != NULL && + (argv[i++] = a2) != NULL) + argv[i] = NULL; + prepare_child(mask, infd, outfd); execvp(argv[0], argv); warn("%s", argv[0]); _exit(1); @@ -234,32 +244,6 @@ start_commandv(char *cmd, sigset_t *nset, int infd, in return (pid); } -int -run_command(char *cmd, sigset_t *nset, int infd, int outfd, ...) -{ - pid_t pid; - va_list args; - - va_start(args, outfd); - pid = start_commandv(cmd, nset, infd, outfd, args); - va_end(args); - if (pid < 0) - return -1; - return wait_command(pid); -} - -int -start_command(char *cmd, sigset_t *nset, int infd, int outfd, ...) -{ - va_list args; - int r; - - va_start(args, outfd); - r = start_commandv(cmd, nset, infd, outfd, args); - va_end(args); - return r; -} - void prepare_child(sigset_t *nset, int infd, int outfd) { @@ -284,7 +268,7 @@ prepare_child(sigset_t *nset, int infd, int outfd) } int -wait_command(pid_t pid) +wait_command(int pid) { if (wait_child(pid) < 0) { @@ -295,7 +279,7 @@ wait_command(pid_t pid) } static struct child * -findchild(pid_t pid, int dont_alloc) +findchild(int pid) { struct child **cpp; @@ -303,16 +287,9 @@ findchild(pid_t pid, int dont_alloc) cpp = &(*cpp)->link) ; if (*cpp == NULL) { - if (dont_alloc) - return(NULL); - if (child_freelist) { - *cpp = child_freelist; - child_freelist = (*cpp)->link; - } else { - *cpp = malloc(sizeof(struct child)); - if (*cpp == NULL) - err(1, "malloc"); - } + *cpp = malloc(sizeof(struct child)); + if (*cpp == NULL) + err(1, "Out of memory"); (*cpp)->pid = pid; (*cpp)->done = (*cpp)->free = 0; (*cpp)->link = NULL; @@ -328,22 +305,19 @@ delchild(struct child *cp) for (cpp = &child; *cpp != cp; cpp = &(*cpp)->link) ; *cpp = cp->link; - cp->link = child_freelist; - child_freelist = cp; + (void)free(cp); } /*ARGSUSED*/ void sigchild(int signo __unused) { - pid_t pid; + int pid; int status; struct child *cp; - int save_errno; - save_errno = errno; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { - cp = findchild(pid, 1); + cp = findchild(pid); if (cp->free) delchild(cp); else { @@ -351,7 +325,6 @@ sigchild(int signo __unused) cp->status = status; } } - errno = save_errno; } int wait_status; @@ -360,51 +333,41 @@ int wait_status; * Wait for a specific child to die. */ int -wait_child(pid_t pid) +wait_child(int pid) { - struct child *cp; sigset_t nset, oset; - pid_t rv = 0; + struct child *cp; (void)sigemptyset(&nset); (void)sigaddset(&nset, SIGCHLD); - (void)sigprocmask(SIG_BLOCK, &nset, &oset); - /* - * If we have not already waited on the pid (via sigchild) - * wait on it now. Otherwise, use the wait status stashed - * by sigchild. - */ - cp = findchild(pid, 1); - if (cp == NULL || !cp->done) - rv = waitpid(pid, &wait_status, 0); - else - wait_status = cp->status; - if (cp != NULL) - delchild(cp); + (void)sigprocmask(SIG_BLOCK, &nset, &oset); + + cp = findchild(pid); + + while (!cp->done) + (void)sigsuspend(&oset); + wait_status = cp->status; + delchild(cp); (void)sigprocmask(SIG_SETMASK, &oset, NULL); - if (rv == -1 || (WIFEXITED(wait_status) && WEXITSTATUS(wait_status))) - return -1; - else - return 0; + return ((WIFEXITED(wait_status) && WEXITSTATUS(wait_status)) ? -1 : 0); } /* * Mark a child as don't care. */ void -free_child(pid_t pid) +free_child(int pid) { - struct child *cp; sigset_t nset, oset; + struct child *cp = findchild(pid); (void)sigemptyset(&nset); (void)sigaddset(&nset, SIGCHLD); - (void)sigprocmask(SIG_BLOCK, &nset, &oset); - if ((cp = findchild(pid, 0)) != NULL) { - if (cp->done) - delchild(cp); - else - cp->free = 1; - } + (void)sigprocmask(SIG_BLOCK, &nset, &oset); + + if (cp->done) + delchild(cp); + else + cp->free = 1; (void)sigprocmask(SIG_SETMASK, &oset, NULL); } From owner-svn-src-stable-10@freebsd.org Tue Jul 31 05:47:59 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B45DC104E830 for ; Tue, 31 Jul 2018 05:47:59 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-yw0-x230.google.com (mail-yw0-x230.google.com [IPv6:2607:f8b0:4002:c05::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 50F827A7F0 for ; Tue, 31 Jul 2018 05:47:59 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: by mail-yw0-x230.google.com with SMTP id q129-v6so5321892ywg.8 for ; Mon, 30 Jul 2018 22:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LqBDm/Qi3WGCXfWk/yXj+CRNPQJyzI5X66Um0p0OwwE=; b=hhoP6cZ2BywzKluxNNW1daoSVevKKoUY/ZlBjWRlf3YQHxO6L4fVCyMIULK9EJvR+h 2o9hRcwpqNfw+U1H8o3Yc87PjVrdj6Kdzg+EnCqXfJG6gCGD8lq3XjxjeLFBw6P5k9ed 6kQ2YCGMGfv4Y9JHQfKeDj3FYK4lTd+W1VIag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LqBDm/Qi3WGCXfWk/yXj+CRNPQJyzI5X66Um0p0OwwE=; b=TJ+WSaelEjm3B6TEyxHiam0DpZqD+XdAC5Kl11lVL1BXmqHk27VUKel5gm0rWafsV9 A3oiFRkI3WrFIT1BJ+NuAwSPhdRQgUwFus2aQsIrDTFnODot3pBUFIc4k8ejSrJzyws0 7c/I8/8kJKiZ+9MU7tRo7Qdj/fj6gXIuqAFGiJCy4HCfeZ4ZbwXxxDxJ/qo6mUdA35f7 uyOdj981p9A6HAlj1XTcDfunASWLooC3sN88pit/f27Zg88s4QZ2YV77o3ovJIxIWAiy AKnRhWtiCrsvihGZP0T0DG8eYZHU9+ZdbRHWb0ef5g0C118b/QB/nuu4OlQnmq2zPpgA rnQQ== X-Gm-Message-State: AOUpUlEHrH6kbaGET4V1H4P98vUZ3kf1yr6eW5GJB/UQk41dDGlrG1i+ w69d8osLIs8ltTy+NlTtRgfLqPYlgPDWAUESU9FzL+A66vc= X-Google-Smtp-Source: AAOMgpe2em9BOKIIdKjlP9XgwJs3+iZj1+2yXjW1BlDaZKWfB6qbCnuhl/SYvbk2AVjvkEkVG+07uCoidPiijaU90YI= X-Received: by 2002:a81:af06:: with SMTP id n6-v6mr10266126ywh.113.1533016078553; Mon, 30 Jul 2018 22:47:58 -0700 (PDT) MIME-Version: 1.0 References: <201807310037.w6V0bPlm099916@repo.freebsd.org> In-Reply-To: <201807310037.w6V0bPlm099916@repo.freebsd.org> From: Eitan Adler Date: Mon, 30 Jul 2018 22:47:30 -0700 Message-ID: Subject: Re: svn commit: r336953 - in stable: 10/usr.bin/mail 11/usr.bin/mail To: Mark Johnston Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jul 2018 05:47:59 -0000 On Mon, 30 Jul 2018 at 17:37, Mark Johnston wrote: > > Author: markj > Date: Tue Jul 31 00:37:25 2018 > New Revision: 336953 > URL: https://svnweb.freebsd.org/changeset/base/336953 > > Log: > Revert r335693, r335694, r335695 by eadler. > > They cause mail(1) to crash in certain scenarios. Thanks! I was going to do this myself shortly. -- Eitan Adler From owner-svn-src-stable-10@freebsd.org Tue Jul 31 21:02:46 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED3921064E32; Tue, 31 Jul 2018 21:02:45 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 95B5F7CCE8; Tue, 31 Jul 2018 21:02:45 +0000 (UTC) (envelope-from rmacklem@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 72C6C18F8E; Tue, 31 Jul 2018 21:02:45 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6VL2jUT038023; Tue, 31 Jul 2018 21:02:45 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6VL2jDa038022; Tue, 31 Jul 2018 21:02:45 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807312102.w6VL2jDa038022@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Tue, 31 Jul 2018 21:02:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337006 - stable/10/sys/fs/nfsserver X-SVN-Group: stable-10 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/10/sys/fs/nfsserver X-SVN-Commit-Revision: 337006 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jul 2018 21:02:46 -0000 Author: rmacklem Date: Tue Jul 31 21:02:45 2018 New Revision: 337006 URL: https://svnweb.freebsd.org/changeset/base/337006 Log: MFC: r336215 Ignore the cookie verifier for NFSv4.1 when the cookie is 0. RFC5661 states that the cookie verifier should be 0 when the cookie is 0. However, the wording is somewhat unclear and a recent discussion on the nfsv4@ietf.org mailing list indicated that the NFSv4 server should ignore the cookie verifier's value when the dirctory offset cookie is 0. This patch deletes the check for this that would return NFSERR_BAD_COOKIE when the verifier was not 0. This was found during testing of the ESXi client against the NFSv4.1 server. Modified: stable/10/sys/fs/nfsserver/nfs_nfsdport.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- stable/10/sys/fs/nfsserver/nfs_nfsdport.c Tue Jul 31 20:57:31 2018 (r337005) +++ stable/10/sys/fs/nfsserver/nfs_nfsdport.c Tue Jul 31 21:02:45 2018 (r337006) @@ -1871,6 +1871,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdg } fullsiz = siz; nd->nd_repstat = getret = nfsvno_getattr(vp, &at, nd->nd_cred, p, 1); +#if 0 if (!nd->nd_repstat) { if (off && verf != at.na_filerev) { /* @@ -1879,17 +1880,14 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdg * removed/added unless that offset cookies returned to * the client are no longer valid. */ -#if 0 if (nd->nd_flag & ND_NFSV4) { nd->nd_repstat = NFSERR_NOTSAME; } else { nd->nd_repstat = NFSERR_BAD_COOKIE; } -#endif - } else if ((nd->nd_flag & ND_NFSV4) && off == 0 && verf != 0) { - nd->nd_repstat = NFSERR_BAD_COOKIE; } } +#endif if (!nd->nd_repstat && vp->v_type != VDIR) nd->nd_repstat = NFSERR_NOTDIR; if (!nd->nd_repstat && cnt == 0) From owner-svn-src-stable-10@freebsd.org Wed Aug 1 10:35:50 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A19FA1050EEE; Wed, 1 Aug 2018 10:35:50 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 573638CD81; Wed, 1 Aug 2018 10:35:50 +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 3855321525; Wed, 1 Aug 2018 10:35:50 +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 w71AZoYP069471; Wed, 1 Aug 2018 10:35:50 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w71AZotf069470; Wed, 1 Aug 2018 10:35:50 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201808011035.w71AZotf069470@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 1 Aug 2018 10:35:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337035 - stable/10/sys/kern X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/sys/kern X-SVN-Commit-Revision: 337035 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2018 10:35:50 -0000 Author: hselasky Date: Wed Aug 1 10:35:49 2018 New Revision: 337035 URL: https://svnweb.freebsd.org/changeset/base/337035 Log: MFC r330344: Correct the return code from pause() during cold startup from zero to EWOULDBLOCK. This also matches the description in pause(9). Discussed with: kib@ Sponsored by: Mellanox Technologies Modified: stable/10/sys/kern/kern_synch.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_synch.c ============================================================================== --- stable/10/sys/kern/kern_synch.c Wed Aug 1 10:34:53 2018 (r337034) +++ stable/10/sys/kern/kern_synch.c Wed Aug 1 10:35:49 2018 (r337035) @@ -362,7 +362,7 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_ sbt = (sbt + SBT_1US - 1) / SBT_1US; if (sbt > 0) DELAY(sbt); - return (0); + return (EWOULDBLOCK); } return (_sleep(&pause_wchan[curcpu], NULL, (flags & C_CATCH) ? PCATCH : 0, wmesg, sbt, pr, flags)); From owner-svn-src-stable-10@freebsd.org Wed Aug 1 10:34:55 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63D0A1050DE1; Wed, 1 Aug 2018 10:34:55 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0B3FA8CC8F; Wed, 1 Aug 2018 10:34:55 +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 C295D21524; Wed, 1 Aug 2018 10:34:54 +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 w71AYssi069348; Wed, 1 Aug 2018 10:34:54 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w71AYrVX069341; Wed, 1 Aug 2018 10:34:53 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201808011034.w71AYrVX069341@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 1 Aug 2018 10:34:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337034 - in stable/10: share/man/man9 sys/kern sys/sys X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/10: share/man/man9 sys/kern sys/sys X-SVN-Commit-Revision: 337034 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2018 10:34:55 -0000 Author: hselasky Date: Wed Aug 1 10:34:53 2018 New Revision: 337034 URL: https://svnweb.freebsd.org/changeset/base/337034 Log: MFC r330349 and r330362: Allow pause_sbt() to catch signals during sleep by passing C_CATCH flag. Define pause_sig() function macro helper similarly to other kernel functions which catch signals. Update outdated function description. Document pause_sig(9) and update prototypes for existing pause(9) and pause_sbt(9) functions. Discussed with: kib@ Suggested by: cem@ Sponsored by: Mellanox Technologies Modified: stable/10/share/man/man9/Makefile stable/10/share/man/man9/sleep.9 stable/10/sys/kern/kern_synch.c stable/10/sys/sys/callout.h stable/10/sys/sys/systm.h Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man9/Makefile ============================================================================== --- stable/10/share/man/man9/Makefile Wed Aug 1 08:24:34 2018 (r337033) +++ stable/10/share/man/man9/Makefile Wed Aug 1 10:34:53 2018 (r337034) @@ -1249,6 +1249,7 @@ MLINKS+=sleep.9 msleep.9 \ sleep.9 msleep_spin.9 \ sleep.9 msleep_spin_sbt.9 \ sleep.9 pause.9 \ + sleep.9 pause_sig.9 \ sleep.9 pause_sbt.9 \ sleep.9 tsleep.9 \ sleep.9 tsleep_sbt.9 \ Modified: stable/10/share/man/man9/sleep.9 ============================================================================== --- stable/10/share/man/man9/sleep.9 Wed Aug 1 08:24:34 2018 (r337033) +++ stable/10/share/man/man9/sleep.9 Wed Aug 1 10:34:53 2018 (r337034) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 19, 2013 +.Dd August 1, 2018 .Dt SLEEP 9 .Os .Sh NAME @@ -34,6 +34,7 @@ .Nm msleep_spin , .Nm msleep_spin_sbt , .Nm pause , +.Nm pause_sig , .Nm pause_sbt , .Nm tsleep , .Nm tsleep_sbt , @@ -53,9 +54,11 @@ .Ft int .Fn msleep_spin_sbt "void *chan" "struct mtx *mtx" "const char *wmesg" \ "sbintime_t sbt" "sbintime_t pr" "int flags" -.Ft void +.Ft int .Fn pause "const char *wmesg" "int timo" -.Ft void +.Ft int +.Fn pause_sig "const char *wmesg" "int timo" +.Ft int .Fn pause_sbt "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" \ "int flags" .Ft int @@ -73,6 +76,8 @@ The functions .Fn msleep , .Fn msleep_spin , .Fn pause , +.Fn pause_sig , +.Fn pause_sbt , .Fn wakeup , and .Fn wakeup_one @@ -82,8 +87,10 @@ external event, it is put to sleep by .Fn tsleep , .Fn msleep , .Fn msleep_spin , +.Fn pause , +.Fn pause_sig , or -.Fn pause . +.Fn pause_sbt . Threads may also wait using one of the locking primitive sleep routines .Xr mtx_sleep 9 , .Xr rw_sleep 9 , @@ -261,6 +268,11 @@ The thread can not be awakened early by signals or cal .Fn wakeup or .Fn wakeup_one . +The +.Fn pause_sig +function is a variant of +.Fn pause +which can be awakened early by signals. .Pp The .Fn wakeup_one @@ -380,6 +392,10 @@ The .Fn pause function appeared in .Fx 7.0 . +The +.Fn pause_sig +function appeared in +.Fx 12.0 . .Sh AUTHORS .An -nosplit This manual page was written by Modified: stable/10/sys/kern/kern_synch.c ============================================================================== --- stable/10/sys/kern/kern_synch.c Wed Aug 1 08:24:34 2018 (r337033) +++ stable/10/sys/kern/kern_synch.c Wed Aug 1 10:34:53 2018 (r337034) @@ -334,16 +334,16 @@ msleep_spin_sbt(void *ident, struct mtx *mtx, const ch } /* - * pause() delays the calling thread by the given number of system ticks. - * During cold bootup, pause() uses the DELAY() function instead of - * the tsleep() function to do the waiting. The "timo" argument must be - * greater than or equal to zero. A "timo" value of zero is equivalent - * to a "timo" value of one. + * pause_sbt() delays the calling thread by the given signed binary + * time. During cold bootup, pause_sbt() uses the DELAY() function + * instead of the _sleep() function to do the waiting. The "sbt" + * argument must be greater than or equal to zero. A "sbt" value of + * zero is equivalent to a "sbt" value of one tick. */ int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags) { - KASSERT(sbt >= 0, ("pause: timeout must be >= 0")); + KASSERT(sbt >= 0, ("pause_sbt: timeout must be >= 0")); /* silently convert invalid timeouts */ if (sbt == 0) @@ -364,7 +364,8 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_ DELAY(sbt); return (0); } - return (_sleep(&pause_wchan[curcpu], NULL, 0, wmesg, sbt, pr, flags)); + return (_sleep(&pause_wchan[curcpu], NULL, + (flags & C_CATCH) ? PCATCH : 0, wmesg, sbt, pr, flags)); } /* Modified: stable/10/sys/sys/callout.h ============================================================================== --- stable/10/sys/sys/callout.h Wed Aug 1 08:24:34 2018 (r337033) +++ stable/10/sys/sys/callout.h Wed Aug 1 10:34:53 2018 (r337034) @@ -58,6 +58,7 @@ #define C_HARDCLOCK 0x0100 /* align to hardclock() calls */ #define C_ABSOLUTE 0x0200 /* event time is absolute. */ #define C_PRECALC 0x0400 /* event time is pre-calculated. */ +#define C_CATCH 0x0800 /* catch signals, used by pause_sbt(9) */ struct callout_handle { struct callout *callout; Modified: stable/10/sys/sys/systm.h ============================================================================== --- stable/10/sys/sys/systm.h Wed Aug 1 08:24:34 2018 (r337033) +++ stable/10/sys/sys/systm.h Wed Aug 1 10:34:53 2018 (r337034) @@ -386,6 +386,8 @@ int pause_sbt(const char *wmesg, sbintime_t sbt, sbint int flags); #define pause(wmesg, timo) \ pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK) +#define pause_sig(wmesg, timo) \ + pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK | C_CATCH) #define tsleep(chan, pri, wmesg, timo) \ _sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \ 0, C_HARDCLOCK) From owner-svn-src-stable-10@freebsd.org Wed Aug 1 11:08:53 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1D4981053EF3; Wed, 1 Aug 2018 11:08:53 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C63368DEBE; Wed, 1 Aug 2018 11:08:52 +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 A7439219F4; Wed, 1 Aug 2018 11:08:52 +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 w71B8q6U085482; Wed, 1 Aug 2018 11:08:52 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w71B8qPB085480; Wed, 1 Aug 2018 11:08:52 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201808011108.w71B8qPB085480@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 1 Aug 2018 11:08:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337036 - in stable/10/sys: arm/arm sys X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/10/sys: arm/arm sys X-SVN-Commit-Revision: 337036 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2018 11:08:53 -0000 Author: hselasky Date: Wed Aug 1 11:08:52 2018 New Revision: 337036 URL: https://svnweb.freebsd.org/changeset/base/337036 Log: MFC r321686 and r330361: Add inline functions to convert between sbintime_t and decimal time units. Use them in some existing code that is vulnerable to roundoff errors. Modified: stable/10/sys/arm/arm/mpcore_timer.c stable/10/sys/sys/time.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/arm/mpcore_timer.c ============================================================================== --- stable/10/sys/arm/arm/mpcore_timer.c Wed Aug 1 10:35:49 2018 (r337035) +++ stable/10/sys/arm/arm/mpcore_timer.c Wed Aug 1 11:08:52 2018 (r337036) @@ -349,7 +349,7 @@ attach_et(struct arm_tmr_softc *sc) sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT | ET_FLAGS_PERCPU; sc->et.et_quality = 1000; sc->et.et_frequency = sc->clkfreq; - sc->et.et_min_period = 20 * SBT_1NS; + sc->et.et_min_period = nstosbt(20); sc->et.et_max_period = 2 * SBT_1S; sc->et.et_start = arm_tmr_start; sc->et.et_stop = arm_tmr_stop; Modified: stable/10/sys/sys/time.h ============================================================================== --- stable/10/sys/sys/time.h Wed Aug 1 10:35:49 2018 (r337035) +++ stable/10/sys/sys/time.h Wed Aug 1 11:08:52 2018 (r337036) @@ -128,7 +128,7 @@ bintime_shift(struct bintime *_bt, int _exp) #define SBT_1M (SBT_1S * 60) #define SBT_1MS (SBT_1S / 1000) #define SBT_1US (SBT_1S / 1000000) -#define SBT_1NS (SBT_1S / 1000000000) +#define SBT_1NS (SBT_1S / 1000000000) /* beware rounding, see nstosbt() */ #define SBT_MAX 0x7fffffffffffffffLL static __inline int @@ -155,6 +155,53 @@ sbttobt(sbintime_t _sbt) return (_bt); } +/* + * Decimal<->sbt conversions. Multiplying or dividing by SBT_1NS results in + * large roundoff errors which sbttons() and nstosbt() avoid. Millisecond and + * microsecond functions are also provided for completeness. + */ +static __inline int64_t +sbttons(sbintime_t _sbt) +{ + + return ((1000000000 * _sbt) >> 32); +} + +static __inline sbintime_t +nstosbt(int64_t _ns) +{ + + return ((_ns * (((uint64_t)1 << 63) / 500000000)) >> 32); +} + +static __inline int64_t +sbttous(sbintime_t _sbt) +{ + + return ((1000000 * _sbt) >> 32); +} + +static __inline sbintime_t +ustosbt(int64_t _us) +{ + + return ((_us * (((uint64_t)1 << 63) / 500000)) >> 32); +} + +static __inline int64_t +sbttoms(sbintime_t _sbt) +{ + + return ((1000 * _sbt) >> 32); +} + +static __inline sbintime_t +mstosbt(int64_t _ms) +{ + + return ((_ms * (((uint64_t)1 << 63) / 500)) >> 32); +} + /*- * Background information: * @@ -210,7 +257,7 @@ sbttots(sbintime_t _sbt) struct timespec _ts; _ts.tv_sec = _sbt >> 32; - _ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32; + _ts.tv_nsec = sbttons((uint32_t)_sbt); return (_ts); } @@ -218,8 +265,7 @@ static __inline sbintime_t tstosbt(struct timespec _ts) { - return (((sbintime_t)_ts.tv_sec << 32) + - (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32)); + return (((sbintime_t)_ts.tv_sec << 32) + nstosbt(_ts.tv_nsec)); } static __inline struct timeval @@ -228,7 +274,7 @@ sbttotv(sbintime_t _sbt) struct timeval _tv; _tv.tv_sec = _sbt >> 32; - _tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32; + _tv.tv_usec = sbttous((uint32_t)_sbt); return (_tv); } @@ -236,8 +282,7 @@ static __inline sbintime_t tvtosbt(struct timeval _tv) { - return (((sbintime_t)_tv.tv_sec << 32) + - (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32)); + return (((sbintime_t)_tv.tv_sec << 32) + ustosbt(_tv.tv_usec)); } #endif /* __BSD_VISIBLE */ From owner-svn-src-stable-10@freebsd.org Wed Aug 1 12:49:52 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0CA2105B41E; Wed, 1 Aug 2018 12:49:52 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5581D725F6; Wed, 1 Aug 2018 12:49:52 +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 33A2E22A51; Wed, 1 Aug 2018 12:49:52 +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 w71Cnqcb036477; Wed, 1 Aug 2018 12:49:52 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w71CnpWg036475; Wed, 1 Aug 2018 12:49:51 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201808011249.w71CnpWg036475@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 1 Aug 2018 12:49:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337041 - in stable/10/sys: amd64/include i386/include X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/10/sys: amd64/include i386/include X-SVN-Commit-Revision: 337041 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2018 12:49:52 -0000 Author: hselasky Date: Wed Aug 1 12:49:51 2018 New Revision: 337041 URL: https://svnweb.freebsd.org/changeset/base/337041 Log: MFC r311169, r312975, r313080, r315718 and r316031: Add support for atomic_(f)cmpset to x86. Modified: stable/10/sys/amd64/include/atomic.h stable/10/sys/i386/include/atomic.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/include/atomic.h ============================================================================== --- stable/10/sys/amd64/include/atomic.h Wed Aug 1 12:18:52 2018 (r337040) +++ stable/10/sys/amd64/include/atomic.h Wed Aug 1 12:49:51 2018 (r337041) @@ -78,8 +78,15 @@ void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \ void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v) +int atomic_cmpset_char(volatile u_char *dst, u_char expect, u_char src); +int atomic_cmpset_short(volatile u_short *dst, u_short expect, u_short src); int atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src); int atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src); +int atomic_fcmpset_char(volatile u_char *dst, u_char *expect, u_char src); +int atomic_fcmpset_short(volatile u_short *dst, u_short *expect, + u_short src); +int atomic_fcmpset_int(volatile u_int *dst, u_int *expect, u_int src); +int atomic_fcmpset_long(volatile u_long *dst, u_long *expect, u_long src); u_int atomic_fetchadd_int(volatile u_int *p, u_int v); u_long atomic_fetchadd_long(volatile u_long *p, u_long v); int atomic_testandset_int(volatile u_int *p, u_int v); @@ -130,49 +137,62 @@ atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_## struct __hack /* - * Atomic compare and set, used by the mutex functions + * Atomic compare and set, used by the mutex functions. * - * if (*dst == expect) *dst = src (all 32 bit words) + * cmpset: + * if (*dst == expect) + * *dst = src * - * Returns 0 on failure, non-zero on success + * fcmpset: + * if (*dst == *expect) + * *dst = src + * else + * *expect = *dst + * + * Returns 0 on failure, non-zero on success. */ - -static __inline int -atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src) -{ - u_char res; - - __asm __volatile( - " " MPLOCKED " " - " cmpxchgl %3,%1 ; " - " sete %0 ; " - "# atomic_cmpset_int" - : "=q" (res), /* 0 */ - "+m" (*dst), /* 1 */ - "+a" (expect) /* 2 */ - : "r" (src) /* 3 */ - : "memory", "cc"); - return (res); +#define ATOMIC_CMPSET(TYPE) \ +static __inline int \ +atomic_cmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE expect, u_##TYPE src) \ +{ \ + u_char res; \ + \ + __asm __volatile( \ + " " MPLOCKED " " \ + " cmpxchg %3,%1 ; " \ + " sete %0 ; " \ + "# atomic_cmpset_" #TYPE " " \ + : "=q" (res), /* 0 */ \ + "+m" (*dst), /* 1 */ \ + "+a" (expect) /* 2 */ \ + : "r" (src) /* 3 */ \ + : "memory", "cc"); \ + return (res); \ +} \ + \ +static __inline int \ +atomic_fcmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE *expect, u_##TYPE src) \ +{ \ + u_char res; \ + \ + __asm __volatile( \ + " " MPLOCKED " " \ + " cmpxchg %3,%1 ; " \ + " sete %0 ; " \ + "# atomic_fcmpset_" #TYPE " " \ + : "=q" (res), /* 0 */ \ + "+m" (*dst), /* 1 */ \ + "+a" (*expect) /* 2 */ \ + : "r" (src) /* 3 */ \ + : "memory", "cc"); \ + return (res); \ } -static __inline int -atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src) -{ - u_char res; +ATOMIC_CMPSET(char); +ATOMIC_CMPSET(short); +ATOMIC_CMPSET(int); +ATOMIC_CMPSET(long); - __asm __volatile( - " " MPLOCKED " " - " cmpxchgq %3,%1 ; " - " sete %0 ; " - "# atomic_cmpset_long" - : "=q" (res), /* 0 */ - "+m" (*dst), /* 1 */ - "+a" (expect) /* 2 */ - : "r" (src) /* 3 */ - : "memory", "cc"); - return (res); -} - /* * Atomically add the value of v to the integer pointed to by p and return * the previous value of *p. @@ -409,6 +429,10 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_add_rel_char atomic_add_barr_char #define atomic_subtract_acq_char atomic_subtract_barr_char #define atomic_subtract_rel_char atomic_subtract_barr_char +#define atomic_cmpset_acq_char atomic_cmpset_char +#define atomic_cmpset_rel_char atomic_cmpset_char +#define atomic_fcmpset_acq_char atomic_fcmpset_char +#define atomic_fcmpset_rel_char atomic_fcmpset_char #define atomic_set_acq_short atomic_set_barr_short #define atomic_set_rel_short atomic_set_barr_short @@ -418,6 +442,10 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_add_rel_short atomic_add_barr_short #define atomic_subtract_acq_short atomic_subtract_barr_short #define atomic_subtract_rel_short atomic_subtract_barr_short +#define atomic_cmpset_acq_short atomic_cmpset_short +#define atomic_cmpset_rel_short atomic_cmpset_short +#define atomic_fcmpset_acq_short atomic_fcmpset_short +#define atomic_fcmpset_rel_short atomic_fcmpset_short #define atomic_set_acq_int atomic_set_barr_int #define atomic_set_rel_int atomic_set_barr_int @@ -429,6 +457,8 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_int atomic_subtract_barr_int #define atomic_cmpset_acq_int atomic_cmpset_int #define atomic_cmpset_rel_int atomic_cmpset_int +#define atomic_fcmpset_acq_int atomic_fcmpset_int +#define atomic_fcmpset_rel_int atomic_fcmpset_int #define atomic_set_acq_long atomic_set_barr_long #define atomic_set_rel_long atomic_set_barr_long @@ -440,6 +470,8 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_long atomic_subtract_barr_long #define atomic_cmpset_acq_long atomic_cmpset_long #define atomic_cmpset_rel_long atomic_cmpset_long +#define atomic_fcmpset_acq_long atomic_fcmpset_long +#define atomic_fcmpset_rel_long atomic_fcmpset_long #define atomic_readandclear_int(p) atomic_swap_int(p, 0) #define atomic_readandclear_long(p) atomic_swap_long(p, 0) @@ -459,6 +491,12 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_8 atomic_subtract_rel_char #define atomic_load_acq_8 atomic_load_acq_char #define atomic_store_rel_8 atomic_store_rel_char +#define atomic_cmpset_8 atomic_cmpset_char +#define atomic_cmpset_acq_8 atomic_cmpset_acq_char +#define atomic_cmpset_rel_8 atomic_cmpset_rel_char +#define atomic_fcmpset_8 atomic_fcmpset_char +#define atomic_fcmpset_acq_8 atomic_fcmpset_acq_char +#define atomic_fcmpset_rel_8 atomic_fcmpset_rel_char /* Operations on 16-bit words. */ #define atomic_set_16 atomic_set_short @@ -475,6 +513,12 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_16 atomic_subtract_rel_short #define atomic_load_acq_16 atomic_load_acq_short #define atomic_store_rel_16 atomic_store_rel_short +#define atomic_cmpset_16 atomic_cmpset_short +#define atomic_cmpset_acq_16 atomic_cmpset_acq_short +#define atomic_cmpset_rel_16 atomic_cmpset_rel_short +#define atomic_fcmpset_16 atomic_fcmpset_short +#define atomic_fcmpset_acq_16 atomic_fcmpset_acq_short +#define atomic_fcmpset_rel_16 atomic_fcmpset_rel_short /* Operations on 32-bit double words. */ #define atomic_set_32 atomic_set_int @@ -494,6 +538,9 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_cmpset_32 atomic_cmpset_int #define atomic_cmpset_acq_32 atomic_cmpset_acq_int #define atomic_cmpset_rel_32 atomic_cmpset_rel_int +#define atomic_fcmpset_32 atomic_fcmpset_int +#define atomic_fcmpset_acq_32 atomic_fcmpset_acq_int +#define atomic_fcmpset_rel_32 atomic_fcmpset_rel_int #define atomic_swap_32 atomic_swap_int #define atomic_readandclear_32 atomic_readandclear_int #define atomic_fetchadd_32 atomic_fetchadd_int @@ -518,6 +565,9 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_cmpset_64 atomic_cmpset_long #define atomic_cmpset_acq_64 atomic_cmpset_acq_long #define atomic_cmpset_rel_64 atomic_cmpset_rel_long +#define atomic_fcmpset_64 atomic_fcmpset_long +#define atomic_fcmpset_acq_64 atomic_fcmpset_acq_long +#define atomic_fcmpset_rel_64 atomic_fcmpset_rel_long #define atomic_swap_64 atomic_swap_long #define atomic_readandclear_64 atomic_readandclear_long #define atomic_fetchadd_64 atomic_fetchadd_long @@ -542,6 +592,9 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_cmpset_ptr atomic_cmpset_long #define atomic_cmpset_acq_ptr atomic_cmpset_acq_long #define atomic_cmpset_rel_ptr atomic_cmpset_rel_long +#define atomic_fcmpset_ptr atomic_fcmpset_long +#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_long +#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long #define atomic_swap_ptr atomic_swap_long #define atomic_readandclear_ptr atomic_readandclear_long Modified: stable/10/sys/i386/include/atomic.h ============================================================================== --- stable/10/sys/i386/include/atomic.h Wed Aug 1 12:18:52 2018 (r337040) +++ stable/10/sys/i386/include/atomic.h Wed Aug 1 12:49:51 2018 (r337041) @@ -83,7 +83,13 @@ void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \ void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v) +int atomic_cmpset_char(volatile u_char *dst, u_char expect, u_char src); +int atomic_cmpset_short(volatile u_short *dst, u_short expect, u_short src); int atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src); +int atomic_fcmpset_char(volatile u_char *dst, u_char *expect, u_char src); +int atomic_fcmpset_short(volatile u_short *dst, u_short *expect, + u_short src); +int atomic_fcmpset_int(volatile u_int *dst, u_int *expect, u_int src); u_int atomic_fetchadd_int(volatile u_int *p, u_int v); int atomic_testandset_int(volatile u_int *p, u_int v); int atomic_testandclear_int(volatile u_int *p, u_int v); @@ -137,60 +143,61 @@ atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_## struct __hack /* - * Atomic compare and set, used by the mutex functions + * Atomic compare and set, used by the mutex functions. * - * if (*dst == expect) *dst = src (all 32 bit words) + * cmpset: + * if (*dst == expect) + * *dst = src * - * Returns 0 on failure, non-zero on success + * fcmpset: + * if (*dst == *expect) + * *dst = src + * else + * *expect = *dst + * + * Returns 0 on failure, non-zero on success. */ - -#ifdef CPU_DISABLE_CMPXCHG - -static __inline int -atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src) -{ - u_char res; - - __asm __volatile( - " pushfl ; " - " cli ; " - " cmpl %3,%1 ; " - " jne 1f ; " - " movl %2,%1 ; " - "1: " - " sete %0 ; " - " popfl ; " - "# atomic_cmpset_int" - : "=q" (res), /* 0 */ - "+m" (*dst) /* 1 */ - : "r" (src), /* 2 */ - "r" (expect) /* 3 */ - : "memory"); - return (res); +#define ATOMIC_CMPSET(TYPE, CONS) \ +static __inline int \ +atomic_cmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE expect, u_##TYPE src) \ +{ \ + u_char res; \ + \ + __asm __volatile( \ + " " MPLOCKED " " \ + " cmpxchg %3,%1 ; " \ + " sete %0 ; " \ + "# atomic_cmpset_" #TYPE " " \ + : "=q" (res), /* 0 */ \ + "+m" (*dst), /* 1 */ \ + "+a" (expect) /* 2 */ \ + : CONS (src) /* 3 */ \ + : "memory", "cc"); \ + return (res); \ +} \ + \ +static __inline int \ +atomic_fcmpset_##TYPE(volatile u_##TYPE *dst, u_##TYPE *expect, u_##TYPE src) \ +{ \ + u_char res; \ + \ + __asm __volatile( \ + " " MPLOCKED " " \ + " cmpxchg %3,%1 ; " \ + " sete %0 ; " \ + "# atomic_fcmpset_" #TYPE " " \ + : "=q" (res), /* 0 */ \ + "+m" (*dst), /* 1 */ \ + "+a" (*expect) /* 2 */ \ + : CONS (src) /* 3 */ \ + : "memory", "cc"); \ + return (res); \ } -#else /* !CPU_DISABLE_CMPXCHG */ +ATOMIC_CMPSET(char, "q"); +ATOMIC_CMPSET(short, "r"); +ATOMIC_CMPSET(int, "r"); -static __inline int -atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src) -{ - u_char res; - - __asm __volatile( - " " MPLOCKED " " - " cmpxchgl %3,%1 ; " - " sete %0 ; " - "# atomic_cmpset_int" - : "=q" (res), /* 0 */ - "+m" (*dst), /* 1 */ - "+a" (expect) /* 2 */ - : "r" (src) /* 3 */ - : "memory", "cc"); - return (res); -} - -#endif /* CPU_DISABLE_CMPXCHG */ - /* * Atomically add the value of v to the integer pointed to by p and return * the previous value of *p. @@ -623,6 +630,10 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_add_rel_char atomic_add_barr_char #define atomic_subtract_acq_char atomic_subtract_barr_char #define atomic_subtract_rel_char atomic_subtract_barr_char +#define atomic_cmpset_acq_char atomic_cmpset_char +#define atomic_cmpset_rel_char atomic_cmpset_char +#define atomic_fcmpset_acq_char atomic_fcmpset_char +#define atomic_fcmpset_rel_char atomic_fcmpset_char #define atomic_set_acq_short atomic_set_barr_short #define atomic_set_rel_short atomic_set_barr_short @@ -632,6 +643,10 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_add_rel_short atomic_add_barr_short #define atomic_subtract_acq_short atomic_subtract_barr_short #define atomic_subtract_rel_short atomic_subtract_barr_short +#define atomic_cmpset_acq_short atomic_cmpset_short +#define atomic_cmpset_rel_short atomic_cmpset_short +#define atomic_fcmpset_acq_short atomic_fcmpset_short +#define atomic_fcmpset_rel_short atomic_fcmpset_short #define atomic_set_acq_int atomic_set_barr_int #define atomic_set_rel_int atomic_set_barr_int @@ -643,6 +658,8 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_int atomic_subtract_barr_int #define atomic_cmpset_acq_int atomic_cmpset_int #define atomic_cmpset_rel_int atomic_cmpset_int +#define atomic_fcmpset_acq_int atomic_fcmpset_int +#define atomic_fcmpset_rel_int atomic_fcmpset_int #define atomic_set_acq_long atomic_set_barr_long #define atomic_set_rel_long atomic_set_barr_long @@ -654,6 +671,8 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_long atomic_subtract_barr_long #define atomic_cmpset_acq_long atomic_cmpset_long #define atomic_cmpset_rel_long atomic_cmpset_long +#define atomic_fcmpset_acq_long atomic_fcmpset_long +#define atomic_fcmpset_rel_long atomic_fcmpset_long #define atomic_readandclear_int(p) atomic_swap_int(p, 0) #define atomic_readandclear_long(p) atomic_swap_long(p, 0) @@ -673,6 +692,12 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_8 atomic_subtract_rel_char #define atomic_load_acq_8 atomic_load_acq_char #define atomic_store_rel_8 atomic_store_rel_char +#define atomic_cmpset_8 atomic_cmpset_char +#define atomic_cmpset_acq_8 atomic_cmpset_acq_char +#define atomic_cmpset_rel_8 atomic_cmpset_rel_char +#define atomic_fcmpset_8 atomic_fcmpset_char +#define atomic_fcmpset_acq_8 atomic_fcmpset_acq_char +#define atomic_fcmpset_rel_8 atomic_fcmpset_rel_char /* Operations on 16-bit words. */ #define atomic_set_16 atomic_set_short @@ -689,6 +714,12 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_16 atomic_subtract_rel_short #define atomic_load_acq_16 atomic_load_acq_short #define atomic_store_rel_16 atomic_store_rel_short +#define atomic_cmpset_16 atomic_cmpset_short +#define atomic_cmpset_acq_16 atomic_cmpset_acq_short +#define atomic_cmpset_rel_16 atomic_cmpset_rel_short +#define atomic_fcmpset_16 atomic_fcmpset_short +#define atomic_fcmpset_acq_16 atomic_fcmpset_acq_short +#define atomic_fcmpset_rel_16 atomic_fcmpset_rel_short /* Operations on 32-bit double words. */ #define atomic_set_32 atomic_set_int @@ -708,6 +739,9 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_cmpset_32 atomic_cmpset_int #define atomic_cmpset_acq_32 atomic_cmpset_acq_int #define atomic_cmpset_rel_32 atomic_cmpset_rel_int +#define atomic_fcmpset_32 atomic_fcmpset_int +#define atomic_fcmpset_acq_32 atomic_fcmpset_acq_int +#define atomic_fcmpset_rel_32 atomic_fcmpset_rel_int #define atomic_swap_32 atomic_swap_int #define atomic_readandclear_32 atomic_readandclear_int #define atomic_fetchadd_32 atomic_fetchadd_int @@ -750,6 +784,14 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); (u_int)(new)) #define atomic_cmpset_rel_ptr(dst, old, new) \ atomic_cmpset_rel_int((volatile u_int *)(dst), (u_int)(old), \ + (u_int)(new)) +#define atomic_fcmpset_ptr(dst, old, new) \ + atomic_fcmpset_int((volatile u_int *)(dst), (u_int *)(old), (u_int)(new)) +#define atomic_fcmpset_acq_ptr(dst, old, new) \ + atomic_fcmpset_acq_int((volatile u_int *)(dst), (u_int *)(old), \ + (u_int)(new)) +#define atomic_fcmpset_rel_ptr(dst, old, new) \ + atomic_fcmpset_rel_int((volatile u_int *)(dst), (u_int *)(old), \ (u_int)(new)) #define atomic_swap_ptr(p, v) \ atomic_swap_int((volatile u_int *)(p), (u_int)(v)) From owner-svn-src-stable-10@freebsd.org Wed Aug 1 13:13:44 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F348105BE58; Wed, 1 Aug 2018 13:13:44 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 157837359B; Wed, 1 Aug 2018 13:13:44 +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 EB03122F37; Wed, 1 Aug 2018 13:13:43 +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 w71DDhkt051427; Wed, 1 Aug 2018 13:13:43 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w71DDhHO051426; Wed, 1 Aug 2018 13:13:43 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201808011313.w71DDhHO051426@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 1 Aug 2018 13:13:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337042 - stable/10/sys/sys X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/sys/sys X-SVN-Commit-Revision: 337042 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2018 13:13:44 -0000 Author: hselasky Date: Wed Aug 1 13:13:43 2018 New Revision: 337042 URL: https://svnweb.freebsd.org/changeset/base/337042 Log: MFC r322596: Add SI_SUB_TASKQ after SI_SUB_INTR and move taskqueue initialization there for EARLY_AP_STARTUP This fixes a regression accidentally introduced in r322588, due to an interaction with EARLY_AP_STARTUP. Reviewed by: bdrewery@, jhb@ Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D12053 Modified: stable/10/sys/sys/kernel.h stable/10/sys/sys/taskqueue.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/sys/kernel.h ============================================================================== --- stable/10/sys/sys/kernel.h Wed Aug 1 12:49:51 2018 (r337041) +++ stable/10/sys/sys/kernel.h Wed Aug 1 13:13:43 2018 (r337042) @@ -127,8 +127,9 @@ enum sysinit_sub_id { SI_SUB_SCHED_IDLE = 0x2600000, /* required idle procs */ SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */ SI_SUB_INTR = 0x2800000, /* interrupt threads */ - SI_SUB_SOFTINTR = 0x2800001, /* start soft interrupt thread */ + SI_SUB_TASKQ = 0x2880000, /* task queues */ SI_SUB_ACL = 0x2900000, /* start for filesystem ACLs */ + SI_SUB_SOFTINTR = 0x2A00000, /* start soft interrupt thread */ SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */ SI_SUB_INIT_IF = 0x3000000, /* prep for net interfaces */ SI_SUB_NETGRAPH = 0x3010000, /* Let Netgraph initialize */ Modified: stable/10/sys/sys/taskqueue.h ============================================================================== --- stable/10/sys/sys/taskqueue.h Wed Aug 1 12:49:51 2018 (r337041) +++ stable/10/sys/sys/taskqueue.h Wed Aug 1 13:13:43 2018 (r337042) @@ -141,7 +141,7 @@ taskqueue_define_##name(void *arg) \ init; \ } \ \ -SYSINIT(taskqueue_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND, \ +SYSINIT(taskqueue_##name, SI_SUB_TASKQ, SI_ORDER_SECOND, \ taskqueue_define_##name, NULL); \ \ struct __hack @@ -166,7 +166,7 @@ taskqueue_define_##name(void *arg) \ init; \ } \ \ -SYSINIT(taskqueue_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND, \ +SYSINIT(taskqueue_##name, SI_SUB_TASKQ, SI_ORDER_SECOND, \ taskqueue_define_##name, NULL); \ \ struct __hack From owner-svn-src-stable-10@freebsd.org Wed Aug 1 19:25:14 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 25B931067253; Wed, 1 Aug 2018 19:25:14 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BEBFC84025; Wed, 1 Aug 2018 19:25:13 +0000 (UTC) (envelope-from rmacklem@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 9A37826C6A; Wed, 1 Aug 2018 19:25:13 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w71JPDAv043025; Wed, 1 Aug 2018 19:25:13 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w71JPDd8043022; Wed, 1 Aug 2018 19:25:13 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201808011925.w71JPDd8043022@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 1 Aug 2018 19:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337058 - in stable/10/sys/fs: nfs nfsserver X-SVN-Group: stable-10 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in stable/10/sys/fs: nfs nfsserver X-SVN-Commit-Revision: 337058 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2018 19:25:14 -0000 Author: rmacklem Date: Wed Aug 1 19:25:12 2018 New Revision: 337058 URL: https://svnweb.freebsd.org/changeset/base/337058 Log: MFC: r336357 Modify the reasons for not issuing a delegation in the NFSv4.1 server. The ESXi NFSv4.1 client will generate warning messages when the reason for not issuing a delegation is two. Two refers to a resource limit and I do not see why it would be considered invalid. However it probably was not the best choice of reason for not issuing a delegation. This patch changes the reasons used to ones that the ESXi client doesn't complain about. This change does not affect the FreeBSD client and does not appear to affect behaviour of the Linux NFSv4.1 client. RFC5661 defines these "reasons" but does not give any guidance w.r.t. which ones are more appropriate to return to a client. Modified: stable/10/sys/fs/nfs/nfsproto.h stable/10/sys/fs/nfsserver/nfs_nfsdserv.c stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfs/nfsproto.h ============================================================================== --- stable/10/sys/fs/nfs/nfsproto.h Wed Aug 1 19:17:55 2018 (r337057) +++ stable/10/sys/fs/nfs/nfsproto.h Wed Aug 1 19:25:12 2018 (r337058) @@ -552,6 +552,7 @@ #define NFSV4OPEN_WDRESOURCE 0x00080000 #define NFSV4OPEN_WDCONTENTION 0x00100000 #define NFSV4OPEN_WDNOTWANTED 0x00200000 +#define NFSV4OPEN_WDSUPPFTYPE 0x00400000 /* * NFS V4 File Handle types Modified: stable/10/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Wed Aug 1 19:17:55 2018 (r337057) +++ stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Wed Aug 1 19:25:12 2018 (r337058) @@ -2929,7 +2929,13 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int is *tl = txdr_unsigned(NFSV4OPEN_DELEGATEWRITE); else if (retext != 0) { *tl = txdr_unsigned(NFSV4OPEN_DELEGATENONEEXT); - if ((rflags & NFSV4OPEN_WDCONTENTION) != 0) { + if ((rflags & NFSV4OPEN_WDNOTWANTED) != 0) { + NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV4OPEN_NOTWANTED); + } else if ((rflags & NFSV4OPEN_WDSUPPFTYPE) != 0) { + NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV4OPEN_NOTSUPPFTYPE); + } else if ((rflags & NFSV4OPEN_WDCONTENTION) != 0) { NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(NFSV4OPEN_CONTENTION); *tl = newnfs_false; Modified: stable/10/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Wed Aug 1 19:17:55 2018 (r337057) +++ stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Wed Aug 1 19:25:12 2018 (r337058) @@ -3022,7 +3022,13 @@ tryagain: /* * This is where we can choose to issue a delegation. */ - if (delegate == 0 || writedeleg == 0 || + if ((new_stp->ls_flags & NFSLCK_WANTNODELEG) != 0) + *rflagsp |= NFSV4OPEN_WDNOTWANTED; + else if (nfsrv_issuedelegs == 0) + *rflagsp |= NFSV4OPEN_WDSUPPFTYPE; + else if (NFSRV_V4DELEGLIMIT(nfsrv_delegatecnt)) + *rflagsp |= NFSV4OPEN_WDRESOURCE; + else if (delegate == 0 || writedeleg == 0 || NFSVNO_EXRDONLY(exp) || (readonly != 0 && nfsrv_writedelegifpos == 0) || !NFSVNO_DELEGOK(vp) || @@ -3030,11 +3036,6 @@ tryagain: (clp->lc_flags & (LCL_CALLBACKSON | LCL_CBDOWN)) != LCL_CALLBACKSON) *rflagsp |= NFSV4OPEN_WDCONTENTION; - else if (nfsrv_issuedelegs == 0 || - NFSRV_V4DELEGLIMIT(nfsrv_delegatecnt)) - *rflagsp |= NFSV4OPEN_WDRESOURCE; - else if ((new_stp->ls_flags & NFSLCK_WANTNODELEG) != 0) - *rflagsp |= NFSV4OPEN_WDNOTWANTED; else { new_deleg->ls_stateid.seqid = delegstateidp->seqid = 1; new_deleg->ls_stateid.other[0] = delegstateidp->other[0] @@ -3085,16 +3086,17 @@ tryagain: /* * This is where we can choose to issue a delegation. */ - if (delegate == 0 || (writedeleg == 0 && readonly == 0) || - !NFSVNO_DELEGOK(vp) || + if ((new_stp->ls_flags & NFSLCK_WANTNODELEG) != 0) + *rflagsp |= NFSV4OPEN_WDNOTWANTED; + else if (nfsrv_issuedelegs == 0) + *rflagsp |= NFSV4OPEN_WDSUPPFTYPE; + else if (NFSRV_V4DELEGLIMIT(nfsrv_delegatecnt)) + *rflagsp |= NFSV4OPEN_WDRESOURCE; + else if (delegate == 0 || (writedeleg == 0 && + readonly == 0) || !NFSVNO_DELEGOK(vp) || (clp->lc_flags & (LCL_CALLBACKSON | LCL_CBDOWN)) != LCL_CALLBACKSON) *rflagsp |= NFSV4OPEN_WDCONTENTION; - else if (nfsrv_issuedelegs == 0 || - NFSRV_V4DELEGLIMIT(nfsrv_delegatecnt)) - *rflagsp |= NFSV4OPEN_WDRESOURCE; - else if ((new_stp->ls_flags & NFSLCK_WANTNODELEG) != 0) - *rflagsp |= NFSV4OPEN_WDNOTWANTED; else { new_deleg->ls_stateid.seqid = delegstateidp->seqid = 1; new_deleg->ls_stateid.other[0] = delegstateidp->other[0] From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:08:40 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8394B106AD64; Fri, 3 Aug 2018 14:08:40 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3520E82F63; Fri, 3 Aug 2018 14:08:40 +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 E9064215F8; Fri, 3 Aug 2018 14:08:39 +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 w73E8dKu064868; Fri, 3 Aug 2018 14:08:39 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73E8dEW064866; Fri, 3 Aug 2018 14:08:39 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031408.w73E8dEW064866@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:08:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337244 - in stable/10: contrib/netbsd-tests/lib/libc/sys lib/libc/sys X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/10: contrib/netbsd-tests/lib/libc/sys lib/libc/sys X-SVN-Commit-Revision: 337244 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:08:40 -0000 Author: asomers Date: Fri Aug 3 14:08:39 2018 New Revision: 337244 URL: https://svnweb.freebsd.org/changeset/base/337244 Log: MFC r328266: mlock(2): correct documentation for error conditions. The man page is years out of date regarding errors. Our implementation _does_ allow unaligned addresses, and it _does_not_ check for negative lengths, because the length is unsigned. It checks for overflow instead. Update the tests accordingly. Reviewed by: bcr Differential Revision: https://reviews.freebsd.org/D13826 Modified: stable/10/contrib/netbsd-tests/lib/libc/sys/t_mlock.c stable/10/lib/libc/sys/mlock.2 Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/netbsd-tests/lib/libc/sys/t_mlock.c ============================================================================== --- stable/10/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Fri Aug 3 14:06:08 2018 (r337243) +++ stable/10/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Fri Aug 3 14:08:39 2018 (r337244) @@ -131,33 +131,38 @@ ATF_TC_BODY(mlock_err, tc) ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)0, page) == -1); errno = 0; - ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)-1, page) == -1); - - errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, munlock(NULL, page) == -1); errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, munlock((char *)0, page) == -1); +#ifdef __FreeBSD__ + /* Wrap around should return EINVAL */ errno = 0; + ATF_REQUIRE_ERRNO(EINVAL, mlock((char *)-1, page) == -1); + errno = 0; + ATF_REQUIRE_ERRNO(EINVAL, munlock((char *)-1, page) == -1); +#else + errno = 0; + ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)-1, page) == -1); + errno = 0; ATF_REQUIRE_ERRNO(ENOMEM, munlock((char *)-1, page) == -1); +#endif - buf = malloc(page); + buf = malloc(page); /* Get a valid address */ ATF_REQUIRE(buf != NULL); - - /* - * unlocking memory that is not locked is an error... - */ - +#ifdef __FreeBSD__ errno = 0; - ATF_REQUIRE_ERRNO(ENOMEM, munlock(buf, page) == -1); - - /* - * These are permitted to fail (EINVAL) but do not on NetBSD - */ - ATF_REQUIRE(mlock((void *)(((uintptr_t)buf) + page/3), page/5) == 0); - ATF_REQUIRE(munlock((void *)(((uintptr_t)buf) + page/3), page/5) == 0); - + /* Wrap around should return EINVAL */ + ATF_REQUIRE_ERRNO(EINVAL, mlock(buf, -page) == -1); + errno = 0; + ATF_REQUIRE_ERRNO(EINVAL, munlock(buf, -page) == -1); +#else + errno = 0; + ATF_REQUIRE_ERRNO(ENOMEM, mlock(buf, -page) == -1); + errno = 0; + ATF_REQUIRE_ERRNO(ENOMEM, munlock(buf, -page) == -1); +#endif (void)free(buf); /* @@ -355,6 +360,80 @@ ATF_TC_CLEANUP(mlock_nested, tc) } #endif +#ifdef __FreeBSD__ +ATF_TC_WITH_CLEANUP(mlock_unaligned); +#else +ATF_TC(mlock_unaligned); +#endif +ATF_TC_HEAD(mlock_unaligned, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that mlock(2) can lock page-unaligned memory"); +#ifdef __FreeBSD__ + atf_tc_set_md_var(tc, "require.config", "allow_sysctl_side_effects"); + atf_tc_set_md_var(tc, "require.user", "root"); +#endif +} + +ATF_TC_BODY(mlock_unaligned, tc) +{ + void *buf, *addr; + +#ifdef __FreeBSD__ + /* Set max_wired really really high to avoid EAGAIN */ + set_vm_max_wired(INT_MAX); +#endif + + buf = malloc(page); + ATF_REQUIRE(buf != NULL); + + if ((uintptr_t)buf & ((uintptr_t)page - 1)) + addr = buf; + else + addr = (void *)(((uintptr_t)buf) + page/3); + + ATF_REQUIRE_EQ(mlock(addr, page/5), 0); + ATF_REQUIRE_EQ(munlock(addr, page/5), 0); + + (void)free(buf); +} + +#ifdef __FreeBSD__ +ATF_TC_CLEANUP(mlock_unaligned, tc) +{ + + restore_vm_max_wired(); +} +#endif + +ATF_TC(munlock_unlocked); +ATF_TC_HEAD(munlock_unlocked, tc) +{ + atf_tc_set_md_var(tc, "descr", +#ifdef __FreeBSD__ + "munlock(2) accepts unlocked memory"); +#else + "munlock(2) of unlocked memory is an error"); +#endif + atf_tc_set_md_var(tc, "require.user", "root"); +} + +ATF_TC_BODY(munlock_unlocked, tc) +{ + void *buf; + + buf = malloc(page); + ATF_REQUIRE(buf != NULL); + +#ifdef __FreeBSD__ + ATF_REQUIRE_EQ(munlock(buf, page), 0); +#else + errno = 0; + ATF_REQUIRE_ERRNO(ENOMEM, munlock(buf, page) == -1); +#endif + (void)free(buf); +} + ATF_TP_ADD_TCS(tp) { @@ -366,6 +445,8 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, mlock_limits); ATF_TP_ADD_TC(tp, mlock_mmap); ATF_TP_ADD_TC(tp, mlock_nested); + ATF_TP_ADD_TC(tp, mlock_unaligned); + ATF_TP_ADD_TC(tp, munlock_unlocked); return atf_no_error(); } Modified: stable/10/lib/libc/sys/mlock.2 ============================================================================== --- stable/10/lib/libc/sys/mlock.2 Fri Aug 3 14:06:08 2018 (r337243) +++ stable/10/lib/libc/sys/mlock.2 Fri Aug 3 14:08:39 2018 (r337244) @@ -28,7 +28,7 @@ .\" @(#)mlock.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd May 17, 2014 +.Dd Jan 22, 2018 .Dt MLOCK 2 .Os .Sh NAME @@ -125,7 +125,7 @@ will fail if: .Va security.bsd.unprivileged_mlock is set to 0 and the caller is not the super-user. .It Bq Er EINVAL -The address given is not page aligned or the length is negative. +The address range given wraps around zero. .It Bq Er EAGAIN Locking the indicated range would exceed the system limit for locked memory. .It Bq Er ENOMEM @@ -143,7 +143,7 @@ will fail if: .Va security.bsd.unprivileged_mlock is set to 0 and the caller is not the super-user. .It Bq Er EINVAL -The address given is not page aligned or the length is negative. +The address range given wraps around zero. .It Bq Er ENOMEM Some or all of the address range specified by the addr and len arguments does not correspond to valid mapped pages in the address space From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:12:39 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43A1A106AF70; Fri, 3 Aug 2018 14:12:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EB76C83368; Fri, 3 Aug 2018 14:12:38 +0000 (UTC) (envelope-from kib@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 CC6C12179B; Fri, 3 Aug 2018 14:12:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w73ECc6O069911; Fri, 3 Aug 2018 14:12:38 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73ECcst069907; Fri, 3 Aug 2018 14:12:38 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201808031412.w73ECcst069907@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 3 Aug 2018 14:12:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337245 - in stable/10/sys: amd64/amd64 i386/i386 i386/isa X-SVN-Group: stable-10 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/10/sys: amd64/amd64 i386/i386 i386/isa X-SVN-Commit-Revision: 337245 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:12:39 -0000 Author: kib Date: Fri Aug 3 14:12:37 2018 New Revision: 337245 URL: https://svnweb.freebsd.org/changeset/base/337245 Log: MFC r336683: Extend ranges of the critical sections to ensure that context switch code never sees FPU pcb flags not consistent with the hardware state. Modified: stable/10/sys/amd64/amd64/fpu.c stable/10/sys/amd64/amd64/machdep.c stable/10/sys/i386/i386/machdep.c stable/10/sys/i386/isa/npx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/amd64/fpu.c ============================================================================== --- stable/10/sys/amd64/amd64/fpu.c Fri Aug 3 14:08:39 2018 (r337244) +++ stable/10/sys/amd64/amd64/fpu.c Fri Aug 3 14:12:37 2018 (r337245) @@ -741,22 +741,22 @@ fpugetregs(struct thread *td) int max_ext_n, i, owned; pcb = td->td_pcb; + critical_enter(); if ((pcb->pcb_flags & PCB_USERFPUINITDONE) == 0) { bcopy(fpu_initialstate, get_pcb_user_save_pcb(pcb), cpu_max_ext_state_size); get_pcb_user_save_pcb(pcb)->sv_env.en_cw = pcb->pcb_initial_fpucw; fpuuserinited(td); + critical_exit(); return (_MC_FPOWNED_PCB); } - critical_enter(); if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) { fpusave(get_pcb_user_save_pcb(pcb)); owned = _MC_FPOWNED_FPU; } else { owned = _MC_FPOWNED_PCB; } - critical_exit(); if (use_xsave) { /* * Handle partially saved state. @@ -776,6 +776,7 @@ fpugetregs(struct thread *td) *xstate_bv |= bit; } } + critical_exit(); return (owned); } @@ -784,6 +785,7 @@ fpuuserinited(struct thread *td) { struct pcb *pcb; + CRITICAL_ASSERT(td); pcb = td->td_pcb; if (PCB_USER_FPU(pcb)) set_pcb_flags(pcb, @@ -842,26 +844,25 @@ fpusetregs(struct thread *td, struct savefpu *addr, ch addr->sv_env.en_mxcsr &= cpu_mxcsr_mask; pcb = td->td_pcb; + error = 0; critical_enter(); if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) { error = fpusetxstate(td, xfpustate, xfpustate_size); - if (error != 0) { - critical_exit(); - return (error); + if (error == 0) { + bcopy(addr, get_pcb_user_save_td(td), sizeof(*addr)); + fpurestore(get_pcb_user_save_td(td)); + set_pcb_flags(pcb, PCB_FPUINITDONE | + PCB_USERFPUINITDONE); } - bcopy(addr, get_pcb_user_save_td(td), sizeof(*addr)); - fpurestore(get_pcb_user_save_td(td)); - critical_exit(); - set_pcb_flags(pcb, PCB_FPUINITDONE | PCB_USERFPUINITDONE); } else { - critical_exit(); error = fpusetxstate(td, xfpustate, xfpustate_size); - if (error != 0) - return (error); - bcopy(addr, get_pcb_user_save_td(td), sizeof(*addr)); - fpuuserinited(td); + if (error == 0) { + bcopy(addr, get_pcb_user_save_td(td), sizeof(*addr)); + fpuuserinited(td); + } } - return (0); + critical_exit(); + return (error); } /* @@ -1004,6 +1005,7 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx return (0); } pcb = td->td_pcb; + critical_enter(); KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save == get_pcb_user_save_pcb(pcb), ("mangled pcb_save")); ctx->flags = 0; @@ -1014,6 +1016,7 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx pcb->pcb_save = fpu_kern_ctx_savefpu(ctx); set_pcb_flags(pcb, PCB_KERNFPU); clear_pcb_flags(pcb, PCB_FPUINITDONE); + critical_exit(); return (0); } @@ -1029,7 +1032,6 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx critical_enter(); if (curthread == PCPU_GET(fpcurthread)) fpudrop(); - critical_exit(); pcb->pcb_save = ctx->prev; if (pcb->pcb_save == get_pcb_user_save_pcb(pcb)) { if ((pcb->pcb_flags & PCB_USERFPUINITDONE) != 0) { @@ -1044,6 +1046,7 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx clear_pcb_flags(pcb, PCB_FPUINITDONE); KASSERT(!PCB_USER_FPU(pcb), ("unpaired fpu_kern_leave")); } + critical_exit(); return (0); } Modified: stable/10/sys/amd64/amd64/machdep.c ============================================================================== --- stable/10/sys/amd64/amd64/machdep.c Fri Aug 3 14:08:39 2018 (r337244) +++ stable/10/sys/amd64/amd64/machdep.c Fri Aug 3 14:12:37 2018 (r337245) @@ -2380,8 +2380,10 @@ int set_fpregs(struct thread *td, struct fpreg *fpregs) { + critical_enter(); set_fpregs_xmm(fpregs, get_pcb_user_save_td(td)); fpuuserinited(td); + critical_exit(); return (0); } Modified: stable/10/sys/i386/i386/machdep.c ============================================================================== --- stable/10/sys/i386/i386/machdep.c Fri Aug 3 14:08:39 2018 (r337244) +++ stable/10/sys/i386/i386/machdep.c Fri Aug 3 14:12:37 2018 (r337245) @@ -3780,6 +3780,7 @@ int set_fpregs(struct thread *td, struct fpreg *fpregs) { + critical_enter(); #ifdef CPU_ENABLE_SSE if (cpu_fxsr) set_fpregs_xmm((struct save87 *)fpregs, @@ -3791,6 +3792,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs) #ifdef DEV_NPX npxuserinited(td); #endif + critical_exit(); return (0); } Modified: stable/10/sys/i386/isa/npx.c ============================================================================== --- stable/10/sys/i386/isa/npx.c Fri Aug 3 14:08:39 2018 (r337244) +++ stable/10/sys/i386/isa/npx.c Fri Aug 3 14:12:37 2018 (r337245) @@ -1037,14 +1037,15 @@ npxgetregs(struct thread *td) return (_MC_FPOWNED_NONE); pcb = td->td_pcb; + critical_enter(); if ((pcb->pcb_flags & PCB_NPXINITDONE) == 0) { bcopy(npx_initialstate, get_pcb_user_save_pcb(pcb), cpu_max_ext_state_size); SET_FPU_CW(get_pcb_user_save_pcb(pcb), pcb->pcb_initial_npxcw); npxuserinited(td); + critical_exit(); return (_MC_FPOWNED_PCB); } - critical_enter(); if (td == PCPU_GET(fpcurthread)) { fpusave(get_pcb_user_save_pcb(pcb)); #ifdef CPU_ENABLE_SSE @@ -1060,7 +1061,6 @@ npxgetregs(struct thread *td) } else { owned = _MC_FPOWNED_PCB; } - critical_exit(); #ifdef CPU_ENABLE_SSE if (use_xsave) { /* @@ -1085,6 +1085,7 @@ npxgetregs(struct thread *td) } } #endif + critical_exit(); return (owned); } @@ -1093,6 +1094,7 @@ npxuserinited(struct thread *td) { struct pcb *pcb; + CRITICAL_ASSERT(td); pcb = td->td_pcb; if (PCB_USER_FPU(pcb)) pcb->pcb_flags |= PCB_NPXINITDONE; @@ -1156,32 +1158,32 @@ npxsetregs(struct thread *td, union savefpu *addr, cha addr->sv_xmm.sv_env.en_mxcsr &= cpu_mxcsr_mask; #endif pcb = td->td_pcb; + error = 0; critical_enter(); if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) { #ifdef CPU_ENABLE_SSE error = npxsetxstate(td, xfpustate, xfpustate_size); - if (error != 0) { - critical_exit(); - return (error); - } - if (!cpu_fxsr) #endif - fnclex(); /* As in npxdrop(). */ - bcopy(addr, get_pcb_user_save_td(td), sizeof(*addr)); - fpurstor(get_pcb_user_save_td(td)); - critical_exit(); - pcb->pcb_flags |= PCB_NPXUSERINITDONE | PCB_NPXINITDONE; + if (error == 0) { +#ifdef CPU_ENABLE_SSE + if (!cpu_fxsr) +#endif + fnclex(); /* As in npxdrop(). */ + bcopy(addr, get_pcb_user_save_td(td), sizeof(*addr)); + fpurstor(get_pcb_user_save_td(td)); + pcb->pcb_flags |= PCB_NPXUSERINITDONE | PCB_NPXINITDONE; + } } else { - critical_exit(); #ifdef CPU_ENABLE_SSE error = npxsetxstate(td, xfpustate, xfpustate_size); - if (error != 0) - return (error); #endif - bcopy(addr, get_pcb_user_save_td(td), sizeof(*addr)); - npxuserinited(td); + if (error == 0) { + bcopy(addr, get_pcb_user_save_td(td), sizeof(*addr)); + npxuserinited(td); + } } - return (0); + critical_exit(); + return (error); } static void @@ -1350,6 +1352,7 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx return (0); } pcb = td->td_pcb; + critical_enter(); KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save == get_pcb_user_save_pcb(pcb), ("mangled pcb_save")); ctx->flags = 0; @@ -1360,6 +1363,7 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx pcb->pcb_save = fpu_kern_ctx_savefpu(ctx); pcb->pcb_flags |= PCB_KERNNPX; pcb->pcb_flags &= ~PCB_NPXINITDONE; + critical_exit(); return (0); } @@ -1374,7 +1378,6 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx critical_enter(); if (curthread == PCPU_GET(fpcurthread)) npxdrop(); - critical_exit(); pcb->pcb_save = ctx->prev; if (pcb->pcb_save == get_pcb_user_save_pcb(pcb)) { if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) != 0) @@ -1389,6 +1392,7 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx pcb->pcb_flags &= ~PCB_NPXINITDONE; KASSERT(!PCB_USER_FPU(pcb), ("unpaired fpu_kern_leave")); } + critical_exit(); return (0); } From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:13:16 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6202106AFC4; Fri, 3 Aug 2018 14:13:16 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7AF3283499; Fri, 3 Aug 2018 14:13:16 +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 5BDA42179C; Fri, 3 Aug 2018 14:13:16 +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 w73EDGtx069994; Fri, 3 Aug 2018 14:13:16 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EDFkq069991; Fri, 3 Aug 2018 14:13:15 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031413.w73EDFkq069991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:13:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337246 - in stable/10: etc/mtree libexec/tftpd libexec/tftpd/tests X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/10: etc/mtree libexec/tftpd libexec/tftpd/tests X-SVN-Commit-Revision: 337246 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:13:17 -0000 Author: asomers Date: Fri Aug 3 14:13:15 2018 New Revision: 337246 URL: https://svnweb.freebsd.org/changeset/base/337246 Log: MFC r330696, r330709, r330742, r331358 r330696: Add some functional tests for tftpd(8) tftpd(8) is difficult to test in isolation due to its relationship with inetd. Create a test program that mimics the behavior of tftp(1) and inetd(8) and verifies tftpd's response in several different scenarios. These test cases cover all of the basic TFTP protocol, but not the optional parts. PR: 157700 PR: 225996 PR: 226004 PR: 226005 Differential Revision: https://reviews.freebsd.org/D14310 r330709: Commit missing file from r330696 X-MFC-With: 330696 r330742: tftpd: fix the build of tests on i386 after 330696 It's those darn printf format specifiers again Reported by: cy, kibab X-MFC-With: 330696 r331358: tftpd: misc Coverity cleanup in the tests A bunch of unchecked return values from open(2) and read(2) Reported by: Coverity CID: 1386900, 1386911, 1386926, 1386928, 1386932, 1386942 CID: 1386961, 1386979 X-MFC-With: 330696 Added: stable/10/libexec/tftpd/tests/ - copied from r330696, head/libexec/tftpd/tests/ Modified: stable/10/etc/mtree/BSD.tests.dist stable/10/libexec/tftpd/Makefile stable/10/libexec/tftpd/tests/functional.c Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/mtree/BSD.tests.dist ============================================================================== --- stable/10/etc/mtree/BSD.tests.dist Fri Aug 3 14:12:37 2018 (r337245) +++ stable/10/etc/mtree/BSD.tests.dist Fri Aug 3 14:13:15 2018 (r337246) @@ -350,6 +350,8 @@ atf-sh .. .. + tftpd + .. .. sbin dhclient Modified: stable/10/libexec/tftpd/Makefile ============================================================================== --- stable/10/libexec/tftpd/Makefile Fri Aug 3 14:12:37 2018 (r337245) +++ stable/10/libexec/tftpd/Makefile Fri Aug 3 14:13:15 2018 (r337246) @@ -15,4 +15,7 @@ DPADD+= ${LIBWRAP} LDADD+= -lwrap .endif +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include Modified: stable/10/libexec/tftpd/tests/functional.c ============================================================================== --- head/libexec/tftpd/tests/functional.c Fri Mar 9 15:30:20 2018 (r330696) +++ stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:13:15 2018 (r337246) @@ -224,19 +224,17 @@ do { \ static void cleanup(void) { - int fd = -1; - char buffer[80] = {0}; + FILE *f; pid_t pid; - fd = open(pidfile, O_RDONLY); - if (fd < 0) + f = fopen(pidfile, "r"); + if (f == NULL) return; - if (read(fd, buffer, sizeof(buffer)) > 0) { - sscanf(buffer, "%d", &pid); + if (fscanf(f, "%d", &pid) == 1) { kill(pid, SIGTERM); waitpid(pid, NULL, 0); } - close(fd); + fclose(f); unlink(pidfile); } @@ -248,10 +246,10 @@ require_bufeq(const char *expected, ssize_t expected_l ssize_t i; ATF_REQUIRE_EQ_MSG(expected_len, len, - "Expected %ld bytes but got %ld", expected_len, len); + "Expected %zd bytes but got %zd", expected_len, len); for (i = 0; i < len; i++) { ATF_REQUIRE_EQ_MSG(actual[i], expected[i], - "Expected %#hhx at position %ld; got %hhx instead", + "Expected %#hhx at position %zd; got %hhx instead", expected[i], i, actual[i]); } } @@ -696,6 +694,7 @@ TFTPD_TC_DEFINE(w_flag,, w_flag = 1;) atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); + ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); close(fd); require_bufeq(contents, contents_len, buffer, r); @@ -733,6 +732,7 @@ TFTPD_TC_DEFINE(wrq_dropped_ack,) atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); + ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); close(fd); require_bufeq((const char*)contents, 768, buffer, r); @@ -766,6 +766,7 @@ TFTPD_TC_DEFINE(wrq_dropped_data,) atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); + ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); close(fd); require_bufeq(contents, contents_len, buffer, r); @@ -800,6 +801,7 @@ TFTPD_TC_DEFINE(wrq_duped_data,) atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); + ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); close(fd); require_bufeq((const char*)contents, 768, buffer, r); @@ -867,6 +869,7 @@ TFTPD_TC_DEFINE(wrq_medium,) atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); + ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); close(fd); require_bufeq((const char*)contents, 768, buffer, r); @@ -900,6 +903,7 @@ TFTPD_TC_DEFINE(wrq_netascii,) atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("unix.txt", O_RDONLY); + ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); close(fd); require_bufeq(expected, sizeof(expected), buffer, r); @@ -940,6 +944,7 @@ TFTPD_TC_DEFINE(wrq_small,) atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); + ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); close(fd); require_bufeq(contents, contents_len, buffer, r); From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:17:14 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E724106B13E; Fri, 3 Aug 2018 14:17:14 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AF33883EFB; Fri, 3 Aug 2018 14:17:13 +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 433B8217A3; Fri, 3 Aug 2018 14:17:13 +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 w73EHCmS070284; Fri, 3 Aug 2018 14:17:12 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EHCjw070280; Fri, 3 Aug 2018 14:17:12 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031417.w73EHCjw070280@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:17:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337247 - in stable/10: libexec/tftpd libexec/tftpd/tests usr.bin/tftp X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/10: libexec/tftpd libexec/tftpd/tests usr.bin/tftp X-SVN-Commit-Revision: 337247 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:17:14 -0000 Author: asomers Date: Fri Aug 3 14:17:11 2018 New Revision: 337247 URL: https://svnweb.freebsd.org/changeset/base/337247 Log: MFC r330710: tftpd: Flush files as soon as they are fully received On an RRQ, tftpd doesn't exit as soon as it's finished receiving a file. Instead, it waits five seconds just in case the client didn't receive the server's last ACK and decides to resend the final DATA packet. Unfortunately, this created a 5 second delay from when the client thinks it's done sending the file, and when the file is available for other processes. Fix this bug by closing the file as soon as receipt is finished. PR: 157700 Reported by: Barry Mishler Modified: stable/10/libexec/tftpd/tests/functional.c stable/10/libexec/tftpd/tftp-transfer.c stable/10/libexec/tftpd/tftpd.c stable/10/usr.bin/tftp/tftp.c Modified: stable/10/libexec/tftpd/tests/functional.c ============================================================================== --- stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:13:15 2018 (r337246) +++ stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:17:11 2018 (r337247) @@ -692,7 +692,6 @@ TFTPD_TC_DEFINE(w_flag,, w_flag = 1;) send_data(1, contents, contents_len); recv_ack(1); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); @@ -730,7 +729,6 @@ TFTPD_TC_DEFINE(wrq_dropped_ack,) send_data(2, (const char*)&contents[128], 256); recv_ack(2); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); @@ -764,7 +762,6 @@ TFTPD_TC_DEFINE(wrq_dropped_data,) send_data(1, contents, contents_len); recv_ack(1); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); @@ -799,7 +796,6 @@ TFTPD_TC_DEFINE(wrq_duped_data,) send_data(2, (const char*)&contents[128], 256); recv_ack(2); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); @@ -867,7 +863,6 @@ TFTPD_TC_DEFINE(wrq_medium,) send_data(2, (const char*)&contents[128], 256); recv_ack(2); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); @@ -894,14 +889,13 @@ TFTPD_TC_DEFINE(wrq_netascii,) fd = open("unix.txt", O_RDWR | O_CREAT, 0666); ATF_REQUIRE(fd >= 0); close(fd); - contents_len = strlen(contents) + 1; + contents_len = sizeof(contents); SEND_WRQ("unix.txt", "netascii"); recv_ack(0); send_data(1, contents, contents_len); recv_ack(1); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("unix.txt", O_RDONLY); ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); @@ -942,7 +936,6 @@ TFTPD_TC_DEFINE(wrq_small,) send_data(1, contents, contents_len); recv_ack(1); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); ATF_REQUIRE(fd >= 0); r = read(fd, buffer, sizeof(buffer)); Modified: stable/10/libexec/tftpd/tftp-transfer.c ============================================================================== --- stable/10/libexec/tftpd/tftp-transfer.c Fri Aug 3 14:13:15 2018 (r337246) +++ stable/10/libexec/tftpd/tftp-transfer.c Fri Aug 3 14:17:11 2018 (r337247) @@ -302,6 +302,8 @@ send_ack: gettimeofday(&(ts->tstop), NULL); } while (n_data == segsize); + write_close(); + /* Don't do late packet management for the client implementation */ if (acting_as_client) return; Modified: stable/10/libexec/tftpd/tftpd.c ============================================================================== --- stable/10/libexec/tftpd/tftpd.c Fri Aug 3 14:13:15 2018 (r337246) +++ stable/10/libexec/tftpd/tftpd.c Fri Aug 3 14:17:11 2018 (r337247) @@ -821,7 +821,6 @@ tftp_recvfile(int peer, const char *mode) block = 0; tftp_receive(peer, &block, &ts, NULL, 0); - write_close(); gettimeofday(&now2, NULL); if (debug&DEBUG_SIMPLE) { Modified: stable/10/usr.bin/tftp/tftp.c ============================================================================== --- stable/10/usr.bin/tftp/tftp.c Fri Aug 3 14:13:15 2018 (r337246) +++ stable/10/usr.bin/tftp/tftp.c Fri Aug 3 14:17:11 2018 (r337247) @@ -263,7 +263,6 @@ recvfile(int peer, char *port, int fd, char *name, cha tftp_receive(peer, &block, &tftp_stats, rp, n); } - write_close(); if (tftp_stats.amount > 0) printstats("Received", verbose, &tftp_stats); return; From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:18:03 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 14F9F106B1E8; Fri, 3 Aug 2018 14:18:03 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BDD3D84232; Fri, 3 Aug 2018 14:18:02 +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 A064B217A6; Fri, 3 Aug 2018 14:18:02 +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 w73EI25M070452; Fri, 3 Aug 2018 14:18:02 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EI26n070450; Fri, 3 Aug 2018 14:18:02 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031418.w73EI26n070450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337248 - in stable/10/libexec/tftpd: . tests X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/10/libexec/tftpd: . tests X-SVN-Commit-Revision: 337248 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:18:03 -0000 Author: asomers Date: Fri Aug 3 14:18:02 2018 New Revision: 337248 URL: https://svnweb.freebsd.org/changeset/base/337248 Log: MFC r330718: tftpd: Verify world-writability for WRQ when using relative paths tftpd(8) says that files may only be written if they already exist and are publicly writable. tftpd.c verifies that a file is publicly writable if it uses an absolute pathname. However, if the pathname is relative, that check is skipped. Fix it. Note that this is not a security vulnerability, because the transfer ultimately doesn't work unless the file already exists and is owned by user nobody. Also, this bug does not affect the default configuration, because the default uses the "-s" option which makes all pathnames absolute. PR: 226004 Modified: stable/10/libexec/tftpd/tests/functional.c stable/10/libexec/tftpd/tftpd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/libexec/tftpd/tests/functional.c ============================================================================== --- stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:17:11 2018 (r337247) +++ stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:18:02 2018 (r337248) @@ -348,6 +348,10 @@ setup(struct sockaddr_storage *to, uint16_t idx) ATF_REQUIRE((client_s = socket(protocol, SOCK_DGRAM, 0)) > 0); break; } + + /* Clear the client's umask. Test cases will specify exact modes */ + umask(0000); + return (client_s); } @@ -713,7 +717,7 @@ TFTPD_TC_DEFINE(wrq_dropped_ack,) for (i = 0; i < nitems(contents); i++) contents[i] = i; - fd = open("medium.txt", O_RDWR | O_CREAT, 0644); + fd = open("medium.txt", O_RDWR | O_CREAT, 0666); ATF_REQUIRE(fd >= 0); close(fd); @@ -747,7 +751,7 @@ TFTPD_TC_DEFINE(wrq_dropped_data,) size_t contents_len; char buffer[1024]; - fd = open("small.txt", O_RDWR | O_CREAT, 0644); + fd = open("small.txt", O_RDWR | O_CREAT, 0666); ATF_REQUIRE(fd >= 0); close(fd); contents_len = strlen(contents) + 1; @@ -783,7 +787,7 @@ TFTPD_TC_DEFINE(wrq_duped_data,) for (i = 0; i < nitems(contents); i++) contents[i] = i; - fd = open("medium.txt", O_RDWR | O_CREAT, 0644); + fd = open("medium.txt", O_RDWR | O_CREAT, 0666); ATF_REQUIRE(fd >= 0); close(fd); @@ -833,7 +837,8 @@ TFTPD_TC_DEFINE(wrq_eaccess_world_readable,) close(fd); SEND_WRQ("empty.txt", "octet"); - atf_tc_expect_fail("PR 226004 with relative pathnames, tftpd doesn't validate world writability"); + atf_tc_expect_fail("PR 225996 tftpd doesn't abort on a WRQ access " + "violation"); RECV_ERROR(2, "Access violation"); } Modified: stable/10/libexec/tftpd/tftpd.c ============================================================================== --- stable/10/libexec/tftpd/tftpd.c Fri Aug 3 14:17:11 2018 (r337247) +++ stable/10/libexec/tftpd/tftpd.c Fri Aug 3 14:18:02 2018 (r337248) @@ -741,8 +741,12 @@ validate_access(int peer, char **filep, int mode) dirp->name, filename); if (stat(pathname, &stbuf) == 0 && (stbuf.st_mode & S_IFMT) == S_IFREG) { - if ((stbuf.st_mode & S_IROTH) != 0) { - break; + if (mode == RRQ) { + if ((stbuf.st_mode & S_IROTH) != 0) + break; + } else { + if ((stbuf.st_mode & S_IWOTH) != 0) + break; } err = EACCESS; } @@ -750,6 +754,8 @@ validate_access(int peer, char **filep, int mode) if (dirp->name != NULL) *filep = filename = pathname; else if (mode == RRQ) + return (err); + else if (err != ENOTFOUND || !create_new) return (err); } From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:19:10 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6CBBC106B2CF; Fri, 3 Aug 2018 14:19:10 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 220E984566; Fri, 3 Aug 2018 14:19:10 +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 0344D217A8; Fri, 3 Aug 2018 14:19:10 +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 w73EJ9Bj070775; Fri, 3 Aug 2018 14:19:09 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EJ9Z8070773; Fri, 3 Aug 2018 14:19:09 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031419.w73EJ9Z8070773@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:19:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337249 - in stable/10/libexec/tftpd: . tests X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/10/libexec/tftpd: . tests X-SVN-Commit-Revision: 337249 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:19:10 -0000 Author: asomers Date: Fri Aug 3 14:19:09 2018 New Revision: 337249 URL: https://svnweb.freebsd.org/changeset/base/337249 Log: MFC r330719: tftpd: Abort on an WRQ access violation On a WRQ (write request) tftpd checks whether the client has access permission for the file in question. If not, then the write is prevented. However, tftpd doesn't reply with an ERROR packet, nor does it abort. Instead, it tries to receive the packet anyway. The symptom is slightly different depending on the nature of the error. If the target file is nonexistent and tftpd lacks permission to create it, then tftpd will willingly receive the file, but not write it anywhere. If the file exists but is not writable, then tftpd will fail to ACK to WRQ. PR: 225996 Modified: stable/10/libexec/tftpd/tests/functional.c stable/10/libexec/tftpd/tftpd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/libexec/tftpd/tests/functional.c ============================================================================== --- stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:18:02 2018 (r337248) +++ stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:19:09 2018 (r337249) @@ -819,8 +819,6 @@ TFTPD_TC_DEFINE(wrq_eaccess,) close(fd); SEND_WRQ("empty.txt", "octet"); - atf_tc_expect_fail("PR 225996 tftpd doesn't abort on a WRQ access " - "violation"); RECV_ERROR(2, "Access violation"); } @@ -837,8 +835,6 @@ TFTPD_TC_DEFINE(wrq_eaccess_world_readable,) close(fd); SEND_WRQ("empty.txt", "octet"); - atf_tc_expect_fail("PR 225996 tftpd doesn't abort on a WRQ access " - "violation"); RECV_ERROR(2, "Access violation"); } @@ -915,8 +911,6 @@ TFTPD_TC_DEFINE(wrq_netascii,) TFTPD_TC_DEFINE(wrq_nonexistent,) { SEND_WRQ("nonexistent.txt", "octet"); - atf_tc_expect_fail("PR 225996 tftpd doesn't abort on a WRQ access " - "violation"); RECV_ERROR(1, "File not found"); } Modified: stable/10/libexec/tftpd/tftpd.c ============================================================================== --- stable/10/libexec/tftpd/tftpd.c Fri Aug 3 14:18:02 2018 (r337248) +++ stable/10/libexec/tftpd/tftpd.c Fri Aug 3 14:19:09 2018 (r337249) @@ -543,6 +543,10 @@ tftp_wrq(int peer, char *recvbuffer, ssize_t size) filename, errtomsg(ecode)); } + if (ecode) { + send_error(peer, ecode); + exit(1); + } tftp_recvfile(peer, mode); exit(0); } From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:19:57 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C9D2106B35C; Fri, 3 Aug 2018 14:19:57 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 12D8D846C8; Fri, 3 Aug 2018 14:19:57 +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 E7A70217AA; Fri, 3 Aug 2018 14:19:56 +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 w73EJulC071020; Fri, 3 Aug 2018 14:19:56 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EJuAD071018; Fri, 3 Aug 2018 14:19:56 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031419.w73EJuAD071018@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:19:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337250 - in stable/10/libexec/tftpd: . tests X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/10/libexec/tftpd: . tests X-SVN-Commit-Revision: 337250 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:19:57 -0000 Author: asomers Date: Fri Aug 3 14:19:56 2018 New Revision: 337250 URL: https://svnweb.freebsd.org/changeset/base/337250 Log: MFC r330720: tftpd: reject unknown opcodes If tftpd receives a command with an unknown opcode, it simply exits 1. It doesn't send an ERROR packet, and the client will hang waiting for one. Fix it. PR: 226005 Modified: stable/10/libexec/tftpd/tests/functional.c stable/10/libexec/tftpd/tftpd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/libexec/tftpd/tests/functional.c ============================================================================== --- stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:19:09 2018 (r337249) +++ stable/10/libexec/tftpd/tests/functional.c Fri Aug 3 14:19:56 2018 (r337250) @@ -675,7 +675,6 @@ TFTPD_TC_DEFINE(unknown_opcode,) { /* Looks like an RRQ or WRQ request, but with a bad opcode */ SEND_STR("\0\007foo.txt\0octet\0"); - atf_tc_expect_timeout("PR 226005 tftpd ignores bad opcodes but doesn't reject them"); RECV_ERROR(4, "Illegal TFTP operation"); } Modified: stable/10/libexec/tftpd/tftpd.c ============================================================================== --- stable/10/libexec/tftpd/tftpd.c Fri Aug 3 14:19:09 2018 (r337249) +++ stable/10/libexec/tftpd/tftpd.c Fri Aug 3 14:19:56 2018 (r337250) @@ -419,8 +419,7 @@ main(int argc, char *argv[]) "%s read access denied", peername); exit(1); } - } - if (tp->th_opcode == WRQ) { + } else if (tp->th_opcode == WRQ) { if (allow_wo) tftp_wrq(peer, tp->th_stuff, n - 1); else { @@ -428,7 +427,8 @@ main(int argc, char *argv[]) "%s write access denied", peername); exit(1); } - } + } else + send_error(peer, EBADOP); exit(1); } From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:22:17 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73A53106B65F; Fri, 3 Aug 2018 14:22:17 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 267E584D2E; Fri, 3 Aug 2018 14:22:17 +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 07B2F2192A; Fri, 3 Aug 2018 14:22:17 +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 w73EMG0a076152; Fri, 3 Aug 2018 14:22:16 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EMGC5076151; Fri, 3 Aug 2018 14:22:16 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031422.w73EMGC5076151@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:22:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337251 - stable/10/sys/security/audit X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/10/sys/security/audit X-SVN-Commit-Revision: 337251 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:22:17 -0000 Author: asomers Date: Fri Aug 3 14:22:16 2018 New Revision: 337251 URL: https://svnweb.freebsd.org/changeset/base/337251 Log: MFC r334296: Fix "Bad tailq" panic when auditing auditon(A_SETCLASS, ...) Due to an oversight in r195280, auditon(A_SETCLASS, ...) would cause a tailq element to get added to the tailq twice, resulting in a circular tailq. This panics when INVARIANTS are on. Differential Revision: https://reviews.freebsd.org/D15381 Modified: stable/10/sys/security/audit/audit_bsm.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/security/audit/audit_bsm.c ============================================================================== --- stable/10/sys/security/audit/audit_bsm.c Fri Aug 3 14:19:56 2018 (r337250) +++ stable/10/sys/security/audit/audit_bsm.c Fri Aug 3 14:22:16 2018 (r337251) @@ -418,7 +418,6 @@ audit_sys_auditon(struct audit_record *ar, struct au_r break; case A_SETCLASS: - kau_write(rec, tok); tok = au_to_arg32(2, "setclass:ec_event", ar->ar_arg_auditon.au_evclass.ec_number); kau_write(rec, tok); From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:23:02 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8437C106B6F1; Fri, 3 Aug 2018 14:23:02 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 30EE584EE7; Fri, 3 Aug 2018 14:23:02 +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 120952193F; Fri, 3 Aug 2018 14:23:02 +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 w73EN1QE076236; Fri, 3 Aug 2018 14:23:01 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EN1ok076235; Fri, 3 Aug 2018 14:23:01 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031423.w73EN1ok076235@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:23:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337252 - stable/10/contrib/openbsm/libbsm X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/10/contrib/openbsm/libbsm X-SVN-Commit-Revision: 337252 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:23:02 -0000 Author: asomers Date: Fri Aug 3 14:23:01 2018 New Revision: 337252 URL: https://svnweb.freebsd.org/changeset/base/337252 Log: MFC r334390: au_read_rec(3): correct return value in man page Submitted by: aniketp Reviewed by: csjp (earlier version) Sponsored by: Google, Inc. (GSoC 2018) Differential Revision: https://reviews.freebsd.org/D15618 Modified: stable/10/contrib/openbsm/libbsm/au_io.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/openbsm/libbsm/au_io.3 ============================================================================== --- stable/10/contrib/openbsm/libbsm/au_io.3 Fri Aug 3 14:22:16 2018 (r337251) +++ stable/10/contrib/openbsm/libbsm/au_io.3 Fri Aug 3 14:23:01 2018 (r337252) @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 4, 2009 +.Dd May 30, 2018 .Dt AU_IO 3 .Os .Sh NAME @@ -129,14 +129,14 @@ would be used to free the record buffer. Finally, the source stream would be closed by a call to .Xr fclose 3 . .Sh RETURN VALUES -The +On success, .Fn au_fetch_tok -and +returns 0 while .Fn au_read_rec -functions -return 0 on success, or \-1 on failure along with additional error information -returned via -.Va errno . +returns the number of bytes read. +Both functions return \-1 on failure with +.Va errno +set appropriately. .Sh SEE ALSO .Xr free 3 , .Xr libbsm 3 From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:23:54 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B329F106B7A7; Fri, 3 Aug 2018 14:23:53 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 388FA8539B; Fri, 3 Aug 2018 14:23:52 +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 37AE721940; Fri, 3 Aug 2018 14:23:52 +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 w73ENqH4076326; Fri, 3 Aug 2018 14:23:52 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73ENq64076325; Fri, 3 Aug 2018 14:23:52 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031423.w73ENq64076325@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:23:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337253 - stable/10/share/man/man4 X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/10/share/man/man4 X-SVN-Commit-Revision: 337253 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:23:54 -0000 Author: asomers Date: Fri Aug 3 14:23:51 2018 New Revision: 337253 URL: https://svnweb.freebsd.org/changeset/base/337253 Log: MFC r334394: auditpipe(4): fix some ioctl arguments in the man page Fix the argument types for the AUDITPIPE_[GS]ET_PRESELECT_(NA)?FLAGS ioctls. Also, fix some grammar. [skip ci] PR: 226713 Submitted by: aniketp Sponsored by: Google, Inc. (GSoC 2018) Differential Revision: https://reviews.freebsd.org/D15620 Modified: stable/10/share/man/man4/auditpipe.4 Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/auditpipe.4 ============================================================================== --- stable/10/share/man/man4/auditpipe.4 Fri Aug 3 14:23:01 2018 (r337252) +++ stable/10/share/man/man4/auditpipe.4 Fri Aug 3 14:23:51 2018 (r337253) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 5, 2006 +.Dd May 30, 2018 .Dt AUDITPIPE 4 .Os .Sh NAME @@ -154,7 +154,7 @@ These flags correspond to the field in .Xr audit_control 5 . The ioctl argument should be of type -.Vt u_int . +.Vt au_mask_t . .It Dv AUDITPIPE_SET_PRESELECT_FLAGS Set the current default preselection flags for attributable events on the pipe. @@ -163,7 +163,7 @@ These flags correspond to the field in .Xr audit_control 5 . The ioctl argument should be of type -.Vt u_int . +.Vt au_mask_t . .It Dv AUDITPIPE_GET_PRESELECT_NAFLAGS Retrieve the current default preselection flags for non-attributable events on the pipe. @@ -172,7 +172,7 @@ These flags correspond to the field in .Xr audit_control 5 . The ioctl argument should be of type -.Vt u_int . +.Vt au_mask_t . .It Dv AUDITPIPE_SET_PRESELECT_NAFLAGS Set the current default preselection flags for non-attributable events on the pipe. @@ -181,7 +181,7 @@ These flags correspond to the field in .Xr audit_control 5 . The ioctl argument should be of type -.Vt u_int . +.Vt au_mask_t . .It Dv AUDITPIPE_GET_PRESELECT_AUID Query the current preselection masks for a specific auid on the pipe. The ioctl argument should be of type @@ -245,7 +245,7 @@ manual page for information on audit-related bugs and .Pp The configurable preselection mechanism mirrors the selection model present for the global audit trail. -It might be desirable to provided a more flexible selection model. +It might be desirable to provide a more flexible selection model. .Pp The per-pipe audit event queue is fifo, with drops occurring if either the user thread provides in sufficient for the record on the queue head, or on From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:25:16 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9ED86106B8D9; Fri, 3 Aug 2018 14:25:16 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48CFC8572D; Fri, 3 Aug 2018 14:25:16 +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 295AB21943; Fri, 3 Aug 2018 14:25:16 +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 w73EPGkl076460; Fri, 3 Aug 2018 14:25:16 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EPGwl076459; Fri, 3 Aug 2018 14:25:16 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031425.w73EPGwl076459@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:25:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337254 - stable/10/lib/libutil X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/10/lib/libutil X-SVN-Commit-Revision: 337254 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:25:16 -0000 Author: asomers Date: Fri Aug 3 14:25:15 2018 New Revision: 337254 URL: https://svnweb.freebsd.org/changeset/base/337254 Log: MFC r334547: pty.3: Add a HISTORY section These functions were first added in 4.3 BSD-Reno, according to http://unix.superglobalmegacorp.com/ and the CSRG svn repository. Reviewed by: bcr, bjk Differential Revision: https://reviews.freebsd.org/D15652 Modified: stable/10/lib/libutil/pty.3 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libutil/pty.3 ============================================================================== --- stable/10/lib/libutil/pty.3 Fri Aug 3 14:23:51 2018 (r337253) +++ stable/10/lib/libutil/pty.3 Fri Aug 3 14:25:15 2018 (r337254) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" " -.Dd November 11, 2015 +.Dd June 2, 2018 .Dt PTY 3 .Os .Sh NAME @@ -143,3 +143,18 @@ may set it to any value as described for .Xr pty 4 , .Xr termios 4 , .Xr group 5 +.Sh HISTORY +The +.Fn openpty +and +.Fn forkpty +functions first appeared in +.Bx 4.3 Reno. +.Sh BUGS +.Fn openpty +writes the slave terminal's name to +.Fa name , +but does not check that sufficient space is available. +It is advisable to use +.Xr ptsname 3 +instead. From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:36:31 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9C368106BDA2; Fri, 3 Aug 2018 14:36:31 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E13E860C5; Fri, 3 Aug 2018 14:36:31 +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 1BBC721B00; Fri, 3 Aug 2018 14:36:31 +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 w73EaUs9081485; Fri, 3 Aug 2018 14:36:30 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EaUCi081481; Fri, 3 Aug 2018 14:36:30 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031436.w73EaUCi081481@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:36:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337256 - in stable/10: contrib/openbsm/bin/praudit etc/mtree usr.sbin/praudit usr.sbin/praudit/tests X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/10: contrib/openbsm/bin/praudit etc/mtree usr.sbin/praudit usr.sbin/praudit/tests X-SVN-Commit-Revision: 337256 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:36:32 -0000 Author: asomers Date: Fri Aug 3 14:36:29 2018 New Revision: 337256 URL: https://svnweb.freebsd.org/changeset/base/337256 Log: MFC r335287, r335290 r335287: praudit(1): return 0 on success Cherry pick https://github.com/openbsm/openbsm/commit/ed83bb3 Submitted by: aniketp Reviewed by: rwatson, 0mp Obtained from: OpenBSM Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/openbsm/openbsm/pull/32 r335290: praudit(1): add tests Submitted by: aniketp X-MFC-With: 335287 Sponsored by: Google, Inc. (GSoC 2018) Differential Revision: https://reviews.freebsd.org/D15751 Added: stable/10/usr.sbin/praudit/tests/ - copied from r335290, head/usr.sbin/praudit/tests/ Modified: stable/10/contrib/openbsm/bin/praudit/praudit.1 stable/10/contrib/openbsm/bin/praudit/praudit.c stable/10/etc/mtree/BSD.tests.dist stable/10/usr.sbin/praudit/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/openbsm/bin/praudit/praudit.1 ============================================================================== --- stable/10/contrib/openbsm/bin/praudit/praudit.1 Fri Aug 3 14:27:28 2018 (r337255) +++ stable/10/contrib/openbsm/bin/praudit/praudit.1 Fri Aug 3 14:36:29 2018 (r337256) @@ -25,7 +25,7 @@ .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 4, 2009 +.Dd June 11, 2018 .Dt PRAUDIT 1 .Os .Sh NAME @@ -88,6 +88,8 @@ Events are displayed as per their descriptions given i .Pa /etc/security/audit_event ; UIDs and GIDs are expanded to their names; dates and times are displayed in human-readable format. +.Sh EXIT STATUS +.Ex -std .Sh FILES .Bl -tag -width ".Pa /etc/security/audit_control" -compact .It Pa /etc/security/audit_class Modified: stable/10/contrib/openbsm/bin/praudit/praudit.c ============================================================================== --- stable/10/contrib/openbsm/bin/praudit/praudit.c Fri Aug 3 14:27:28 2018 (r337255) +++ stable/10/contrib/openbsm/bin/praudit/praudit.c Fri Aug 3 14:36:29 2018 (r337256) @@ -169,5 +169,5 @@ main(int argc, char **argv) if (oflags & AU_OFLAG_XML) au_print_xml_footer(stdout); - return (1); + return (0); } Modified: stable/10/etc/mtree/BSD.tests.dist ============================================================================== --- stable/10/etc/mtree/BSD.tests.dist Fri Aug 3 14:27:28 2018 (r337255) +++ stable/10/etc/mtree/BSD.tests.dist Fri Aug 3 14:36:29 2018 (r337256) @@ -682,6 +682,8 @@ .. nmtree .. + praudit + .. pw .. rpcbind Modified: stable/10/usr.sbin/praudit/Makefile ============================================================================== --- stable/10/usr.sbin/praudit/Makefile Fri Aug 3 14:27:28 2018 (r337255) +++ stable/10/usr.sbin/praudit/Makefile Fri Aug 3 14:36:29 2018 (r337256) @@ -13,4 +13,7 @@ WARNS?= 3 DPADD= ${LIBBSM} LDADD= -lbsm +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:37:24 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B391106BE3C; Fri, 3 Aug 2018 14:37:24 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D4F428622D; Fri, 3 Aug 2018 14:37:23 +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 9CFCF21B01; Fri, 3 Aug 2018 14:37:23 +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 w73EbN91081579; Fri, 3 Aug 2018 14:37:23 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EbNXg081578; Fri, 3 Aug 2018 14:37:23 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031437.w73EbNXg081578@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:37:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337257 - stable/10/contrib/openbsm/bin/auditd X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/10/contrib/openbsm/bin/auditd X-SVN-Commit-Revision: 337257 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:37:24 -0000 Author: asomers Date: Fri Aug 3 14:37:23 2018 New Revision: 337257 URL: https://svnweb.freebsd.org/changeset/base/337257 Log: MFC r335899: auditd(8): register signal handlers interrutibly auditd_wait_for_events() relies on read(2) being interrupted by signals, but it registers signal handlers with signal(3), which sets SA_RESTART. That breaks asynchronous signal handling. It means that signals don't actually get handled until after an audit(8) trigger is received. Symptoms include: * Sending SIGTERM to auditd doesn't kill it right away; you must send SIGTERM and then send a trigger with auditon(2). * Same with SIGHUP * Zombie child processes don't get reaped until auditd receives a trigger sent by auditon. This includes children created by expiring audit trails at auditd startup. Fix by using sigaction(2) instead of signal(3). Cherry pick https://github.com/openbsm/openbsm/commit/d060887 PR: 229381 Reviewed by: cem Obtained from: OpenBSM Differential Revision: https://github.com/openbsm/openbsm/pull/36 Modified: stable/10/contrib/openbsm/bin/auditd/auditd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/openbsm/bin/auditd/auditd.c ============================================================================== --- stable/10/contrib/openbsm/bin/auditd/auditd.c Fri Aug 3 14:36:29 2018 (r337256) +++ stable/10/contrib/openbsm/bin/auditd/auditd.c Fri Aug 3 14:37:23 2018 (r337257) @@ -415,27 +415,35 @@ close_all(void) static int register_daemon(void) { + struct sigaction action; FILE * pidfile; int fd; pid_t pid; /* Set up the signal hander. */ - if (signal(SIGTERM, auditd_relay_signal) == SIG_ERR) { + action.sa_handler = auditd_relay_signal; + /* + * sa_flags must not include SA_RESTART, so that read(2) will be + * interruptible in auditd_wait_for_events + */ + action.sa_flags = 0; + sigemptyset(&action.sa_mask); + if (sigaction(SIGTERM, &action, NULL) != 0) { auditd_log_err( "Could not set signal handler for SIGTERM"); fail_exit(); } - if (signal(SIGCHLD, auditd_relay_signal) == SIG_ERR) { + if (sigaction(SIGCHLD, &action, NULL) != 0) { auditd_log_err( "Could not set signal handler for SIGCHLD"); fail_exit(); } - if (signal(SIGHUP, auditd_relay_signal) == SIG_ERR) { + if (sigaction(SIGHUP, &action, NULL) != 0) { auditd_log_err( "Could not set signal handler for SIGHUP"); fail_exit(); } - if (signal(SIGALRM, auditd_relay_signal) == SIG_ERR) { + if (sigaction(SIGALRM, &action, NULL) != 0) { auditd_log_err( "Could not set signal handler for SIGALRM"); fail_exit(); From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:45:54 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 907B7106C226; Fri, 3 Aug 2018 14:45:54 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 41DE3868F2; Fri, 3 Aug 2018 14:45:54 +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 2171521CAC; Fri, 3 Aug 2018 14:45:54 +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 w73Ejsg0086935; Fri, 3 Aug 2018 14:45:54 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EjraV086933; Fri, 3 Aug 2018 14:45:53 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031445.w73EjraV086933@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:45:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337258 - stable/10/sys/kern X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/10/sys/kern X-SVN-Commit-Revision: 337258 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:45:54 -0000 Author: asomers Date: Fri Aug 3 14:45:53 2018 New Revision: 337258 URL: https://svnweb.freebsd.org/changeset/base/337258 Log: MFC r336205: Don't acquire evclass_lock with a spinlock held When the "pc" audit class is enabled and auditd is running, witness will panic during thread exit because au_event_class tries to lock an rwlock while holding a spinlock acquired upstack by thread_exit. To fix this, move AUDIT_SYSCALL_EXIT futher upstack, before the spinlock is acquired. Of thread_exit's 16 callers, it's only necessary to call AUDIT_SYSCALL_EXIT from two, exit1 (for exiting processes) and kern_thr_exit (for exiting threads). The other callers are all kernel threads, which needen't call AUDIT_SYSCALL_EXIT because since they can't make syscalls there will be nothing to audit. And exit1 already does call AUDIT_SYSCALL_EXIT, making the second call in thread_exit redundant for that case. PR: 228444 Reported by: aniketp Reviewed by: aniketp, kib Differential Revision: https://reviews.freebsd.org/D16210 Modified: stable/10/sys/kern/kern_thr.c stable/10/sys/kern/kern_thread.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_thr.c ============================================================================== --- stable/10/sys/kern/kern_thr.c Fri Aug 3 14:37:23 2018 (r337257) +++ stable/10/sys/kern/kern_thr.c Fri Aug 3 14:45:53 2018 (r337258) @@ -362,6 +362,11 @@ kern_thr_exit(struct thread *td) racct_sub(p, RACCT_NTHR, 1); tdsigcleanup(td); umtx_thread_exit(td); + +#ifdef AUDIT + AUDIT_SYSCALL_EXIT(0, td); +#endif + PROC_SLOCK(p); thread_stopped(p); thread_exit(); Modified: stable/10/sys/kern/kern_thread.c ============================================================================== --- stable/10/sys/kern/kern_thread.c Fri Aug 3 14:37:23 2018 (r337257) +++ stable/10/sys/kern/kern_thread.c Fri Aug 3 14:45:53 2018 (r337258) @@ -418,9 +418,6 @@ thread_exit(void) SDT_PROBE0(proc, , , lwp__exit); KASSERT(TAILQ_EMPTY(&td->td_sigqueue.sq_list), ("signal pending")); -#ifdef AUDIT - AUDIT_SYSCALL_EXIT(0, td); -#endif /* * drop FPU & debug register state storage, or any other * architecture specific resources that From owner-svn-src-stable-10@freebsd.org Fri Aug 3 14:47:48 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 47572106C2A2; Fri, 3 Aug 2018 14:47:48 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ED10A86A57; Fri, 3 Aug 2018 14:47:47 +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 CA5B821CAE; Fri, 3 Aug 2018 14:47:47 +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 w73EllQ7087100; Fri, 3 Aug 2018 14:47:47 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73EllVw087099; Fri, 3 Aug 2018 14:47:47 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201808031447.w73EllVw087099@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 3 Aug 2018 14:47:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r337259 - stable/10/sys/security/audit X-SVN-Group: stable-10 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/10/sys/security/audit X-SVN-Commit-Revision: 337259 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-10@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 14:47:48 -0000 Author: asomers Date: Fri Aug 3 14:47:47 2018 New Revision: 337259 URL: https://svnweb.freebsd.org/changeset/base/337259 Log: MFC r336319: auditon(2): fix A_SETPOLICY with 64-bit values A_SETPOLICY is supposed to work with either 64 or 32-bit values, but due to a typo the 64-bit version has never worked correctly. Submitted by: aniketp Reviewed by: asomers, cem Sponsored by: Google, Inc. (GSoC 2018) Differential Revision: https://reviews.freebsd.org/D16222 Modified: stable/10/sys/security/audit/audit_syscalls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/security/audit/audit_syscalls.c ============================================================================== --- stable/10/sys/security/audit/audit_syscalls.c Fri Aug 3 14:45:53 2018 (r337258) +++ stable/10/sys/security/audit/audit_syscalls.c Fri Aug 3 14:47:47 2018 (r337259) @@ -241,7 +241,7 @@ sys_auditon(struct thread *td, struct auditon_args *ua case A_OLDSETPOLICY: case A_SETPOLICY: if (uap->length == sizeof(udata.au_policy64)) { - if (udata.au_policy & (~AUDIT_CNT|AUDIT_AHLT| + if (udata.au_policy & ~(AUDIT_CNT|AUDIT_AHLT| AUDIT_ARGV|AUDIT_ARGE)) return (EINVAL); audit_fail_stop = ((udata.au_policy64 & AUDIT_CNT) ==