CVE-2026-143111: dcache: let d_invalidate() wait for a d_set_mounted() in flight

Published Dec 3, 2026
·
Updated

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

dcache: let dinvalidate() wait for a dsetmounted() in flight

dinvalidate() and dsetmounted() are supposed to exclude each other. Either the mount fails with -ENOENT because an ancestor of the mountpoint was unhashed or dinvalidate() finds the mountpoint and detaches the mount. dinvalidate() unhashes the dentry first and then searches the subtree with dwalk() which starts out lockless and only looks at the seqcount of renamelock.

Since dsetmounted() switched to readseqlockexcl() nothing makes that walk wait or retry:

CPU0: mount on A/M CPU1: dinvalidate(A) dsetmounted(M) readseqlockexcl(&renamelock) A is hashed, go on ddrop(A) shrinkdcacheparent(A) dwalk(A, findsubmount) readseqbegin(&renamelock) M is not a mountpoint needseqretry() == false return M->dflags |= DCACHEMOUNTED return 0 mount gets attached to M

The mount ends up below an unhashed dentry. It can't be reached anymore and pins the subtree until its parent mount or the mount namespace goes away. The window grows with the depth of the mountpoint. With a FUSE directory 3000 levels deep a bind mount racing with FUSENOTIFYINVALENTRY for the parent of the mountpoint survived in 151 of 200 attempts.

Before 5e317d23f6c6 the seqcount bump made the walk wait while dsetmounted() ran and retry under the lock when one had run in the meantime. That was the right thing to wait for on the wrong counter: every renamelock reader paid for it, dlookup(), dpath(), the ".." step of the RCU walk.

So give dsetmounted() a seqlock of its own. It is the only writer and dinvalidate() is the only reader. After unhashing the dentry dinvalidate() runs an empty readseqbegin()/readseqretry() section on it. That spins while the count is odd, i.e. while a dsetmounted() is between its ancestor check and its flag, and goes round once more if one started in the meantime. Nobody else retries anything. The ordering comes from the locks both already take:

- If that dsetmounted() saw the dentry hashed its check ran under the dentry's dlock before ddrop() took it. So the count is odd by the time dinvalidate() reads it and dinvalidate() waits.

- Once the count is even again the flag has been set under the mountpoint's dlock and the walk takes that lock to look at it.

A dsetmounted() that starts after the unhash fails its ancestor check and never touches the flag. So the only flag the walk can pick up belongs to the one mount that saw the dentry hashed and is still in flight, and there is at most one of those because namespacesem serializes mounts. Either it gets attached and detachmounts() takes it off after waiting for namespacesem or it fails later on and drops the flag again. In that case the walk goes round once more and finds nothing. The same goes for the mountpoint that attachrecursivemnt() preallocates on the root of the tree it attaches. IOW, dinvalidate() does at most one extra round, which the removed-name trap (cf. [1]) relies on.

Note that on PREEMPTRT readseqbegin() takes the lock instead of spinning on a preempted dsetmounted().

The cost is a seqlock around the ancestor walk for every new mountpoint and two loads of a cacheline that only dsetmounted() writes for every dinvalidate() of a positive dentry. Walking the ancestors a second time after setting the flag would close the race as well but doubles the cost of dsetmounted() with the depth of the mountpoint: about 1us at 64 levels and 75us at 4096 levels.

[1]: https://patch.msgid.link/20261028-work-mount-trap-b4-v1-0-f20d9d0730d6@kernel.org

Affected Software

1 affected component
Linux Linux kernel

Event History

Dec 3, 2026
CVE Published
via MITRE·09:19 AM
Data Sourced
via MITRE·09:19 AM
Description

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203