CVE-2026-99862: fs/ntfs3: bound DeleteAttribute asize against rec->used in do_action
In the Linux kernel, the following vulnerability has been resolved:
fs/ntfs3: bound DeleteAttribute asize against rec->used in doaction
In doaction()'s DeleteAttribute case (fslog.c:3316), attr is Add2Ptr(rec, roff) with roff taken from the on-disk lrh->recordoff, and asize = le32tocpu(attr->size) is read straight out of the MFT record:
asize = le32tocpu(attr->size); used = le32tocpu(rec->used);
if (!checkifattr(rec, lrh)) goto dirtyvol; ... memmove(attr, Add2Ptr(attr, asize), used - asize - roff);
checkifattr() (fslog.c:2869) walks the attribute chain from rec->attroff and returns o == ro. Its loop breaks on ATTREND, so ro may legitimately equal the offset of the ATTREND marker; that is exactly how CreateAttribute appends to a record. But checkfilerecord()'s walk (fslog.c:2831) also stops at ATTREND, so checkattr() never inspects the bytes there. When roff is the ATTREND offset, those never-validated bytes are what gets read as attr->size, and used - asize - roff underflows.
The read itself is also unbounded: roff is a u16 and attr->size is dereferenced at fslog.c:3317, before checkifattr() has constrained roff at all, so it can be up to ~64K past a recordsize-sized object.
Commit 0ca0485e4b2e ("fs/ntfs3: validate rec->used in journal-replay file record check") added at fslog.c:2844
if (used < PtrOffset(rec, attr) + sizeof(attr->type)) return false;
and its changelog names this very memmove. It bounds rec->used against the ATTREND offset; it does not bound asize. With recordsize 0x400, attroff 0x38, a valid three-attribute chain ending in ATTREND at 0x158 and used 0x160, a record whose four bytes at 0x15c read 0x100 gives
used - asize - roff = 0x160 - 0x100 - 0x158 = 0xffffff08
i.e. a ~4 GiB memmove whose source and destination both run off the end of rec, a kmalloc(sbi->recordsize) object (record.c:105).
The equivalent non-replay path already refuses this. miremoveattr() performs the same removal and starts with (record.c:548):
if (aoff + asize > used) return false;
Apply the same bound, spelled as a subtraction to match the neighbouring cases, and move the attr->size read after checkifattr() so that the header is known to lie inside the record before it is dereferenced. Requiring roff + SIZEOFRESIDENT <= used rejects the ATTREND offset without rejecting any real attribute: for an attribute the walk validated, roff + asize <= off(ATTREND) <= used - 4, and any attribute a DeleteAttribute record can legitimately name carries a full resident header, so roff + SIZEOFRESIDENT <= roff + asize <= used - 4. checkattr() itself imposes no lower bound on asize, so a crafted sub-header asize can still pass the first test; the second test then bounds it and the memmove stays inside the record.
Reproduced by mounting a crafted image on v7.2-rc5, which already contains 0ca0485e4b2e, under KASAN. The image is an ordinary mkfs.ntfs volume with four bytes of one MFT record changed and a crafted $LogFile:
BUG: KASAN: slab-out-of-bounds in doaction.isra.0+0x3211/0x83c0 Read of size 4294967048 at addr ffff888002423258 by task mount/66
CPU: 1 UID: 0 PID: 66 Comm: mount Not tainted 7.2.0-rc5 #3 Call Trace: kasanreport+0xce/0x100 kasancheckrange+0x105/0x1b0 asanmemmove+0x23/0x60 doaction.isra.0+0x3211/0x83c0 logreplay+0x920a/0xd300 ntfsloadlogandreplay+0x3ef/0x510 ntfsfillsuper+0x1d23/0x4550 gettreebdevflags+0x2ef/0x550 vfsgettree+0x82/0x2f0 fcmount+0x10/0x1b0 pathmount+0x517/0x1df0 x64sysmount+0x20b/0x270 dosyscall64+0xf9/0x540 entrySYSCALL64afterhwframe+0x77/0x7f
Allocated by task 66: kasankmalloc+0x8f/0xa0 kmallocnoprof+0x1b4/0x460 miinit+0x81/0x110 miget+0x6a/0x220 doaction.isra.0+0x1dbf/0x83c0 logreplay+0x920a/0xd300 ntfsloadlogandreplay+0x3ef/0x510 ntfsfillsuper+0x1d23/0x4550
The buggy address belongs to the object at ffff88 ---truncated---