Files
linux/fs
DaeMyung Kang b64f0ae5d4 ntfs: validate attribute name bounds before returning it
ntfs_attr_find() validates a named attribute before comparing it with the
requested name, but that check is currently after the AT_UNUSED handling.
When callers enumerate attributes with AT_UNUSED, ntfs_attr_find() can
return a malformed named attribute before checking whether name_offset
and name_length stay within the attribute record.

Some enumeration callers use the returned attribute name pointer
directly.  For example, one path passes (attr + name_offset, name_length)
to ntfs_attr_iget(), where the name can later be copied according to
name_length.  A malformed on-disk name_offset/name_length pair should not
be exposed to those callers.

Move the existing name bounds validation before returning attributes
during AT_UNUSED enumeration, and write it as an offset/remaining-size
check so the subtraction cannot underflow.  Extract the converted values
into local variables (name_offset, attr_len, name_size) to make the
intent explicit and avoid repeating the endian conversions inside the
bounds check.  This keeps matching attributes on the same checked path
while also covering attribute enumeration.

A small userspace ASAN model with attr length=32, name_offset=124 and
name_length=8 reproduces a heap-buffer-overflow read in the old
enumeration path.  With this change the same malformed attribute is
rejected before the name pointer is returned to the caller.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
2026-05-10 00:42:28 +09:00
..
2026-04-20 17:27:28 +02:00
2026-01-02 13:43:41 -05:00
2025-11-28 12:42:31 +01:00
2026-04-03 16:53:50 -04:00
2026-04-01 12:26:07 -07:00
2025-09-01 13:08:01 +02:00
2026-02-19 21:51:00 +09:00
2026-02-19 21:51:00 +09:00
2026-01-12 16:52:09 +01:00
2026-04-14 09:30:15 +02:00
2026-01-12 16:52:09 +01:00
2026-03-23 12:41:58 +01:00