From: "Miguel García" <miguelgarciaroman8@gmail.com>
To: stable@vger.kernel.org
Cc: gregkh@linuxfoundation.org, sashal@kernel.org, axboe@kernel.dk,
hch@lst.de, linux-block@vger.kernel.org,
syzbot+b8d61a58b7c7ebd2c8e0@syzkaller.appspotmail.com,
syzbot+2aca91e1d3ae43aef10c@syzkaller.appspotmail.com,
"Miguel García" <miguelgarciaroman8@gmail.com>
Subject: [PATCH 6.1.y v2] block: make bio_check_eod work for zero sized devices
Date: Sat, 29 Aug 2026 19:19:18 +0200 [thread overview]
Message-ID: <20260829171918.134829-1-miguelgarciaroman8@gmail.com> (raw)
In-Reply-To: <2025041215-grudge-rearrange-7123@gregkh>
From: Christoph Hellwig <hch@lst.de>
commit 3eb96946f0be6bf447cbdf219aba22bc42672f92 upstream.
Since the dawn of time bio_check_eod has a check for a non-zero size of
the device. This doesn't really make any sense as we never want to send
I/O to a device that's been set to zero size, or never moved out of that.
I am a bit surprised we haven't caught this for a long time, but the
removal of the extra validation inside of zram caused syzbot to trip
over this issue recently. I've added a Fixes tag for that commit, but
the issue really goes back way before git history.
Fixes: 9fe95babc742 ("zram: remove valid_io_request")
Reported-by: syzbot+b8d61a58b7c7ebd2c8e0@syzkaller.appspotmail.com
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230524060538.1593686-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Backport note for 6.1.y:
The same underlying bug affects 6.1.y even though 9fe95babc742 is not in
that tree. The syzbot reproducer attaches a socket to /dev/nbd0 without
setting its capacity, then mounts it as BEFS. BEFS calls sb_bread() while
bdev_nr_sectors() is zero. The maxsector guard makes bio_check_eod() accept
that read, which reaches NBD and waits for a response instead of failing
with -EIO. syzbot reproduced the resulting __bread_gfp() hang on 6.1.y and
identified this upstream commit by fix bisection.
Reported-by: syzbot+2aca91e1d3ae43aef10c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2aca91e1d3ae43aef10c
Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>
---
Changes in v2:
- Explain the 6.1.y NBD and BEFS failure path, as requested by Greg:
https://lore.kernel.org/r/2025041215-grudge-rearrange-7123@gregkh
- Preserve both syzbot reports and the upstream commit metadata.
- Refresh against v6.1.186.
Older stable trees are not included here because this backport and its local
validation are scoped to the syzbot report for 6.1.y.
v1: https://lore.kernel.org/r/20250412102424.56383-1-miguelgarciaroman8@gmail.com
block/blk-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 25b4733..1fcd80a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -515,7 +515,7 @@ static inline int bio_check_eod(struct bio *bio)
sector_t maxsector = bdev_nr_sectors(bio->bi_bdev);
unsigned int nr_sectors = bio_sectors(bio);
- if (nr_sectors && maxsector &&
+ if (nr_sectors &&
(nr_sectors > maxsector ||
bio->bi_iter.bi_sector > maxsector - nr_sectors)) {
pr_info_ratelimited("%s: attempt to access beyond end of device\n"
--
2.43.0
next parent reply other threads:[~2026-08-29 17:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2025041215-grudge-rearrange-7123@gregkh>
2026-08-29 17:19 ` Miguel García [this message]
2026-08-31 1:39 ` [PATCH 6.1.y v2] block: make bio_check_eod work for zero sized devices Sasha Levin
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=20260829171918.134829-1-miguelgarciaroman8@gmail.com \
--to=miguelgarciaroman8@gmail.com \
--cc=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+2aca91e1d3ae43aef10c@syzkaller.appspotmail.com \
--cc=syzbot+b8d61a58b7c7ebd2c8e0@syzkaller.appspotmail.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