CVE-2026-98985: namespace: check the mounts before reading their parents in pivot_root()
In the Linux kernel, the following vulnerability has been resolved:
namespace: check the mounts before reading their parents in pivotroot()
pathpivotroot() reads the parents of newroot and of the caller's root and checks whether they are shared before it checks that either mount is in the caller's mount namespace. Only namespacesem is held. That's fine for a mount that is in the caller's mount namespace.
But newroot can be a file descriptor to a mount that has been unmounted and that only the file descriptor keeps alive. If that mount stayed attached to its parent when it was unmounted nothing pins the parent for it. The final mntput() of the parent unhooks the children under mountlock alone and frees the parent afterwards:
pivotroot() close(fd), last ref on the parent ------------ --------------------------------- exparent = newmnt->mntparent mntputnoexpireslowpath() umountmnt(newmnt) cleanupmnt() callrcu() ISMNTSHARED(exparent)
BUG: KASAN: slab-use-after-free in pathpivotroot+0xf1a/0x1840 Read of size 4 at addr ffff8881047382f8 by task pivotwiden/157 pathpivotroot+0xf1a/0x1840 x64syspivotroot+0x165/0x190
The same goes for the caller's root via chroot(). Both outcomes of the check end in EINVAL so nothing but the read itself goes wrong. It's the same thing commit bb4609405752 ("statmount: read the parent of an unmounted mount under mountlock") fixed for statmount().
Check that both mounts are in the caller's namespace before their parents are read. Every path returns EINVAL either way.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In path_pivot_root(), check that both the new_root mount and the caller's root mount are in the caller's mount namespace before reading their parent mounts; return EINVAL when either mount is not in that namespace.