Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sctp: allow receiving msg when TCP-style sk is in CLOSED state

Commit 141ddefce7c8 ("sctp: change sk state to CLOSED instead of
CLOSING in sctp_sock_migrate") changed sk state to CLOSED if the
assoc is closed when sctp_accept clones a new sk.

If there is still data in sk receive queue, users will not be able
to read it any more, as sctp_recvmsg returns directly if sk state
is CLOSED.

This patch is to add CLOSED state check in sctp_recvmsg to allow
reading data from TCP-style sk with CLOSED state as what TCP does.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xin Long and committed by
David S. Miller
e0878694 a0fc6843

+1 -1
+1 -1
net/sctp/socket.c
··· 2079 2079 lock_sock(sk); 2080 2080 2081 2081 if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED) && 2082 - !sctp_sstate(sk, CLOSING)) { 2082 + !sctp_sstate(sk, CLOSING) && !sctp_sstate(sk, CLOSED)) { 2083 2083 err = -ENOTCONN; 2084 2084 goto out; 2085 2085 }