All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Hamilton <adhamilt@gmail.com>
To: grub-devel@gnu.org
Cc: b@horn.uk, dkiper@net-space.pl, phcoder@gmail.com,
	mlewando@redhat.com, andreas.klauer@metamorpher.de,
	eric.valette@gmail.com, fzielcke@z-51.de,
	mate.kukri@canonical.com, Andrew Hamilton <adhamilt@gmail.com>
Subject: [PATCH v2] fs/ntfs: Check at->attr_cur after calling next_attribute()
Date: Thu, 20 Mar 2025 17:54:20 -0500	[thread overview]
Message-ID: <20250320225420.4740-1-adhamilt@gmail.com> (raw)

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

             reply	other threads:[~2025-03-20 22:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20 22:54 Andrew Hamilton [this message]
2025-03-20 23:04 ` [PATCH v2] fs/ntfs: Check at->attr_cur after calling next_attribute() Vladimir 'phcoder' Serbinenko
2025-03-20 23:19   ` Andrew Hamilton
2025-03-21 18:58 ` Ross Philipson via Grub-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250320225420.4740-1-adhamilt@gmail.com \
    --to=adhamilt@gmail.com \
    --cc=andreas.klauer@metamorpher.de \
    --cc=b@horn.uk \
    --cc=dkiper@net-space.pl \
    --cc=eric.valette@gmail.com \
    --cc=fzielcke@z-51.de \
    --cc=grub-devel@gnu.org \
    --cc=mate.kukri@canonical.com \
    --cc=mlewando@redhat.com \
    --cc=phcoder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.