aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/block/bio.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-12-04 18:34:18 +0100
committerJens Axboe <axboe@kernel.dk>2023-12-15 07:34:27 -0700
commit3f034c374ad55773c12dd8f3c1607328e17c0072 (patch)
tree63d40bdc2f1ccf202c00d9edf11aeeb207943179 /block/bio.c
parentblock: Use pr_info() instead of printk(KERN_INFO ...) (diff)
downloadwireguard-linux-3f034c374ad55773c12dd8f3c1607328e17c0072.tar.xz
wireguard-linux-3f034c374ad55773c12dd8f3c1607328e17c0072.zip
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20231204173419.782378-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bio.c')
-rw-r--r--block/bio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/bio.c b/block/bio.c
index 5eba53ca953b..270f6b99926e 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);
}