fs/ntfs: Check at->attr_cur after calling next_attribute()
PATCH v2 1/1 fs/ntfs: Check at->attr_cur after calling next_attribute()
A regression was introduced recently as a part of the series of filesystem related patches to address some CVEs found in GRUB.
This issue may cause either an infinite loop at startup when accessing certain valid NTFS file systems, or may cause a crash due to a NULL pointer deference on systems where "NULL" address is invalid (such as may happen when calling grub-mount from the operating system level).
Correct this issue by checking that at->attr_cur != NULL inside find_attr.
--- grub-core/fs/ntfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
grub-core/fs/ntfs.c +2 -1
@@ -387,7 +387,8 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) } at->attr_cur = at->attr_nxt; mft_end = at->mft->buf + (at->mft->data->mft_size <<GRUB_NTFS_BLK_SHR ); -while (at->attr_cur < mft_end && *at->attr_cur !=0xFF ) +while (at->attr_cur !=NULL && at->attr_cur < mft_end + && *at->attr_cur !=0xFF ) { at->attr_nxt =next_attribute (at->attr_cur, at->end);if (*at->attr_cur ==GRUB_NTFS_AT_ATTRIBUTE_LIST )
Signature · 7 lines
2.39.5 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 26 lines · Andrew Hamilton
A regression was introduced recently as a part of the series of filesystem related patches to address some CVEs found in GRUB.
This issue may cause either an infinite loop at startup when accessing certain valid NTFS file systems, or may cause a crash due to a NULL pointer deference on systems where "NULL" address is invalid (such as may happen when calling grub-mount from the operating system level).
Correct this issue by checking that
at->attr_cur!= NULL insidefind_attr.Co-authored-by B Horn <[email protected]>Co-authored-by Andrew Hamilton <[email protected]>Signed-off-by Andrew Hamilton <[email protected]>--- grub-core/fs/ntfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)grub-core/fs/ntfs.c +0
-0
grub-core/fs/ntfs.c find_attr (struct grub_ntfs_attr *at, grub_uint8_t · line 393
Quoted 8 lines
grub-core/fs/ntfs.c +2
-1@@ -387,7 +387,8 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) } at->attr_cur = at->attr_nxt; mft_end = at->mft->buf + (at->mft->data->mft_size <<GRUB_NTFS_BLK_SHR ); -while (at->attr_cur < mft_end && *at->attr_cur !=0xFF ) +while (at->attr_cur !=NULL && at->attr_cur < mft_end + && *at->attr_cur !=0xFF )
Why not while (at->attr_cur >= at->mft->buf && at->attr_cur < mft_end && ... ?
Quoted 7 lines
grub-core/fs/ntfs.c +0
-0{at->attr_nxt = next_attribute (at->attr_cur, at->end); if (*at->attr_cur == GRUB_NTFS_AT_ATTRIBUTE_LIST)--
2.39.5
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Good feedback, I will update as suggested and send out a v3 shortly!
Thanks!
Andrew
Quoted 26 lines · Vladimir 'phcoder' Serbinenko
Le ven. 21 mars 2025, 01:54, Andrew Hamilton <[email protected]> a écrit :
Quoted 21 lines
A regression was introduced recently as a part of the series of filesystem related patches to address some CVEs found in GRUB.
This issue may cause either an infinite loop at startup when accessing certain valid NTFS file systems, or may cause a crash due to a NULL pointer deference on systems where "NULL" address is invalid (such as may happen when calling grub-mount from the operating system level).
Correct this issue by checking that
at->attr_cur!= NULL insidefind_attr.Co-authored-by B Horn <[email protected]>Co-authored-by Andrew Hamilton <[email protected]>Signed-off-by Andrew Hamilton <[email protected]>--- grub-core/fs/ntfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 24 lines
Quoted 5 lines
grub-core/fs/ntfs.c +0
-0grub-core/fs/ntfs.c find_attr (struct grub_ntfs_attr *at, grub_uint8_t · line 394
Quoted 9 lines
grub-core/fs/ntfs.c +2
-1@@ -387,7 +387,8 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) } at->attr_cur = at->attr_nxt; mft_end = at->mft->buf + (at->mft->data->mft_size <<GRUB_NTFS_BLK_SHR ); -while (at->attr_cur < mft_end && *at->attr_cur !=0xFF ) +while (at->attr_cur !=NULL && at->attr_cur < mft_end + && *at->attr_cur !=0xFF )Why not while (
at->attr_cur>=at->mft->buf&&at->attr_cur<mft_end&& ... ?Quoted 7 lines
{ at->attr_nxt = next_attribute (at->attr_cur, at->end); if (*at->attr_cur == GRUB_NTFS_AT_ATTRIBUTE_LIST)--
2.39.5
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 9 lines · Andrew Hamilton
A regression was introduced recently as a part of the series of filesystem related patches to address some CVEs found in GRUB.
This issue may cause either an infinite loop at startup when accessing certain valid NTFS file systems, or may cause a crash due to a NULL pointer deference on systems where "NULL" address is invalid (such as may happen when calling grub-mount from the operating system level).
Quoted 4 lines
Correct this issue by checking that
at->attr_cur!= NULL insidefind_attr.
Quoted 13 lines
Co-authored-by B Horn <[email protected]>Co-authored-by Andrew Hamilton <[email protected]>Signed-off-by Andrew Hamilton <[email protected]>--- grub-core/fs/ntfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)grub-core/fs/ntfs.c +0
-0
grub-core/fs/ntfs.c find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) · line 394
Quoted 9 lines
grub-core/fs/ntfs.c +2
-1@@ -387,7 +387,8 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) } at->attr_cur = at->attr_nxt; mft_end = at->mft->buf + (at->mft->data->mft_size <<GRUB_NTFS_BLK_SHR ); -while (at->attr_cur < mft_end && *at->attr_cur !=0xFF ) +while (at->attr_cur !=NULL && at->attr_cur < mft_end + && *at->attr_cur !=0xFF ) { at->attr_nxt =next_attribute (at->attr_cur, at->end);if (*at->attr_cur ==GRUB_NTFS_AT_ATTRIBUTE_LIST )
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel