From owner-dev-commits-src-all@freebsd.org Tue Sep 14 13:10:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 263D86694E5; Tue, 14 Sep 2021 13:10:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H83cg0B4pz4mp3; Tue, 14 Sep 2021 13:10:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C2BE71B13C; Tue, 14 Sep 2021 13:10:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18EDAgIa039604; Tue, 14 Sep 2021 13:10:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18EDAg4K039603; Tue, 14 Sep 2021 13:10:42 GMT (envelope-from git) Date: Tue, 14 Sep 2021 13:10:42 GMT Message-Id: <202109141310.18EDAg4K039603@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e6c19aa94da4 - main - sctp: Allow blocking on I/O locks even with non-blocking sockets MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e6c19aa94da4a799472f8b82f196ffc42d0dbdaf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 13:10:43 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e6c19aa94da4a799472f8b82f196ffc42d0dbdaf commit e6c19aa94da4a799472f8b82f196ffc42d0dbdaf Author: Mark Johnston AuthorDate: 2021-09-14 13:02:05 +0000 Commit: Mark Johnston CommitDate: 2021-09-14 13:02:05 +0000 sctp: Allow blocking on I/O locks even with non-blocking sockets There are two flags to request a non-blocking receive on a socket: MSG_NBIO and MSG_DONTWAIT. They are handled a bit differently in that soreceive_generic() and soreceive_stream() will block on the socket I/O lock when MSG_NBIO is set, but not if MSG_DONTWAIT is set. In general, MSG_NBIO seems to mean, "don't block if there is no data to receive" and MSG_DONTWAIT means "don't go to sleep for any reason". SCTP's soreceive implementation did not allow blocking on the I/O lock if either flag is set, but this violates an assumption in aio_process_sb(), which specifies MSG_NBIO but nonetheless expects to make progress if data is available to read. Change sctp_sorecvmsg() to block on the I/O lock only if MSG_DONTWAIT is not set. Reported by: syzbot+c7d22dbbb9aef509421d@syzkaller.appspotmail.com Reviewed by: tuexen MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31915 --- sys/netinet/sctputil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 09d486038b65..c6cdd3315704 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -5585,7 +5585,7 @@ sctp_sorecvmsg(struct socket *so, rwnd_req, block_allowed, so->so_rcv.sb_cc, (uint32_t)uio->uio_resid); } - error = SOCK_IO_RECV_LOCK(so, (block_allowed ? SBL_WAIT : 0)); + error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(in_flags)); if (error) { goto release_unlocked; }