Re: WARNING in submit_bio_checks

From: Eric Biggers
Date: Mon Jul 13 2020 - 12:16:18 EST


On Mon, Jul 13, 2020 at 11:18:36AM +0100, Christoph Hellwig wrote:
> On Fri, Jul 10, 2020 at 10:34:19PM -0700, syzbot wrote:
> > Hello,
> >
> > syzbot found the following crash on:
>
> This is not a crash, but a WARN_ONCE. A pre-existing one that just
> slightly changed the printed message recently.
>

It doesn't really matter. WARN is for indicating kernel bugs only.
A user-triggable WARN is a bug. Either the bug that makes the WARN
reachable needs to be fixed, or if the WARN is legitimately user-reachable
it needs to be removed or replaced with a proper ratelimited log message.

This one looks legitimately user-reachable, so we could do:

diff --git a/block/blk-core.c b/block/blk-core.c
index d9d632639bd1..354c51ad5c81 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -854,8 +854,8 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
return false;

- WARN_ONCE(1,
- "Trying to write to read-only block-device %s (partno %d)\n",
+ pr_warn_ratelimited(
+ "block: trying to write to read-only block-device %s (partno %d)\n",
bio_devname(bio, b), part->partno);
/* Older lvm-tools actually trigger this */
return false;


We could also show current->comm and current->pid if they would be useful here.

And yes, this is preexisting which is why syzbot has reported this before
(https://syzkaller.appspot.com/bug?id=79eda145ab047a0dc7d03ca5fcb1cf12206eb481).
Just no one has bothered to fix it yet.

- Eric