CVE-2026-97437: ntfs3: fix out-of-bounds read in ntfs_dir_emit() and hdr_find_e()
In the Linux kernel, the following vulnerability has been resolved:
ntfs3: fix out-of-bounds read in ntfsdiremit() and hdrfinde()
The bounds check in ntfsdiremit() compares fname->namelen (a character count) against e->size (a byte count) without accounting for the 2-byte-per-character UTF-16LE encoding or the ATTRFILENAME header size:
if (fname->namelen + sizeof(struct NTFSDE) > le16tocpu(e->size))
This computes: namelen + 16 > esize
The correct check must account for the ATTRFILENAME header (66 bytes before the name) and the UTF-16LE character size (2 bytes each):
sizeof(NTFSDE) + offsetof(ATTRFILENAME, name) + namelen sizeof(short) > esize
Which computes: 16 + 66 + namelen 2 > esize
The correct calculation already exists as fnamefullsize() in ntfs.h and is used in cmpfnames(), namei.c, and fslog.c, but was not used in the readdir path.
A crafted NTFS image with an index entry containing a small e->size but large fname->namelen bypasses the current check, causing ntfsutf16tonls() to read past the entry boundary.
Additionally, add a keysize validation in hdrfinde() to ensure the declared keysize does not exceed the available entry data, preventing comparison functions from reading past entry boundaries on the lookup path.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In ntfs_dir_emit(), validate the filename entry using fname_full_size(), accounting for the ATTR_FILE_NAME header and UTF-16LE character size: ensure the calculated filename size (16 + 66 + name_len * 2) does not exceed e->size.
- Compensating control
In hdr_find_e(), add key_size validation to ensure the declared key_size does not exceed the available entry data before processing the entry.
Event History
Frequently Asked Questions
What does an attacker need to provide to trigger the vulnerable path?
The attacker needs a crafted NTFS image containing an index entry whose declared entry size is small while its file-name length is large. This can bypass the incorrect size check and cause ntfs_utf16_to_nls() to read past the entry boundary.
When is the malformed index entry processed?
The affected validation in ntfs_dir_emit() is in the readdir path, where directory entries are emitted. The additional hdr_find_e() validation concerns declared key sizes that exceed available entry data.