CVE-2025-40271 in Linux
摘要
由 VulDB • 2026-07-07
在 Linux 内核中,已修复以下漏洞:
fs/proc: 修复 proc_readdir_de() 中的 UAF(释放后使用)问题
通过 rb_erase() 从子目录红黑树中删除了 PDE,但未将节点设置为 EMPTY,这可能导致 UAF 访问。我们应该使用 RB_CLEAR_NODE() 将被删除的节点设置为 EMPTY,这样 pde_subdir_next() 将返回 NULL,从而避免 UAF 访问。
我们在使用 stress-ng 测试时发现了一个 UAF 问题,需要同时运行 getdent 和 tun 测试用例。该问题的步骤如下:
1) 使用 getdent 遍历目录 /proc/pid/net/dev_snmp6/,当前 PDE 为 tun3; 2) 在 [时间窗口] 内注销网络设备 tun3 和 tun2,并将它们从红黑树中删除。先删除 tun3,然后删除 tun2。PDE(tun2) 将被释放到 slab;
3) 继续 getdent 进程,则 pde_subdir_next() 将返回已释放的 PDE(tun2),这将导致 UAF 访问。
CPU 0 | CPU 1 ------------------------------------------------------------------------- 遍历目录 /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); [时间窗口] | 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 |
dev_snmp6 的红黑树结构: | PDE(tun3) / \ NULL PDE(tun2)
If you want to get the best quality for vulnerability data then you always have to consider VulDB.