diff options
author | Christoph Hellwig <hch@lst.de> | 2023-12-04 20:34:18 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-02-05 23:12:53 +0300 |
commit | 8ae420190058b290639953f393336d7cb4dfa266 (patch) | |
tree | 29b39ec05e24aff2b9b93e5015f61ddb2082e6ee /block/bio.c | |
parent | 44f6b75c095eaf8a545ce301339044b5f1dd9be1 (diff) | |
download | linux-8ae420190058b290639953f393336d7cb4dfa266.tar.xz |
block: prevent an integer overflow in bvec_try_merge_hw_page
[ Upstream commit 3f034c374ad55773c12dd8f3c1607328e17c0072 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block/bio.c')
-rw-r--r-- | block/bio.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/block/bio.c b/block/bio.c index 6c22dd7b6f27..74c2818c7ec9 100644 --- a/block/bio.c +++ b/block/bio.c @@ -927,7 +927,7 @@ static bool bio_try_merge_hw_seg(struct request_queue *q, struct bio *bio, 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 __bio_try_merge_page(bio, page, len, offset, same_page); } |