All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] fs/ntfs: Check at->attr_cur after calling next_attribute()
@ 2025-03-20 22:54 Andrew Hamilton
  2025-03-20 23:04 ` Vladimir 'phcoder' Serbinenko
  2025-03-21 18:58 ` Ross Philipson via Grub-devel
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Hamilton @ 2025-03-20 22:54 UTC (permalink / raw)
  To: grub-devel
  Cc: b, dkiper, phcoder, mlewando, andreas.klauer, eric.valette,
	fzielcke, mate.kukri, 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 inside
find_attr.

Fixes: https://savannah.gnu.org/bugs/?66855

Co-authored-by: B Horn <b@horn.uk>
Co-authored-by: Andrew Hamilton <adhamilt@gmail.com>
Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
---
 grub-core/fs/ntfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c
index 960833a34..a29e10401 100644
--- a/grub-core/fs/ntfs.c
+++ b/grub-core/fs/ntfs.c
@@ -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)
-- 
2.39.5


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-21 18:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-20 22:54 [PATCH v2] fs/ntfs: Check at->attr_cur after calling next_attribute() Andrew Hamilton
2025-03-20 23:04 ` Vladimir 'phcoder' Serbinenko
2025-03-20 23:19   ` Andrew Hamilton
2025-03-21 18:58 ` Ross Philipson via Grub-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.