From: John Ogness <john.ogness@linutronix.de>
To: Petr Mladek <pmladek@suse.com>
Cc: Joanne Koong <joannelkoong@gmail.com>,
syzbot <syzbot+3686758660f980b402dc@syzkaller.appspotmail.com>,
"amurray@thegoodpenguin.co.uk" <amurray@thegoodpenguin.co.uk>,
brauner@kernel.org, chao@kernel.org, djwong@kernel.org,
jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-xfs@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [iomap?] kernel BUG in folio_end_read (2)
Date: Wed, 05 Nov 2025 21:04:02 +0106 [thread overview]
Message-ID: <87bjlgqmk5.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <aQuABK25fdBVTGZc@pathway.suse.cz>
On 2025-11-05, Petr Mladek <pmladek@suse.com> wrote:
> I guess that we should do:
>
> From f9cae42b4a910127fb7694aebe2e46247dbb0fcb Mon Sep 17 00:00:00 2001
> From: Petr Mladek <pmladek@suse.com>
> Date: Wed, 5 Nov 2025 17:14:57 +0100
> Subject: [PATCH] printk_ringbuffer: Fix check of valid data size when blk_lpos
> overflows
>
> The commit 67e1b0052f6bb8 ("printk_ringbuffer: don't needlessly wrap
> data blocks around") allows to use the last 4 bytes of the ring buffer.
>
> But the check for the data_size was not properly updated. It fails
> when blk_lpos->next overflows to "0". In this case:
>
> + is_blk_wrapped(data_ring, blk_lpos->begin, blk_lpos->next)
> returns false because it checks "blk_lpos->next - 1"
>
> + but "blk_lpos->begin < blk_lpos->next" fails because
> blk_lpos->next is already 0.
>
> + is_blk_wrapped(data_ring, blk_lpos->begin + DATA_SIZE(data_ring),
> blk_lpos->next) returns false because "begin_lpos" is from
> next wrap but "next_lpos - 1" is from the previous one
>
> As a result, get_data() triggers the WARN_ON_ONCE() for "Illegal
> block description", for example:
Beautiful catch!
> Another question is whether this is the only problem caused the patch.
This comparison is quite special. It caught my attention while combing
through the code. Sadly, I missed this fix despite staring at the
problem. I was more concerned about making sure it could handle wraps
correctly without realizing it was an incorrect range check.
Tomorrow I will recomb through again, this time verifying all the range
checks.
> It might help to fill messages with a fixed size which might trigger
> blk_lpos->next == 0 in the 1st wrap.
I did this and indeed it reproduces the WARN_ON_ONCE() when next==0. And
with your patch applied, the warning is gone.
John
next prev parent reply other threads:[~2025-11-05 19:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 13:13 [syzbot] [f2fs?] kernel BUG in folio_end_read (2) syzbot
2025-11-01 2:11 ` [syzbot] [iomap?] " syzbot
2025-11-03 16:58 ` Joanne Koong
2025-11-04 2:43 ` syzbot
2025-11-04 17:45 ` Joanne Koong
2025-11-04 18:25 ` Petr Mladek
2025-11-05 14:54 ` John Ogness
2025-11-05 16:49 ` Petr Mladek
2025-11-05 19:58 ` John Ogness [this message]
2025-11-06 11:36 ` John Ogness
2025-11-06 16:22 ` Petr Mladek
2025-11-06 18:58 ` John Ogness
2025-11-06 19:36 ` John Ogness
2025-11-07 11:48 ` Petr Mladek
2025-11-07 13:41 ` John Ogness
2025-11-02 5:39 ` syzbot
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=87bjlgqmk5.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=amurray@thegoodpenguin.co.uk \
--cc=brauner@kernel.org \
--cc=chao@kernel.org \
--cc=djwong@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=joannelkoong@gmail.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=syzbot+3686758660f980b402dc@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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