diff options
author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2023-02-13 20:45:48 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-03-11 16:44:16 +0100 |
commit | 2b1c5145b07d5705165e9fc4c8003166c99221a4 (patch) | |
tree | e80fcb0f92028847cce1b790b56f04030eb621f1 | |
parent | 800a1c4c8a7fee28149d33c59ceb8171debe0497 (diff) | |
download | linux-stable-2b1c5145b07d5705165e9fc4c8003166c99221a4.tar.gz linux-stable-2b1c5145b07d5705165e9fc4c8003166c99221a4.tar.bz2 linux-stable-2b1c5145b07d5705165e9fc4c8003166c99221a4.zip |
tcp: Fix listen() regression in 5.4.229.
commit fdaf88531cfd17b2a710cceb3141ef6f9085ff40 upstream.
When we backport dadd0dcaa67d ("net/ulp: prevent ULP without clone op from
entering the LISTEN status"), we have accidentally backported a part of
7a7160edf1bf ("net: Return errno in sk->sk_prot->get_port().") and removed
err = -EADDRINUSE in inet_csk_listen_start().
Thus, listen() no longer returns -EADDRINUSE even if ->get_port() failed
as reported in [0].
We set -EADDRINUSE to err just before ->get_port() to fix the regression.
[0]: https://lore.kernel.org/stable/EF8A45D0-768A-4CD5-9A8A-0FA6E610ABF7@winter.cafe/
Reported-by: Winter <winter@winter.cafe>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 9ef69c975b15..04593893e0c6 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -932,6 +932,7 @@ int inet_csk_listen_start(struct sock *sk, int backlog) * It is OK, because this socket enters to hash table only * after validation is complete. */ + err = -EADDRINUSE; inet_sk_state_store(sk, TCP_LISTEN); if (!sk->sk_prot->get_port(sk, inet->inet_num)) { inet->inet_sport = htons(inet->inet_num); |