Date: Tue, 21 Sep 2021 13:48:32 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 32f1d05f783d - stable/13 - sctp: Allow blocking on I/O locks even with non-blocking sockets Message-ID: <202109211348.18LDmWcH035671@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=32f1d05f783de24f97ec56aca454e52c7d1071bf commit 32f1d05f783de24f97ec56aca454e52c7d1071bf Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-09-14 13:02:05 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-09-21 13:38:39 +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 Sponsored by: The FreeBSD Foundation (cherry picked from commit e6c19aa94da4a799472f8b82f196ffc42d0dbdaf) --- 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 ad4409f666df..b01ace4d1fb9 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -5586,7 +5586,7 @@ sctp_sorecvmsg(struct socket *so, rwnd_req, block_allowed, so->so_rcv.sb_cc, (uint32_t)uio->uio_resid); } - error = sblock(&so->so_rcv, (block_allowed ? SBL_WAIT : 0)); + error = sblock(&so->so_rcv, SBLOCKWAIT(in_flags)); if (error) { goto release_unlocked; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109211348.18LDmWcH035671>