From: Oscar Deschamps <odeschamps.mail@gmail.com>
To: Joao Marcos Costa <joaomarcos.costa@bootlin.com>,
Richard Genoud <richard.genoud@bootlin.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Allan ELKAIM <allan.elkaim@gmail.com>,
Tom Rini <trini@konsulko.com>,
u-boot@lists.u-boot-project.org,
Oscar Deschamps <odeschamps.mail@gmail.com>
Subject: [PATCH] fs/squashfs: fix NULL dereference on failed symlink resolution
Date: Wed, 28 Oct 2026 14:44:27 +0100 [thread overview]
Message-ID: <20261028134427.405740-1-odeschamps.mail@gmail.com> (raw)
sqfs_resolve_symlink() can return NULL, on its symlink_size overflow
guard or on an allocation failure. sqfs_read_nest() and sqfs_size_nest()
use the result without checking it, unlike sqfs_search_dir(), and the
NULL reaches sqfs_split_path() which dereferences path[0]. A crafted or
corrupted image can thus crash U-Boot (a NULL read) while reading or
sizing a file through a symlink.
Check the result in both callers and guard sqfs_split_path() against a
NULL path. Found by fuzzing the SquashFS parser.
Signed-off-by: Oscar Deschamps <odeschamps.mail@gmail.com>
---
fs/squashfs/sqfs.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 0ea6dcaba1a..28d6e64e79c 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -1295,6 +1295,10 @@ static int sqfs_split_path(char **file, char **dir, const char *path)
*file = NULL;
*dir = NULL;
+
+ if (!path)
+ return -EINVAL;
+
dirc = NULL;
basec = NULL;
bname = NULL;
@@ -1561,6 +1565,10 @@ static int sqfs_read_nest(const char *filename, void *buf, loff_t offset,
dirs->entry = NULL;
sqfs_closedir(dirsp);
dirsp = NULL;
+ if (!resolved) {
+ ret = -EINVAL;
+ goto out;
+ }
ret = sqfs_read_nest(resolved, buf, offset, len, actread);
free(resolved);
goto out;
@@ -1848,6 +1856,10 @@ static int sqfs_size_nest(const char *filename, loff_t *size)
*/
sqfs_closedir(dirsp);
dirsp = NULL;
+ if (!resolved) {
+ ret = -EINVAL;
+ break;
+ }
ret = sqfs_size(resolved, size);
free(resolved);
break;
--
2.43.0
next reply other threads:[~2026-10-28 14:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 13:44 Oscar Deschamps [this message]
2026-10-28 14:27 ` [PATCH] fs/squashfs: fix NULL dereference on failed symlink resolution Miquel Raynal
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=20261028134427.405740-1-odeschamps.mail@gmail.com \
--to=odeschamps.mail@gmail.com \
--cc=allan.elkaim@gmail.com \
--cc=joaomarcos.costa@bootlin.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard.genoud@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
/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.