Message ID | 20250314092446.852230-1-youngmin.nam@samsung.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [1/2] tcp: fix races in tcp_abort() | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
On Fri, Mar 14, 2025 at 06:24:45PM +0900, Youngmin Nam wrote: > From: Eric Dumazet <edumazet@google.com> > > tcp_abort() has the same issue than the one fixed in the prior patch > in tcp_write_err(). > > commit 5ce4645c23cf5f048eb8e9ce49e514bababdee85 upstream. > > To apply commit bac76cf89816bff06c4ec2f3df97dc34e150a1c4, > this patch must be applied first. > > In order to get consistent results from tcp_poll(), we must call > sk_error_report() after tcp_done(). > > We can use tcp_done_with_error() to centralize this logic. > > Fixes: c1e64e298b8c ("net: diag: Support destroying TCP sockets.") > Signed-off-by: Eric Dumazet <edumazet@google.com> > Acked-by: Neal Cardwell <ncardwell@google.com> > Link: https://lore.kernel.org/r/20240528125253.1966136-4-edumazet@google.com > Signed-off-by: Jakub Kicinski <kuba@kernel.org> > Cc: <stable@vger.kernel.org> # v5.10+ Did not apply to 5.10.y, what did you want this added to? thanks, greg k-h
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 7ad82be40f34..9fe164aa185c 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4630,13 +4630,9 @@ int tcp_abort(struct sock *sk, int err) bh_lock_sock(sk); if (!sock_flag(sk, SOCK_DEAD)) { - WRITE_ONCE(sk->sk_err, err); - /* This barrier is coupled with smp_rmb() in tcp_poll() */ - smp_wmb(); - sk_error_report(sk); if (tcp_need_reset(sk->sk_state)) tcp_send_active_reset(sk, GFP_ATOMIC); - tcp_done(sk); + tcp_done_with_error(sk, err); } bh_unlock_sock(sk);