From: Kees Cook <kees@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: 李龙兴 <coregee2000@gmail.com>, "Theodore Ts'o" <tytso@mit.edu>,
"Andreas Dilger" <adilger.kernel@dilger.ca>,
linux-ext4@vger.kernel.org, syzkaller@googlegroups.com,
andy@kernel.org, akpm@linux-foundation.org,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [Kernel Bug] WARNING in ext4_fill_super
Date: Fri, 6 Feb 2026 11:29:11 -0800 [thread overview]
Message-ID: <202602061032.63DD1CA3AE@keescook> (raw)
In-Reply-To: <aYYE4iLTXZw5t0w_@smile.fi.intel.com>
On Fri, Feb 06, 2026 at 05:12:34PM +0200, Andy Shevchenko wrote:
> On Fri, Feb 06, 2026 at 05:08:19PM +0200, Andy Shevchenko wrote:
> > On Fri, Feb 06, 2026 at 04:20:15PM +0200, Andy Shevchenko wrote:
> > > On Mon, Feb 02, 2026 at 12:19:45PM +0800, 李龙兴 wrote:
> > > > Dear Linux kernel developers and maintainers,
> > > >
> > > > We would like to report a new kernel bug found by our tool. The issue
> > > > is a WARNING in ext4_fill_super. Details are as follows.
> > >
> > > First of all, the warning appears in parse_apply_sb_mount_options().
> [...]
> Actually, the documentation says that strscpy*() must be used against C-strings.
> This can explain the bug, id est the given string in mount options is not
> NUL-terminated. That's where bug may come from. So, the Q is why is mount options
> not NUL-terminated when it comes to ext4_fill_super()?
parse_apply_sb_mount_options(...):
...
char s_mount_opts[64];
...
if (strscpy_pad(s_mount_opts, sbi->s_es->s_mount_opts) < 0)
return -E2BIG;
Is sbi->s_es->s_mount_opts expected to be a C string? If not, this
strscpy_pad() should likely be memtostr_pad(). (s_mount_opts is expected
to be a C string based on its use with later C string API calls.)
It seems like s_mount_opts is expected to be a C string, I can see it
being used that way in lots of other places, e.g.:
fs/ext4/ioctl.c: strscpy_pad(ret.mount_opts, es->s_mount_opts);
fs/ext4/ioctl.c: strscpy_pad(es->s_mount_opts, params->mount_opts);
fs/ext4/super.c: if (!sbi->s_es->s_mount_opts[0])
fs/ext4/super.c: if (strscpy_pad(s_mount_opts, sbi->s_es->s_mount_opts) < 0)
I can't tell where es->s_mount_opts comes from originally?
This one:
fs/ext4/ioctl.c: strscpy_pad(es->s_mount_opts, params->mount_opts);
comes through ext4_ioctl_set_tune_sb() which has:
if (strnlen(params.mount_opts, sizeof(params.mount_opts)) ==
sizeof(params.mount_opts))
return -E2BIG;
So it's already checked for, and suggests it must be NUL-terminated.
> > > > loop4: detected capacity change from 0 to 514
> > > > ------------[ cut here ]------------
> > > > strnlen: detected buffer overflow: 65 byte read of buffer size 64
> > > > WARNING: CPU: 0 PID: 12320 at lib/string_helpers.c:1035
> > > > __fortify_report+0x9c/0xd0 lib/string_helpers.c:1035
> > > > [...]
> > > > Call Trace:
> > > > <TASK>
> > > > __fortify_panic+0x23/0x30 lib/string_helpers.c:1042
> > > > strnlen include/linux/fortify-string.h:235 [inline]
> > > > sized_strscpy include/linux/fortify-string.h:309 [inline]
> > > > parse_apply_sb_mount_options fs/ext4/super.c:2486 [inline]
> > > > __ext4_fill_super fs/ext4/super.c:5306 [inline]
> > > > ext4_fill_super+0x3972/0xaf70 fs/ext4/super.c:5736
> > > > get_tree_bdev_flags+0x38c/0x620 fs/super.c:1698
> > > > vfs_get_tree+0x8e/0x340 fs/super.c:1758
> > > > fc_mount fs/namespace.c:1199 [inline]
> > > > do_new_mount_fc fs/namespace.c:3642 [inline]
So, something via do_new_mount_fc? Probably:
static int ext4_fill_super(struct super_block *sb, struct fs_context *fc)
which calls __ext4_fill_super(), and eventually
parse_apply_sb_mount_options(). Which depends on:
struct ext4_fs_context *ctx = fc->fs_private;
But I can't figure out where that comes from. Seems like fs_parse(), but
I don't see where mount option strings would come through...
Anyone more familiar with this know?
-Kees
--
Kees Cook
next prev parent reply other threads:[~2026-02-06 19:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 4:19 [Kernel Bug] WARNING in ext4_fill_super 李龙兴
2026-02-06 14:20 ` Andy Shevchenko
2026-02-06 15:08 ` Andy Shevchenko
2026-02-06 15:12 ` Andy Shevchenko
2026-02-06 19:29 ` Kees Cook [this message]
2026-02-06 19:53 ` Kees Cook
2026-02-06 20:36 ` Kees Cook
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=202602061032.63DD1CA3AE@keescook \
--to=kees@kernel.org \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=coregee2000@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller@googlegroups.com \
--cc=tytso@mit.edu \
/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.