CVE-2026-99994: ntfs: balance the $MFT runlist lock in data extension error paths
In the Linux kernel, the following vulnerability has been resolved:
ntfs: balance the $MFT runlist lock in data extension error paths
ntfsmftdataextendallocationnolock() drops the $MFT runlist lock before allocating clusters, and every path into undoalloc arrives without it, except a mapmftrecord() failure, which takes it first. undoalloc never releases it, so the lock leaks and the next $MFT extension and $MFT writeback hang. The restoreundoalloc failure path, on the other hand, releases the lock without holding it. And undoalloc frees the clusters with ntfsclusterfree() and truncates the runlist without the lock, although both require it.
Enter undoalloc without the lock on every path. Merge the new clusters with ntfsrunlistsmergekeepsrc() and keep the runlist that ntfsclusteralloc() returned until the extension is complete. On failure, undoalloc truncates $MFT's runlist under the lock and, after dropping it, frees the clusters from the kept runlist with ntfsclusterfreefromrl(). That keeps lcnbmplock outside the runlist lock, the order given by the comment before the cluster allocation. Unlike ntfsclusterfree() on a volume mounted with -o discard, this does not issue discards for the clusters, which were never written; the runlist merge failure path already frees them the same way. If the truncation fails, the runlist may still reference the clusters, so they stay allocated and the volume is marked for chkdsk; at this call site the truncation only shrinks the runlist and cannot fail today.
A shorter fix would keep calling ntfsclusterfree() on the live runlist without the lock, relying on $MFT's runlist being fully mapped and changed only by this function under mreclock. That breaks ntfsclusterfree()'s documented locking rule on an argument about the rest of the driver, so this patch does not do that.