* [PATCH] ext2: handle NULL fc->source in ext2_msg_fc()
@ 2026-11-22 18:23 Arbab Haider
0 siblings, 0 replies; only message in thread
From: Arbab Haider @ 2026-11-22 18:23 UTC (permalink / raw)
To: Jan Kara
Cc: Eric Sandeen, linux-ext4, linux-kernel,
syzbot+1d23ad199a3bfd6f9149, stable, Arbab Haider
With the new mount API (fsopen()/fsconfig()), userspace can pass mount
options such as "nobh", "dax", or "reservation" before setting the
"source" parameter, leaving fc->source as NULL during option parsing.
In ext2_msg_fc(), when fc->purpose != FS_CONTEXT_FOR_RECONFIGURE,
strrchr(fc->source, '/') is called unconditionally without checking if
fc->source is non-NULL, causing a kernel NULL pointer dereference:
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
RIP: 0010:strrchr+0x24/0x80
ext2_msg_fc+0x157/0x1e3
Check fc->source before calling strrchr(), and omit the "(%s)" device
prefix when s_id is NULL or empty (e.g., when source is unset, empty,
or ends with '/').
Tested locally in QEMU (x86_64, KASAN+UBSAN) using fsopen()/fsconfig()
with NULL, empty, trailing-slash, relative, and full-path sources.
Reported-by: syzbot+1d23ad199a3bfd6f9149@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1d23ad199a3bfd6f9149
Fixes: 98f18c76c2c3 ("ext2: create ext2_msg_fc for use during parsing")
Cc: stable@vger.kernel.org
Signed-off-by: Arbab Haider <arbabhaider649@gmail.com>
---
fs/ext2/super.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 54a6c26d0..c99367652 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -89,20 +89,25 @@ static void ext2_msg_fc(struct fs_context *fc, const char *prefix,
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
s_id = fc->root->d_sb->s_id;
- } else {
+ } else if (fc->source) {
/* get last path component of source */
s_id = strrchr(fc->source, '/');
if (s_id)
s_id++;
else
s_id = fc->source;
+ } else {
+ s_id = NULL;
}
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
- printk("%sEXT2-fs (%s): %pV\n", prefix, s_id, &vaf);
+ if (s_id && *s_id)
+ printk("%sEXT2-fs (%s): %pV\n", prefix, s_id, &vaf);
+ else
+ printk("%sEXT2-fs: %pV\n", prefix, &vaf);
va_end(args);
}
--
2.53.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-22 18:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 18:23 [PATCH] ext2: handle NULL fc->source in ext2_msg_fc() Arbab Haider
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®