KernelScan.io

HIGH

packet Fanout UAF

CVE-2026-31504

CVSS 7.8 / 10.0 NVD

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

KernelScan AI7.8HIGH

01

In the Linux kernel, the following vulnerability has been resolved: net: fix fanout UAF in packet_release() via NETDEV_UP race `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.

02

Engine v0.2.0

Risk summary

An attacker with local access can trigger a use-after-free vulnerability in the packet socket fanout mechanism by exploiting a race condition during socket cleanup. This could lead to kernel memory corruption, system crashes, or potential privilege escalation through careful heap manipulation.

Affectednet/packet/af_packet.c

Vulnerability analysis

Root Cause: A race condition exists in packet_release() where NETDEV_UP events can re-register a socket into a fanout group's array after the socket has begun cleanup but before po->num is zeroed. The socket remains in the global sklist during cleanup, allowing packet_notifier(NETDEV_UP) to find it and call __fanout_link() which adds the socket back to f->arr[] without incrementing f->sk_ref, creating a dangling pointer when the socket is fully freed.

Attack Surface: Local attack surface requiring the ability to create AF_PACKET sockets with fanout groups and trigger network device state changes. The vulnerability requires specific timing between socket cleanup and NETDEV_UP events, making it a timing-dependent race condition.

Fix Mechanism: The patch adds 'WRITE_ONCE(po->num, 0);' inside the bind_lock critical section in packet_release(). By zeroing po->num while holding the lock, it prevents NETDEV_UP from re-registering the socket since the protocol number check will fail, closing the race window.

03

BranchFixed inPatch commit
5.105.10.253ee642b1962ca
5.155.15.20342cfd7898eee
6.16.1.1681b4c03f8892d
6.126.12.8075fe6db23705
6.186.18.21d0c7cdc15fdf
6.196.19.11ceccbfc6de72
6.66.6.131654386baef22
mainline7.042156f93d123