CVE-2026-138947: fs/ntfs3: fix integer overflow in find_log_rec() causing OOB read
In the Linux kernel, the following vulnerability has been resolved:
fs/ntfs3: fix integer overflow in findlogrec() causing OOB read
findlogrec() validates the on-disk LFSRECORDHDR.clientdatalen field (len, a raw u32 read straight from a mounted $LogFile page) against the log's total available space:
len = le32tocpu(rh->clientdatalen); reclen = len + log->recordheaderlen; if (reclen >= log->totalavail) return -EINVAL;
The addition is unchecked. For len in [0xffffffd0, 0xffffffff] (i.e. log->recordheaderlen away from UINTMAX), reclen wraps to a small u32 value that trivially clears the reclen >= log->totalavail guard, so a record whose declared length is actually ~4 GiB is reported as valid and in-page.
Because findlogrec() wrongly accepts the record, its caller readlogreclcb() hands it back to logreplay() as good. On the transaction-table replay leg, logreplay() re-derives the record length directly from the same raw, still-unclamped clientdatalen field and uses it to size the restart-table blob:
reclen = le32tocpu(frh->clientdatalen); / ~0xffffffff / ... t16 = le16tocpu(lrh->redooff); rt = Add2Ptr(lrh, t16); t32 = reclen - t16; / still ~4 GiB / if (!checkrstbl(rt, t32)) return -EINVAL;
checkrstbl()'s own bytes < ts bounds guard is defeated because the caller-supplied bytes (t32) is itself the poisoned ~4 GiB value, so the guard can never trigger. The subsequent entry-validation loop then walks rt->used (also attacker-controlled) entries of sizeof(struct RESTARTTABLE) == 0x18 bytes each straight past the end of the kmalloc(log->pagesize) log-page buffer allocated in readlogpage(), producing an out-of-bounds read that is reachable simply by mounting a crafted $LogFile (no genuine dirty-page / crash-recovery state is required). Confirmed via KASAN as a slab-out-of-bounds read in checkrstbl(), called from logreplay() -> ntfsloadlogandreplay() -> ntfsfillsuper() -> mount(2).
Fix the root cause instead of hardening every downstream consumer of the poisoned length: make the addition in findlogrec() overflow-safe with checkaddoverflow(), mirroring the pattern fs/ntfs3/run.c already uses to validate other attacker-controlled on-disk length/offset arithmetic decoded from MAPPINGPAIRS runs, e.g.:
if (checkaddoverflow(vcn64, len, &nextvcn)) return -EINVAL; ... if (checkaddoverflow(lcn, len, &lcnend)) return -EINVAL;
(fs/ntfs3/run.c, rununpack()).
With the overflow rejected instead of silently wrapped, reclen is only ever a true, non-wrapped sum, so the existing reclen >= log->totalavail check now correctly rejects any oversized record up front. logreplay()'s transaction-table leg then never gets a chance to re-read the poisoned clientdatalen, and checkrstbl() is never invoked with an attacker-inflated bytes for this path.
Verified on a v6.19 KASAN build: mounting a crafted $LogFile whose clientdatalen overflows trips a KASAN slab-out-of-bounds-read report in checkrstbl() before this fix; with checkaddoverflow() applied, the same image is cleanly rejected during log replay and no KASAN report fires.