* [PATCH] fs/ntfs3: fix out-of-bounds read of INDEX_ROOT in reparse/objid init
@ 2026-06-10 11:57 Weiming Shi
2026-07-14 16:45 ` Konstantin Komarov
0 siblings, 1 reply; 3+ messages in thread
From: Weiming Shi @ 2026-06-10 11:57 UTC (permalink / raw)
To: Konstantin Komarov
Cc: ntfs3, linux-kernel, Xiang Mei, Weiming Wu, Weiming Shi
From: Weiming Wu <weiming3@asu.edu>
ntfs_reparse_init() and ntfs_objid_init() parse the index root of the
$Extend/$Reparse and $Extend/$ObjId metafiles (the INDEX_ROOT attributes
named $R and $O). They read its type and rule fields through
resident_data(), which does not check that the resident attribute is
large enough to hold them.
mi_enum_attr() accepts a resident attribute with data_off == asize and
data_size == 0. For such an attribute placed last in its MFT record,
resident_data() returns a pointer to the end of the record_size buffer,
so reading root->type / root->rule reads past the allocation.
Use resident_data_ex(attr, sizeof(struct INDEX_ROOT)) and bail out when
it returns NULL, as ntfs_security_init() already does for $SDH / $SII.
The attribute is only parsed while mounting a crafted image, so this
needs CAP_SYS_ADMIN.
BUG: KASAN: slab-out-of-bounds in ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306)
Read of size 4 at addr ffff88801219dc00 by task mount
ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306)
ntfs_fill_super (fs/ntfs3/super.c:1604)
get_tree_bdev_flags (fs/super.c:1703)
vfs_get_tree (fs/super.c:1758)
path_mount (fs/namespace.c:4131)
__x64_sys_mount (fs/namespace.c:4360)
Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
Reported-by: Xiang Mei <xmei5@asu.edu>
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
---
fs/ntfs3/fsntfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
index d0434756029b6..42493a2da24ef 100644
--- a/fs/ntfs3/fsntfs.c
+++ b/fs/ntfs3/fsntfs.c
@@ -2302,8 +2302,8 @@ int ntfs_reparse_init(struct ntfs_sb_info *sbi)
goto out;
}
- root_r = resident_data(attr);
- if (root_r->type != ATTR_ZERO ||
+ root_r = resident_data_ex(attr, sizeof(struct INDEX_ROOT));
+ if (!root_r || root_r->type != ATTR_ZERO ||
root_r->rule != NTFS_COLLATION_TYPE_UINTS) {
err = -EINVAL;
goto out;
@@ -2340,8 +2340,8 @@ int ntfs_objid_init(struct ntfs_sb_info *sbi)
goto out;
}
- root = resident_data(attr);
- if (root->type != ATTR_ZERO ||
+ root = resident_data_ex(attr, sizeof(struct INDEX_ROOT));
+ if (!root || root->type != ATTR_ZERO ||
root->rule != NTFS_COLLATION_TYPE_UINTS) {
err = -EINVAL;
goto out;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/ntfs3: fix out-of-bounds read of INDEX_ROOT in reparse/objid init
2026-06-10 11:57 [PATCH] fs/ntfs3: fix out-of-bounds read of INDEX_ROOT in reparse/objid init Weiming Shi
@ 2026-07-14 16:45 ` Konstantin Komarov
2026-07-14 16:48 ` Weiming Shi
0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Komarov @ 2026-07-14 16:45 UTC (permalink / raw)
To: Weiming Shi; +Cc: ntfs3, linux-kernel, Xiang Mei, Weiming Wu
On 6/10/26 13:57, Weiming Shi wrote:
> From: Weiming Wu <weiming3@asu.edu>
>
> ntfs_reparse_init() and ntfs_objid_init() parse the index root of the
> $Extend/$Reparse and $Extend/$ObjId metafiles (the INDEX_ROOT attributes
> named $R and $O). They read its type and rule fields through
> resident_data(), which does not check that the resident attribute is
> large enough to hold them.
>
> mi_enum_attr() accepts a resident attribute with data_off == asize and
> data_size == 0. For such an attribute placed last in its MFT record,
> resident_data() returns a pointer to the end of the record_size buffer,
> so reading root->type / root->rule reads past the allocation.
>
> Use resident_data_ex(attr, sizeof(struct INDEX_ROOT)) and bail out when
> it returns NULL, as ntfs_security_init() already does for $SDH / $SII.
>
> The attribute is only parsed while mounting a crafted image, so this
> needs CAP_SYS_ADMIN.
>
> BUG: KASAN: slab-out-of-bounds in ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306)
> Read of size 4 at addr ffff88801219dc00 by task mount
> ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306)
> ntfs_fill_super (fs/ntfs3/super.c:1604)
> get_tree_bdev_flags (fs/super.c:1703)
> vfs_get_tree (fs/super.c:1758)
> path_mount (fs/namespace.c:4131)
> __x64_sys_mount (fs/namespace.c:4360)
>
> Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
> Reported-by: Xiang Mei <xmei5@asu.edu>
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Weiming Shi <bestswngs@gmail.com>
> ---
> fs/ntfs3/fsntfs.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
> index d0434756029b6..42493a2da24ef 100644
> --- a/fs/ntfs3/fsntfs.c
> +++ b/fs/ntfs3/fsntfs.c
> @@ -2302,8 +2302,8 @@ int ntfs_reparse_init(struct ntfs_sb_info *sbi)
> goto out;
> }
>
> - root_r = resident_data(attr);
> - if (root_r->type != ATTR_ZERO ||
> + root_r = resident_data_ex(attr, sizeof(struct INDEX_ROOT));
> + if (!root_r || root_r->type != ATTR_ZERO ||
> root_r->rule != NTFS_COLLATION_TYPE_UINTS) {
> err = -EINVAL;
> goto out;
> @@ -2340,8 +2340,8 @@ int ntfs_objid_init(struct ntfs_sb_info *sbi)
> goto out;
> }
>
> - root = resident_data(attr);
> - if (root->type != ATTR_ZERO ||
> + root = resident_data_ex(attr, sizeof(struct INDEX_ROOT));
> + if (!root || root->type != ATTR_ZERO ||
> root->rule != NTFS_COLLATION_TYPE_UINTS) {
> err = -EINVAL;
> goto out;
> --
> 2.43.0
>
Hello,
Very sorry for the delay.
Your patch was applied, thank you.
Regards,
Konstantin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/ntfs3: fix out-of-bounds read of INDEX_ROOT in reparse/objid init
2026-07-14 16:45 ` Konstantin Komarov
@ 2026-07-14 16:48 ` Weiming Shi
0 siblings, 0 replies; 3+ messages in thread
From: Weiming Shi @ 2026-07-14 16:48 UTC (permalink / raw)
To: Konstantin Komarov; +Cc: ntfs3, linux-kernel, Xiang Mei, Weiming Wu
Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
于2026年7月15日周三 00:45写道:
>
> On 6/10/26 13:57, Weiming Shi wrote:
>
> > From: Weiming Wu <weiming3@asu.edu>
> >
> > ntfs_reparse_init() and ntfs_objid_init() parse the index root of the
> > $Extend/$Reparse and $Extend/$ObjId metafiles (the INDEX_ROOT attributes
> > named $R and $O). They read its type and rule fields through
> > resident_data(), which does not check that the resident attribute is
> > large enough to hold them.
> >
> > mi_enum_attr() accepts a resident attribute with data_off == asize and
> > data_size == 0. For such an attribute placed last in its MFT record,
> > resident_data() returns a pointer to the end of the record_size buffer,
> > so reading root->type / root->rule reads past the allocation.
> >
> > Use resident_data_ex(attr, sizeof(struct INDEX_ROOT)) and bail out when
> > it returns NULL, as ntfs_security_init() already does for $SDH / $SII.
> >
> > The attribute is only parsed while mounting a crafted image, so this
> > needs CAP_SYS_ADMIN.
> >
> > BUG: KASAN: slab-out-of-bounds in ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306)
> > Read of size 4 at addr ffff88801219dc00 by task mount
> > ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306)
> > ntfs_fill_super (fs/ntfs3/super.c:1604)
> > get_tree_bdev_flags (fs/super.c:1703)
> > vfs_get_tree (fs/super.c:1758)
> > path_mount (fs/namespace.c:4131)
> > __x64_sys_mount (fs/namespace.c:4360)
> >
> > Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
> > Reported-by: Xiang Mei <xmei5@asu.edu>
> > Assisted-by: Claude:claude-opus-4-8
> > Signed-off-by: Weiming Shi <bestswngs@gmail.com>
> > ---
> > fs/ntfs3/fsntfs.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
> > index d0434756029b6..42493a2da24ef 100644
> > --- a/fs/ntfs3/fsntfs.c
> > +++ b/fs/ntfs3/fsntfs.c
> > @@ -2302,8 +2302,8 @@ int ntfs_reparse_init(struct ntfs_sb_info *sbi)
> > goto out;
> > }
> >
> > - root_r = resident_data(attr);
> > - if (root_r->type != ATTR_ZERO ||
> > + root_r = resident_data_ex(attr, sizeof(struct INDEX_ROOT));
> > + if (!root_r || root_r->type != ATTR_ZERO ||
> > root_r->rule != NTFS_COLLATION_TYPE_UINTS) {
> > err = -EINVAL;
> > goto out;
> > @@ -2340,8 +2340,8 @@ int ntfs_objid_init(struct ntfs_sb_info *sbi)
> > goto out;
> > }
> >
> > - root = resident_data(attr);
> > - if (root->type != ATTR_ZERO ||
> > + root = resident_data_ex(attr, sizeof(struct INDEX_ROOT));
> > + if (!root || root->type != ATTR_ZERO ||
> > root->rule != NTFS_COLLATION_TYPE_UINTS) {
> > err = -EINVAL;
> > goto out;
> > --
> > 2.43.0
> >
> Hello,
>
> Very sorry for the delay.
> Your patch was applied, thank you.
>
> Regards,
> Konstantin
>
Hi Konstantin,
Thank you for the update and for applying the patch.
Best regards,
Weiming Shi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-14 16:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-10 11:57 [PATCH] fs/ntfs3: fix out-of-bounds read of INDEX_ROOT in reparse/objid init Weiming Shi
2026-07-14 16:45 ` Konstantin Komarov
2026-07-14 16:48 ` Weiming Shi
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®