Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2] inet: reject unhashed sockets during timewait purge
@ 2026-11-25  2:31 Wentao Guan
  2026-12-03  4:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Guan @ 2026-11-25  2:31 UTC (permalink / raw)
  To: edumazet, ncardwell, kuniyu, imv4bel
  Cc: martin.lau, jiayuan.chen, netdev, Wentao Guan, stable

A shared ehash can retain a stale pointer that is recycled as an
unhashed SYN-cookie request from another dead namespace. The namespace
recheck alone accepts that request, and
inet_csk_reqsk_queue_drop_and_put() can then operate on an uninitialized
timer.

This is the inet_twsk_purge() counterpart of the validation added for
established lookups. Recheck the nulls node after taking the reference.
If it is unhashed, drop the reference and restart the purge instead of
operating on the recycled request.

This was found by review
commit 4e2b3ef19e0e ("inet: reject unhashed sockets during established lookups")

Fixes: 740ea3c4a0b2 ("tcp: Clean up kernel listener's reqsk in inet_twsk_purge()")
Cc: stable@vger.kernel.org
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
---
changelog v2:
change Fixes tag pointer by Kuniyuki Iwashima reviewed and add the reviewed-by.
v1 link:
https://lore.kernel.org/all/1595ACC3A3D11BB8+20261119041113.3514099-2-guanwentao@uniontech.com/
---
---
 net/ipv4/inet_timewait_sock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index e256c55ce9f29..5601bd03b1382 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -333,7 +333,8 @@ void inet_twsk_purge(struct inet_hashinfo *hashinfo)
 			if (unlikely(!refcount_inc_not_zero_acquire(&sk->sk_refcnt)))
 				continue;
 
-			if (check_net(sock_net(sk))) {
+			if (unlikely(hlist_nulls_unhashed_lockless(&sk->sk_nulls_node) ||
+				     check_net(sock_net(sk)))) {
 				sock_gen_put(sk);
 				goto restart;
 			}
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net v2] inet: reject unhashed sockets during timewait purge
  2026-11-25  2:31 [PATCH net v2] inet: reject unhashed sockets during timewait purge Wentao Guan
@ 2026-12-03  4:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-12-03  4:50 UTC (permalink / raw)
  To: Wentao Guan
  Cc: edumazet, ncardwell, kuniyu, imv4bel, martin.lau, jiayuan.chen,
	netdev, stable

Hello:

This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:

On Wed, 25 Nov 2026 10:31:24 +0800 you wrote:
> A shared ehash can retain a stale pointer that is recycled as an
> unhashed SYN-cookie request from another dead namespace. The namespace
> recheck alone accepts that request, and
> inet_csk_reqsk_queue_drop_and_put() can then operate on an uninitialized
> timer.
> 
> This is the inet_twsk_purge() counterpart of the validation added for
> established lookups. Recheck the nulls node after taking the reference.
> If it is unhashed, drop the reference and restart the purge instead of
> operating on the recycled request.
> 
> [...]

Here is the summary with links:
  - [net,v2] inet: reject unhashed sockets during timewait purge
    https://git.kernel.org/netdev/net/c/780a1d2de86a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03  4:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  2:31 [PATCH net v2] inet: reject unhashed sockets during timewait purge Wentao Guan
2026-12-03  4:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox