Linux EXT4 FS development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhao Gongyi" <zhaogongyi@bytedance.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH] ext4: use a stable source for the kmmpd thread name
Date: Mon, 16 Nov 2026 16:42:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-217372@kernel.org> (raw)
In-Reply-To: <da634961-1d13-4d21-b181-f366fd72e0d1@bytedance.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] lib/kasprintf: reproducer-only msleep(1000) delay committed in
  kvasprintf()
- [High] ext4: missing Signed-off-by trailer in commit message
- [Medium] ext4: commit title and raw email reply body do not match code
  changes
--

commit d8ecd786cfd0874e564c2e769446a7a6d1cd1f7f
Author: Zhao Gongyi <zhaogongyi@bytedance.com>

> ext4: use a stable source for the kmmpd thread name
>
> Hi Jan,
>
> On 11/16/26 8:16 PM, Jan Kara wrote:
> > What can change it? I don't see anything that should be doing that...
>
> A concurrent buffered write to the loop block device can change it. In
> one diagnostic run, the write reached the page-cache buffer ext4 was
> using for MMP. mmp_bdevname is embedded at bh->b_data + 0x50.
>
> In an x86 QEMU diagnostic run based on commit
> 7475ea8b58616b33c04afb976cf0fbaad9dd63fb, kvasprintf() first read
> "loop0" at ffff888013e1d050. A kprobe on mark_buffer_dirty() then
> fired for a buffer starting at ffff888013e1d000, covering that field.
> The stack was:
>
>    ksys_write -> blkdev_write_iter -> blkdev_buffered_write
>      -> iomap_file_buffered_write -> iomap_write_end
>      -> block_write_end -> block_commit_write -> mark_buffer_dirty
>
> The buffered write path copies data into the page cache before
> block_commit_write(). About one second later, the same source page
> contained an empty string, and kvasprintf() reported return values 11
> and 6. The kprobe records the buffer being dirtied; it does not trap
> the byte-copy instruction itself. My earlier description of a
> concurrent MMP mount changing the name was imprecise.
>
> The original syzkaller manager report shows the warning on an
> unmodified kernel. Standalone QEMU replays without a delay did not hit
> it reliably. To obtain the trace above, I used a diagnostic build with
> a one-second delay after the first vsnprintf() pass, source snapshots,
> an exported MMP buffer address, and a kprobe module. The attached
> test-only delay patch widens the window but does not collect the writer
> trace by itself. None of this diagnostic code is part of the proposed fix.
>
> The attached repro.syz is input to syz-execprog. I ran it in the guest with:
>
>    /root/syz-execprog -executor=/root/syz-executor -arch=amd64 \
>      -sandbox=none -procs=12 -repeat=0 -threaded=true -slowdown=1 \
>      -sandbox_arg=0 -type=qemu /root/repro.syz
>
> I understand that raw writes to a block device during ext4 access can
> corrupt metadata. The proposed change gives the two-pass thread-name
> formatting a stable source; it does not change MMP's protection logic.
> I can provide the full diagnostic diff, kprobe module, and console log
> if useful.
>
> Thanks,
> Gongyi
>
> This is a reproducer-only delay patch for validating:
>
>         WARNING in __kthread_create_on_node
>         different return values (11 and 6) from vsnprintf("kmmpd-%.*s", ...)
>
> The first delay patch only matched "kmmpd-%.*s".  That made the A side
> easy to reproduce, but after applying the fix the B side uses
> "kmmpd-%s" and therefore did not hit the same artificial kvasprintf()
> delay window.
>
> Delay both old and fixed kmmpd thread-name formats after kvasprintf()'s
> first vsnprintf() pass.  With this patch, A verifies that the original
> buffer-backed string can change during the widened window, while B uses
> the same widened kvasprintf() window but passes the fixed stack-backed
> string source.
>
> Do not use this patch as a fix and do not ship it outside validation.

[Severity: High]
The commit message is missing a Signed-off-by: trailer.

[Severity: Medium]
Does the commit subject and message match the code change?  The title claims
to provide a stable source for the ext4 kmmpd thread name and the body
contains a mailing-list reply concatenated with validation notes, while the
diff only modifies lib/kasprintf.c.

> diff --git a/lib/kasprintf.c b/lib/kasprintf.c
> index cd2f5974ed987..77cbf8a1cbdd4 100644
> --- a/lib/kasprintf.c
> +++ b/lib/kasprintf.c
> @@ -7,6 +7,7 @@
>  
>  #include <linux/stdarg.h>
>  #include <linux/export.h>
> +#include <linux/delay.h>
>  #include <linux/slab.h>
>  #include <linux/types.h>
>  #include <linux/string.h>
> @@ -22,6 +23,15 @@ char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
>  	first = vsnprintf(NULL, 0, fmt, aq);
>  	va_end(aq);
>  
> +	/*
> +	 * Reproducer-only delay.  Cover both the original ext4 MMP thread-name
> +	 * format and the fixed format so A and B execute the same widened
> +	 * kvasprintf() window.
> +	 */
> +	if (!strcmp(fmt, "kmmpd-%.*s") ||
> +	    !strcmp(fmt, "kmmpd-%s"))
> +		msleep(1000);

[Severity: High]
Was this reproducer-only delay patch committed instead of the ext4 fix in
ext4_multi_mount_protect()?

Rather than stabilizing the thread name in fs/ext4/mmp.c, this regression
adds an unconditional msleep(1000) between the two vsnprintf() passes in
kvasprintf().  It stalls every ext4 MMP mount by one second, widens the race
window that triggers the vsnprintf() mismatch warning, and sleeps without
checking whether gfp allows blocking.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/da634961-1d13-4d21-b181-f366fd72e0d1@bytedance.com?part=1

      reply	other threads:[~2026-11-16 16:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 17:25 [PATCH] ext4: use a stable source for the kmmpd thread name Zhao Gongyi
2026-11-14 17:32 ` sashiko-bot
2026-11-16 12:16 ` Jan Kara
2026-11-16 16:36   ` Zhao Gongyi
2026-11-16 16:42     ` sashiko-bot [this message]

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=sashiko-outbox-217372@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    --cc=zhaogongyi@bytedance.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox