Skip to content

Commit cc90bc6

Browse files
Andreas Gruenbacheraxboe
Andreas Gruenbacher
authored andcommitted
block: fix "check bi_size overflow before merge"
This partially reverts commit e3a5d8e. Commit e3a5d8e ("check bi_size overflow before merge") adds a bio_full check to __bio_try_merge_page. This will cause __bio_try_merge_page to fail when the last bi_io_vec has been reached. Instead, what we want here is only the bi_size overflow check. Fixes: e3a5d8e ("block: check bi_size overflow before merge") Cc: [email protected] # v5.4+ Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent dc3ecfc commit cc90bc6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

block/bio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,12 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,
754754
if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
755755
return false;
756756

757-
if (bio->bi_vcnt > 0 && !bio_full(bio, len)) {
757+
if (bio->bi_vcnt > 0) {
758758
struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
759759

760760
if (page_is_mergeable(bv, page, len, off, same_page)) {
761+
if (bio->bi_iter.bi_size > UINT_MAX - len)
762+
return false;
761763
bv->bv_len += len;
762764
bio->bi_iter.bi_size += len;
763765
return true;

0 commit comments

Comments
 (0)