]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
block: don't overwrite bip_vcnt in bio_integrity_copy_user()
authorDavid Carlier <devnexen@gmail.com>
Mon, 11 May 2026 21:51:51 +0000 (22:51 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 12 May 2026 15:23:31 +0000 (09:23 -0600)
bio_integrity_add_page() already sets bip_vcnt to 1 for the bounce
segment. Overwriting it with nr_vecs breaks bip_vcnt <= bip_max_vcnt
on WRITE (bip_max_vcnt is 1), so the gap-merge checks in block/blk.h
read past the bip_vec[] flex array. On READ the read is in bounds
but lands on a saved user bvec instead of the bounce.

The line was added for split propagation, but bio_integrity_clone()
doesn't copy bip_vcnt and BIP_CLONE_FLAGS excludes BIP_COPY_USER.

Fixes: 3991657ae707 ("block: set bip_vcnt correctly")
Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260511215151.346228-1-devnexen@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio-integrity.c

index e54c6e06e1cbba6fa64b70c62deb3ad9710b8e03..78e678d4104b69f6602c6253cf42d1c0e52f2bf0 100644 (file)
@@ -308,7 +308,6 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec,
        }
 
        bip->bip_flags |= BIP_COPY_USER;
-       bip->bip_vcnt = nr_vecs;
        return 0;
 free_bip:
        bio_integrity_free(bio);