HomeFreeBSD

sctp: Allow blocking on I/O locks even with non-blocking sockets

Description

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

Details

Provenance
markjAuthored on Sep 14 2021, 1:02 PM
Reviewer
tuexen
Differential Revision
D31915: sctp: Allow blocking on I/O locks even with non-blocking sockets
Parents
R10:fa0463c384b6: socket: De-duplicate SBLOCKWAIT() definitions
Branches
Unknown
Tags
Unknown