diff options
| author | Jens Axboe <axboe@kernel.dk> | 2025-09-22 05:55:41 -0600 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2025-09-22 09:35:24 -0600 |
| commit | ab073abf6d974d3fe998fc6731ca80e2b57ffd69 (patch) | |
| tree | 169af8e48ec78fa5a84bfc13d7754e6afd81d030 | |
| parent | drbd: init queue_limits->max_hw_wzeroes_unmap_sectors parameter (diff) | |
| download | linux-ab073abf6d974d3fe998fc6731ca80e2b57ffd69.tar.gz linux-ab073abf6d974d3fe998fc6731ca80e2b57ffd69.zip | |
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>
| -rw-r--r-- | block/blk-core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 4201504158a1..a27185cd8ede 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -557,9 +557,11 @@ 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)) { + if (!maxsector) + return -EIO; pr_info_ratelimited("%s: attempt to access beyond end of device\n" "%pg: rw=%d, sector=%llu, nr_sectors = %u limit=%llu\n", current->comm, bio->bi_bdev, bio->bi_opf, |
