VYPR
Unrated severityNVD Advisory· Published Dec 6, 2025· Updated Apr 15, 2026

CVE-2025-40271

CVE-2025-40271

Description

In the Linux kernel, the following vulnerability has been resolved:

fs/proc: fix uaf in proc_readdir_de()

Pde is erased from subdir rbtree through rb_erase(), but not set the node to EMPTY, which may result in uaf access. We should use RB_CLEAR_NODE() set the erased node to EMPTY, then pde_subdir_next() will return NULL to avoid uaf access.

We found an uaf issue while using stress-ng testing, need to run testcase getdent and tun in the same time. The steps of the issue is as follows:

1) use getdent to traverse dir /proc/pid/net/dev_snmp6/, and current pde is tun3;

2) in the [time windows] unregister netdevice tun3 and tun2, and erase them from rbtree. erase tun3 first, and then erase tun2. the pde(tun2) will be released to slab;

3) continue to getdent process, then pde_subdir_next() will return pde(tun2) which is released, it will case uaf access.

CPU 0 | CPU 1 ------------------------------------------------------------------------- traverse dir /proc/pid/net/dev_snmp6/ | unregister_netdevice(tun->dev) //tun3 tun2 sys_getdents64() | iterate_dir() | proc_readdir() | proc_readdir_de() | snmp6_unregister_dev() pde_get(de); | proc_remove() read_unlock(&proc_subdir_lock); | remove_proc_subtree() | write_lock(&proc_subdir_lock); [time window] | rb_erase(&root->subdir_node, &parent->subdir); | write_unlock(&proc_subdir_lock); read_lock(&proc_subdir_lock); | next = pde_subdir_next(de); | pde_put(de); | de = next; //UAF |

rbtree of dev_snmp6 | pde(tun3) / \ NULL pde(tun2)

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

In the Linux kernel’s /proc filesystem, a missing RB_CLEAR_NODE() after rb_erase() in proc_readdir_de() can cause a use-after-free when a network device is unregistered during directory traversal.

Root

Cause

The vulnerability resides in the proc_readdir_de() function inode operation (fs/proc) where the proc_readdir_de() function traverses the red-black tree of subdirectory entries (pde) for a /proc directory. When an entry is removed from the tree via rb_erase(), the kernel fails to call RB_CLEAR_NODE() on the erased node, leaving its sibling pointers dangling. As a result, a subsequent call to pde_subdir_next() can follow those stale pointers and return a freed proc_dir_entry [description].

Exploitation

Scenario

An attacker (or any local user) who can trigger parallel operations on /proc can exploit this race condition. The specific scenario involves concurrently running getdents on /proc/pid/net/dev_snmp6/ while a network device (e.g., a tun interface) is being unregistered. During the race window, the kernel removes and frees the proc_dir_entry for the device, but the directory iterator still holds a stale reference [description].

Impact

Successfully exploiting this use-after-free can lead to arbitrary code execution or a system crash (denial of service), as the freed proc_dir_entry structure may be reallocated for other kernel objects. The attack requires only local access and the ability to create and destroy network interfaces (e.g., via ip tuntap), making it a realistic local privilege escalation or denial-of-service vector [description].

Mitigation

A fix is merged into the mainline Linux kernel and has been backported to stable branches (commits [1], [2], [3]). The patch adds RB_CLEAR_NODE() after rb_erase() for each subdirectory entry, ensuring that pde_subdir_next() returns -> rb_next() will return NULL instead of following a freed node. Administrators should update their kernels to include this fix immediately.

AI Insight generated on May 19, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

2

Patches

8

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

8

News mentions

0

No linked articles in our index yet.