Message ID | 20231204173419.782378-2-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] block: prevent an integer overflow in bvec_try_merge_hw_page | expand |
diff --git a/block/bio.c b/block/bio.c index 816d412c06e9b4..cef830adbc06e0 100644 --- a/block/bio.c +++ b/block/bio.c @@ -944,7 +944,7 @@ bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv, if ((addr1 | mask) != (addr2 | mask)) 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 bvec_try_merge_page(bv, page, len, offset, same_page); }
Reordered a check to avoid a possible overflow when adding len to bv_len. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)