Commit 3f034c37 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: prevent an integer overflow in bvec_try_merge_hw_page

Reordered a check to avoid a possible overflow when adding len to bv_len.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20231204173419.782378-2-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent f19d1e3b
...@@ -944,7 +944,7 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, ...@@ -944,7 +944,7 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv,
if ((addr1 | mask) != (addr2 | mask)) if ((addr1 | mask) != (addr2 | mask))
return false; return false;
if (bv->bv_len + len > queue_max_segment_size(q)) if (len > queue_max_segment_size(q) - bv->bv_len)
return false; return false;
return bvec_try_merge_page(bv, page, len, offset, same_page); return bvec_try_merge_page(bv, page, len, offset, same_page);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment