lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 28 May 2024 11:57:44 -0400
From: Neal Cardwell <ncardwell@...gle.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>, 
	Paolo Abeni <pabeni@...hat.com>, David Laight <David.Laight@...lab.com>, netdev@...r.kernel.org, 
	eric.dumazet@...il.com
Subject: Re: [PATCH v2 net-next 2/4] tcp: fix race in tcp_write_err()

On Tue, May 28, 2024 at 8:53 AM Eric Dumazet <edumazet@...gle.com> wrote:
>
> I noticed flakes in a packetdrill test, expecting an epoll_wait()
> to return EPOLLERR | EPOLLHUP on a failed connect() attempt,
> after multiple SYN retransmits. It sometimes return EPOLLERR only.
>
> The issue is that tcp_write_err():
>  1) writes an error in sk->sk_err,
>  2) calls sk_error_report(),
>  3) then calls tcp_done().
>
> tcp_done() is writing SHUTDOWN_MASK into sk->sk_shutdown,
> among other things.
>
> Problem is that the awaken user thread (from 2) sk_error_report())
> might call tcp_poll() before tcp_done() has written sk->sk_shutdown.
>
> tcp_poll() only sees a non zero sk->sk_err and returns EPOLLERR.
>
> This patch fixes the issue by making sure to call sk_error_report()
> after tcp_done().
>
> tcp_write_err() also lacks an smp_wmb().
>
> We can reuse tcp_done_with_error() to factor out the details,
> as Neal suggested.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> ---

Acked-by: Neal Cardwell <ncardwell@...gle.com>

Thanks, Eric!

neal

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ