From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Keith Busch <kbusch@kernel.org>
Cc: Hari Mishal <harimishal1@gmail.com>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Hannes Reinecke <hare@suse.de>,
Kanchan Joshi <joshi.k@samsung.com>,
Nitesh Shetty <nj.shetty@samsung.com>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] nvme: drop WARN_ON_ONCE on write_stream bounds check
Date: Tue, 28 Jul 2026 07:15:28 +0200 [thread overview]
Message-ID: <2026072849-uproar-aqua-07c3@gregkh> (raw)
In-Reply-To: <amfg_OFiyDadWb3v@kbusch-mbp>
On Mon, Jul 27, 2026 at 04:51:40PM -0600, Keith Busch wrote:
> On Mon, Jul 27, 2026 at 09:19:27PM +0200, Greg Kroah-Hartman wrote:
> > On Mon, Jul 27, 2026 at 08:24:40AM -0600, Keith Busch wrote:
> > > On Sat, Jul 25, 2026 at 03:51:11PM +0200, Hari Mishal wrote:
> > > > write_stream is validated against bdev_max_write_streams() in both
> > > > generic block direct I/O (block/fops.c) and F2FS before a bio
> > > > carrying it is ever built, so write_stream > nr_plids shouldn't be
> > > > reachable through any current legitimate path. The remaining users
> > > > of bio->bi_write_stream elsewhere in the block layer only copy an
> > > > already-validated value between bios (bio.c, blk-crypto-fallback.c)
> > > > or compare it for merge eligibility (blk-merge.c); none of them
> > > > introduce a new, unvalidated value.
> > > >
> > > > Using WARN_ON_ONCE as the backstop for that assumption isn't worth
> > > > it given how many deployed systems run with panic-on-warn enabled;
> > > > the existing graceful return BLK_STS_INVAL already handles it on
> > > > its own.
> > >
> > > That's not a very good reason to remove a WARN_ON. You've left the check
> > > in for a condition that should never happen, so when it does happen,
> > > it'll be impossible to debug without the WARN.
> > >
> > > And the WARN also annotates the branch as unlikely, which is desirable
> > > for this case.
> >
> > But, if it ever does happen, a WARN_ON will reboot the box, given that
> > billions of Linux systems have panic-on-warn enabled.
>
> So WARN_ON is the new BUG_ON now?
It has been that way since syzbot started sending us reports (i.e. for
many many years...)
> If the condition happens we need to
> know how we got here and make it obvious something is wrong. So I guess
> we'd have to replace every one of these:
>
> if (WARN_ON_ONCE(condition)) ...
>
> With an open-coded version like:
>
> if (unlikely(condition)) {
> do_once(dump_stack());
> ...
> }
>
> ?
Yes, if userspace can trigger this. Because again, this will cause a
box to reboot.
If we didn't have panic-on-warn, a ton of CVEs would just disappear
tomorrow. But that's not the world we live in :(
> That doesn't seem right, so if that is the suggestion, then I think we
> need a new macro to provide the result that the WARN_ON usage expected.
You can provide a tracedump if you really need/want it, no need to call
WARN_ON(), the macro is there for you to use.
> > So if this can ever happen,
>
> But it can't ever happen. This patch's commit message reasoned that as
> justification to remove the warn, but we need to know how we got here
> when it does happen because it means somebody broke contract.
Fair enough, but note that if userspace can trigger this, it should be
fixed up. See the other WARN_ON patch fix for nvme that I sent yesterday
for an example of userspace being able to trigger this type of issue:
https://lore.kernel.org/r/20260727-nvme-tcp-v1-1-61c0e36763eb@linuxfoundation.org
> > just properly handle it and recover and don't loose user
> > data.
>
> We can't save the data from this specific condition: the data from the
> request is unwritable and lost. We've also learned that EINVAL errors
> are not handled for many DM stacking drivers in very bad ways, so again,
> we need to know how we got here when something breaks the API contract
> otherwise it'll be a difficult problem to debug without that visibility.
Ok, if you want to keep this here, that's fine, because you know you
can't recover properly and crashing the system is the only acceptable
thing to do. But in that case, why not make it a BUG_ON()?
thanks,
greg k-h
next prev parent reply other threads:[~2026-07-28 5:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 13:51 [PATCH 0/2] nvme: fix racy access to FDP placement ID array Hari Mishal
2026-07-25 13:51 ` [PATCH 1/2] " Hari Mishal
2026-07-27 13:31 ` Kanchan Joshi
2026-07-27 14:22 ` Kanchan Joshi
2026-07-25 13:51 ` [PATCH 2/2] nvme: drop WARN_ON_ONCE on write_stream bounds check Hari Mishal
2026-07-27 14:24 ` Keith Busch
2026-07-27 19:19 ` Greg Kroah-Hartman
2026-07-27 22:51 ` Keith Busch
2026-07-28 5:15 ` Greg Kroah-Hartman [this message]
2026-07-28 5:18 ` Christoph Hellwig
2026-07-28 6:58 ` Greg Kroah-Hartman
2026-07-28 9:46 ` Keith Busch
2026-07-28 10:34 ` Greg Kroah-Hartman
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=2026072849-uproar-aqua-07c3@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=harimishal1@gmail.com \
--cc=hch@lst.de \
--cc=joshi.k@samsung.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nj.shetty@samsung.com \
--cc=sagi@grimberg.me \
/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