All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Hamilton <adhamilt@gmail.com>
To: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com, phcoder@gmail.com,
	development@efficientek.com, Andrew Hamilton <adhamilt@gmail.com>
Subject: [PATCH v3 5/5] fs/fshelp: Avoid possible NULL pointer deference
Date: Wed, 21 May 2025 22:20:41 -0500	[thread overview]
Message-ID: <20250522032041.32043-6-adhamilt@gmail.com> (raw)
In-Reply-To: <20250522032041.32043-1-adhamilt@gmail.com>

Avoid attempting to defererence a NULL pointer to call read_symlink when
the given filesystem does not provide a read_symlink function. This could
be triggered if the calling filesystem had a file marked as a symlink.
This appears possible for HFS and was observed during fuzzing of NTFS.

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/fs/fshelp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c
index cb41934b4..15278fb80 100644
--- a/grub-core/fs/fshelp.c
+++ b/grub-core/fs/fshelp.c
@@ -226,7 +226,10 @@ find_file (char *currpath,
 	    return grub_error (GRUB_ERR_SYMLINK_LOOP,
 			       N_("too deep nesting of symlinks"));
 
-	  symlink = read_symlink (ctx->currnode->node);
+	  if (read_symlink != NULL)
+	    symlink = read_symlink (ctx->currnode->node);
+	  else
+	    return grub_error (GRUB_ERR_BAD_FS, "read_symlink is NULL");
 
 	  if (!symlink)
 	    return grub_errno;
-- 
2.39.5


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

  parent reply	other threads:[~2025-05-22  3:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-22  3:20 [PATCH v3 0/5] fs: Test failure fixes and fuzzer fixes Andrew Hamilton
2025-05-22  3:20 ` [PATCH v3 1/5] fs/ntfs: Correct regression with run list calculation Andrew Hamilton
2025-05-22  3:20 ` [PATCH v3 2/5] fs/ntfs: Correct attribute vs attribute list validation Andrew Hamilton
2025-05-22  3:20 ` [PATCH v3 3/5] fs/ntfs: Correct possible access violations Andrew Hamilton
2025-05-22  3:20 ` [PATCH v3 4/5] fs/ntfs: Correct possible infinite loops / hangs Andrew Hamilton
2025-05-22  3:20 ` Andrew Hamilton [this message]
2025-05-22  8:35 ` [PATCH v3 0/5] fs: Test failure fixes and fuzzer fixes Daniel Kiper 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=20250522032041.32043-6-adhamilt@gmail.com \
    --to=adhamilt@gmail.com \
    --cc=daniel.kiper@oracle.com \
    --cc=development@efficientek.com \
    --cc=grub-devel@gnu.org \
    --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.