* [PATCH] net: fix fanout UAF in packet_release() via NETDEV_UP race
@ 2026-03-19 20:06 Yochai Eisenrich
2026-03-19 20:18 ` Willem de Bruijn
2026-03-24 0:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Yochai Eisenrich @ 2026-03-19 20:06 UTC (permalink / raw)
To: willemdebruijn.kernel
Cc: Yochai Eisenrich, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev
`packet_release()` has a race window where `NETDEV_UP` can re-register a
socket into a fanout group's `arr[]` array. The re-registration is not
cleaned up by `fanout_release()`, leaving a dangling pointer in the fanout
array.
`packet_release()` does NOT zero `po->num` in its `bind_lock` section.
After releasing `bind_lock`, `po->num` is still non-zero and `po->ifindex`
still matches the bound device. A concurrent `packet_notifier(NETDEV_UP)`
that already found the socket in `sklist` can re-register the hook.
For fanout sockets, this re-registration calls `__fanout_link(sk, po)`
which adds the socket back into `f->arr[]` and increments `f->num_members`,
but does NOT increment `f->sk_ref`.
The fix sets `po->num` to zero in `packet_release` while `bind_lock` is
held to prevent NETDEV_UP from linking, preventing the race window.
This bug was found following an additional audit with Claude Code based on
CVE-2025-38617.
Link: https://blog.calif.io/p/a-race-within-a-race-exploiting-cve
Fixes: ce06b03e60fc ("packet: Add helpers to register/unregister ->prot_hook")
Signed-off-by: Yochai Eisenrich <echelonh@gmail.com>
---
net/packet/af_packet.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 72d0935139f0..bb2d88205e5a 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -3135,6 +3135,7 @@ static int packet_release(struct socket *sock)
spin_lock(&po->bind_lock);
unregister_prot_hook(sk, false);
+ WRITE_ONCE(po->num, 0);
packet_cached_dev_reset(po);
if (po->prot_hook.dev) {
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: fix fanout UAF in packet_release() via NETDEV_UP race
2026-03-19 20:06 [PATCH] net: fix fanout UAF in packet_release() via NETDEV_UP race Yochai Eisenrich
@ 2026-03-19 20:18 ` Willem de Bruijn
2026-03-24 0:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Willem de Bruijn @ 2026-03-19 20:18 UTC (permalink / raw)
To: Yochai Eisenrich, willemdebruijn.kernel
Cc: Yochai Eisenrich, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev
Yochai Eisenrich wrote:
> `packet_release()` has a race window where `NETDEV_UP` can re-register a
> socket into a fanout group's `arr[]` array. The re-registration is not
> cleaned up by `fanout_release()`, leaving a dangling pointer in the fanout
> array.
> `packet_release()` does NOT zero `po->num` in its `bind_lock` section.
> After releasing `bind_lock`, `po->num` is still non-zero and `po->ifindex`
> still matches the bound device. A concurrent `packet_notifier(NETDEV_UP)`
> that already found the socket in `sklist` can re-register the hook.
> For fanout sockets, this re-registration calls `__fanout_link(sk, po)`
> which adds the socket back into `f->arr[]` and increments `f->num_members`,
> but does NOT increment `f->sk_ref`.
>
> The fix sets `po->num` to zero in `packet_release` while `bind_lock` is
> held to prevent NETDEV_UP from linking, preventing the race window.
>
> This bug was found following an additional audit with Claude Code based on
> CVE-2025-38617.
> Link: https://blog.calif.io/p/a-race-within-a-race-exploiting-cve
>
> Fixes: ce06b03e60fc ("packet: Add helpers to register/unregister ->prot_hook")
>
> Signed-off-by: Yochai Eisenrich <echelonh@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: fix fanout UAF in packet_release() via NETDEV_UP race
2026-03-19 20:06 [PATCH] net: fix fanout UAF in packet_release() via NETDEV_UP race Yochai Eisenrich
2026-03-19 20:18 ` Willem de Bruijn
@ 2026-03-24 0:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-24 0:30 UTC (permalink / raw)
To: Yochai E
Cc: willemdebruijn.kernel, andrew+netdev, davem, edumazet, kuba,
pabeni, netdev
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 19 Mar 2026 22:06:10 +0200 you wrote:
> `packet_release()` has a race window where `NETDEV_UP` can re-register a
> socket into a fanout group's `arr[]` array. The re-registration is not
> cleaned up by `fanout_release()`, leaving a dangling pointer in the fanout
> array.
> `packet_release()` does NOT zero `po->num` in its `bind_lock` section.
> After releasing `bind_lock`, `po->num` is still non-zero and `po->ifindex`
> still matches the bound device. A concurrent `packet_notifier(NETDEV_UP)`
> that already found the socket in `sklist` can re-register the hook.
> For fanout sockets, this re-registration calls `__fanout_link(sk, po)`
> which adds the socket back into `f->arr[]` and increments `f->num_members`,
> but does NOT increment `f->sk_ref`.
>
> [...]
Here is the summary with links:
- net: fix fanout UAF in packet_release() via NETDEV_UP race
https://git.kernel.org/netdev/net/c/42156f93d123
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] 3+ messages in thread
end of thread, other threads:[~2026-03-24 0:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 20:06 [PATCH] net: fix fanout UAF in packet_release() via NETDEV_UP race Yochai Eisenrich
2026-03-19 20:18 ` Willem de Bruijn
2026-03-24 0:30 ` 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