* [PATCH ntfs3] fs/ntfs3: validate EA entry layout against ef->size in ntfs_read_ea
@ 2026-07-03 22:23 Xiang Mei
2026-09-21 10:54 ` Konstantin Komarov
0 siblings, 1 reply; 2+ messages in thread
From: Xiang Mei @ 2026-07-03 22:23 UTC (permalink / raw)
To: Konstantin Komarov, ntfs3; +Cc: linux-kernel, Weiming Shi, Xiang Mei
In ntfs_read_ea(), the ef->size branch only checks that the declared
entry size fits the remaining buffer; unlike the zero-size branch it
never verifies that the entry's own name and value fit inside ef->size.
A crafted image can thus present an in-bounds ef->size with an arbitrary
elength, which find_ea()/ntfs_get_ea() later use as the memcpy length,
reading past the allocation and leaking adjacent heap memory:
BUG: KASAN: slab-out-of-bounds in ntfs_get_ea (fs/ntfs3/xattr.c:302)
Read of size 65535 at addr ffff888010770b0f by task exploit/142
...
__asan_memcpy (mm/kasan/shadow.c:105)
ntfs_get_ea (fs/ntfs3/xattr.c:302)
ntfs_getxattr (fs/ntfs3/xattr.c:848)
__vfs_getxattr (fs/xattr.c:446)
vfs_getxattr (fs/xattr.c:479)
do_getxattr (fs/xattr.c:808)
filename_getxattr (fs/xattr.c:837)
path_getxattrat (fs/xattr.c:876)
do_syscall_64 (arch/x86/entry/syscall_64.c:94)
...
The buggy address is located 15 bytes inside of
allocated 20-byte region, cache kmalloc-32
Validate the name/value layout in the ef->size branch too, bounding it
against ef->size, as the zero-size branch validates it against the
buffer.
Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
Reported-by: Weiming Shi <bestswngs@gmail.com>
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Xiang Mei <xmei5@asu.edu>
---
fs/ntfs3/xattr.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 04814dd29375..259d7f53b77b 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -155,6 +155,11 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
ea_size = le32_to_cpu(ef->size);
if (ea_size > bytes)
goto out1;
+ if (bytes < offsetof(struct EA_FULL, name))
+ goto out1;
+ if (struct_size(ef, name, 1 + ef->name_len +
+ le16_to_cpu(ef->elength)) > ea_size)
+ goto out1;
continue;
}
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH ntfs3] fs/ntfs3: validate EA entry layout against ef->size in ntfs_read_ea
2026-07-03 22:23 [PATCH ntfs3] fs/ntfs3: validate EA entry layout against ef->size in ntfs_read_ea Xiang Mei
@ 2026-09-21 10:54 ` Konstantin Komarov
0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Komarov @ 2026-09-21 10:54 UTC (permalink / raw)
To: Xiang Mei, ntfs3; +Cc: linux-kernel, Weiming Shi
On 7/4/26 00:23, Xiang Mei wrote:
> In ntfs_read_ea(), the ef->size branch only checks that the declared
> entry size fits the remaining buffer; unlike the zero-size branch it
> never verifies that the entry's own name and value fit inside ef->size.
> A crafted image can thus present an in-bounds ef->size with an arbitrary
> elength, which find_ea()/ntfs_get_ea() later use as the memcpy length,
> reading past the allocation and leaking adjacent heap memory:
>
> BUG: KASAN: slab-out-of-bounds in ntfs_get_ea (fs/ntfs3/xattr.c:302)
> Read of size 65535 at addr ffff888010770b0f by task exploit/142
> ...
> __asan_memcpy (mm/kasan/shadow.c:105)
> ntfs_get_ea (fs/ntfs3/xattr.c:302)
> ntfs_getxattr (fs/ntfs3/xattr.c:848)
> __vfs_getxattr (fs/xattr.c:446)
> vfs_getxattr (fs/xattr.c:479)
> do_getxattr (fs/xattr.c:808)
> filename_getxattr (fs/xattr.c:837)
> path_getxattrat (fs/xattr.c:876)
> do_syscall_64 (arch/x86/entry/syscall_64.c:94)
> ...
> The buggy address is located 15 bytes inside of
> allocated 20-byte region, cache kmalloc-32
>
> Validate the name/value layout in the ef->size branch too, bounding it
> against ef->size, as the zero-size branch validates it against the
> buffer.
>
> Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
> Reported-by: Weiming Shi <bestswngs@gmail.com>
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Xiang Mei <xmei5@asu.edu>
> ---
> fs/ntfs3/xattr.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 04814dd29375..259d7f53b77b 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -155,6 +155,11 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
> ea_size = le32_to_cpu(ef->size);
> if (ea_size > bytes)
> goto out1;
> + if (bytes < offsetof(struct EA_FULL, name))
> + goto out1;
> + if (struct_size(ef, name, 1 + ef->name_len +
> + le16_to_cpu(ef->elength)) > ea_size)
> + goto out1;
> continue;
> }
>
Hello,
Sorry for the delay.
The patch was applied, thanks.
Regards,
Konstantin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-21 10:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-03 22:23 [PATCH ntfs3] fs/ntfs3: validate EA entry layout against ef->size in ntfs_read_ea Xiang Mei
2026-09-21 10:54 ` Konstantin Komarov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®