CVE-2026-99422: ovl: use the pinned upper dir in ovl_fix_origin()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
ovl: use the pinned upper dir in ovl_fix_origin()
Renames made directly on the upper filesystem during a lookup crash the kernel.
A dentry that is passed to vfs_setxattr() must be pinned. ovl_fix_origin() passes upper->d_parent to ovl_set_impure() without a reference, and the lookup holds no lock of the upper directory. A rename on the upper filesystem changes d_parent, and only the child pins the new parent, so a second rename and an rmdir free it.
With delays in ovl_fix_origin() and ovl_set_impure(), renaming the upper directory twice and removing the intermediate parent during the lookup of a merge directory without an origin xattr gave a KASAN use-after-free in vfs_setxattr().
Fix this by passing the upper dentry that the overlay parent holds.
[amir: add helper ovl_set_impure_dir()]
The Linux kernel CVE team has assigned CVE-2026-99422 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.16 with commit 9678e630305724487f1fc101d6b83c383ff9cc90 and fixed in 6.12.117 with commit 17a540e65e567c8e4dd165a3ce5b592842ba5ab5 Issue introduced in 4.16 with commit 9678e630305724487f1fc101d6b83c383ff9cc90 and fixed in 6.18.61 with commit b219cdaea16b2f3e8e13a63662d462addd8a2cd0 Issue introduced in 4.16 with commit 9678e630305724487f1fc101d6b83c383ff9cc90 and fixed in 7.3.2 with commit 77c9b481faacf46b9d9282ffaa71afbac7acf819 Issue introduced in 4.16 with commit 9678e630305724487f1fc101d6b83c383ff9cc90 and fixed in 7.4-rc1 with commit 4f61ff2ebfb3d2967b83b6a4d456242244d5a61f
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2026-99422
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
fs/overlayfs/namei.c
fs/overlayfs/overlayfs.h
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/17a540e65e567c8e4dd165a3ce5b592842ba5ab5 https://git.kernel.org/stable/c/b219cdaea16b2f3e8e13a63662d462addd8a2cd0 https://git.kernel.org/stable/c/77c9b481faacf46b9d9282ffaa71afbac7acf819 https://git.kernel.org/stable/c/4f61ff2ebfb3d2967b83b6a4d456242244d5a61f