]> www.infradead.org Git - users/dwmw2/linux.git/commit
sctp: cancel a blocking accept when shutdown a listen socket
authorXin Long <lucien.xin@gmail.com>
Mon, 1 Jul 2024 17:48:49 +0000 (13:48 -0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 3 Jul 2024 08:45:39 +0000 (09:45 +0100)
commitcda91d5b911a5a168a1c6e6917afda43b0e458c8
tree59344614b873294a6a7068fa2f3e2a72add5681b
parent2e3ed20c17e719cbe7b13feaa3e7c46cf6a85887
sctp: cancel a blocking accept when shutdown a listen socket

As David Laight noticed,

"In a multithreaded program it is reasonable to have a thread blocked in
 accept(). With TCP a subsequent shutdown(listen_fd, SHUT_RDWR) causes
 the accept to fail. But nothing happens for SCTP."

sctp_disconnect() is eventually called when shutdown a listen socket,
but nothing is done in this function. This patch sets RCV_SHUTDOWN
flag in sk->sk_shutdown there, and adds the check (sk->sk_shutdown &
RCV_SHUTDOWN) to break and return in sctp_accept().

Note that shutdown() is only supported on TCP-style SCTP socket.

Reported-by: David Laight <David.Laight@aculab.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/socket.c