]> www.infradead.org Git - users/dwmw2/linux.git/commit
sctp: ensure sk_state is set to CLOSED if hashing fails in sctp_listen_start
authorXin Long <lucien.xin@gmail.com>
Mon, 7 Oct 2024 16:25:11 +0000 (12:25 -0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Oct 2024 12:36:32 +0000 (13:36 +0100)
commit4d5c70e6155d5eae198bade4afeab3c1b15073b6
tree409fa0afd48158f853bc9c7042a8324b6d287ddc
parent82c5b53140faf89c31ea2b3a0985a2f291694169
sctp: ensure sk_state is set to CLOSED if hashing fails in sctp_listen_start

If hashing fails in sctp_listen_start(), the socket remains in the
LISTENING state, even though it was not added to the hash table.
This can lead to a scenario where a socket appears to be listening
without actually being accessible.

This patch ensures that if the hashing operation fails, the sk_state
is set back to CLOSED before returning an error.

Note that there is no need to undo the autobind operation if hashing
fails, as the bind port can still be used for next listen() call on
the same socket.

Fixes: 76c6d988aeb3 ("sctp: add sock_reuseport for the sock in __sctp_hash_endpoint")
Reported-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
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>
net/sctp/socket.c