Skip to content

Commit ab073ab

Browse files
committed
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: d0a2b52 ("block: tone down bio_check_eod") Tested-by: Sahil Chandna <chandna.linuxkernel@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 027a7a9 commit ab073ab

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

block/blk-core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,11 @@ static inline int bio_check_eod(struct bio *bio)
557557
sector_t maxsector = bdev_nr_sectors(bio->bi_bdev);
558558
unsigned int nr_sectors = bio_sectors(bio);
559559

560-
if (nr_sectors && maxsector &&
560+
if (nr_sectors &&
561561
(nr_sectors > maxsector ||
562562
bio->bi_iter.bi_sector > maxsector - nr_sectors)) {
563+
if (!maxsector)
564+
return -EIO;
563565
pr_info_ratelimited("%s: attempt to access beyond end of device\n"
564566
"%pg: rw=%d, sector=%llu, nr_sectors = %u limit=%llu\n",
565567
current->comm, bio->bi_bdev, bio->bi_opf,

0 commit comments

Comments
 (0)