Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: fix EOD return for device with nr_sectors == 0

A recent commit skipped dumping the usual "attempt to access beyond end
of device" message if the device size is 0 sectors, as that's a common
pattern for devices that have been hot removed. But while it stopped
that message, it also prevented returning -EIO for that condition.
Reinstate the -EIO return, while retaining the quiet operation for
triggering EOD for a device with 0 sectors.

Reported-by: syzbot+4b12286339fe4c2700c1@syzkaller.appspotmail.com
Reported-by: Sahil Chandna <chandna.linuxkernel@gmail.com>
Fixes: d0a2b527d8c3 ("block: tone down bio_check_eod")
Tested-by: Sahil Chandna <chandna.linuxkernel@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

+3 -1
+3 -1
block/blk-core.c
··· 557 557 sector_t maxsector = bdev_nr_sectors(bio->bi_bdev); 558 558 unsigned int nr_sectors = bio_sectors(bio); 559 559 560 - if (nr_sectors && maxsector && 560 + if (nr_sectors && 561 561 (nr_sectors > maxsector || 562 562 bio->bi_iter.bi_sector > maxsector - nr_sectors)) { 563 + if (!maxsector) 564 + return -EIO; 563 565 pr_info_ratelimited("%s: attempt to access beyond end of device\n" 564 566 "%pg: rw=%d, sector=%llu, nr_sectors = %u limit=%llu\n", 565 567 current->comm, bio->bi_bdev, bio->bi_opf,