Skip to content

Commit 3eb9694

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: make bio_check_eod work for zero sized devices
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: 9fe95ba ("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>
1 parent 46930b7 commit 3eb9694

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static inline int bio_check_eod(struct bio *bio)
520520
sector_t maxsector = bdev_nr_sectors(bio->bi_bdev);
521521
unsigned int nr_sectors = bio_sectors(bio);
522522

523-
if (nr_sectors && maxsector &&
523+
if (nr_sectors &&
524524
(nr_sectors > maxsector ||
525525
bio->bi_iter.bi_sector > maxsector - nr_sectors)) {
526526
pr_info_ratelimited("%s: attempt to access beyond end of device\n"

0 commit comments

Comments
 (0)