]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: copy back bounce buffer to user-space correctly in case of split
authorChristoph Hellwig <hch@lst.de>
Thu, 28 Nov 2024 11:22:32 +0000 (16:52 +0530)
committerJens Axboe <axboe@kernel.dk>
Mon, 23 Dec 2024 15:17:16 +0000 (08:17 -0700)
Copy back the bounce buffer to user-space in entirety when the parent
bio completes. The existing code uses bip_iter.bi_size for sizing the
copy, which can be modified. So move away from that and fetch it from
the vector passed to the block layer. While at it, switch to using
better variable names.

Fixes: 492c5d455969f ("block: bio-integrity: directly map user buffers")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Link: https://lore.kernel.org/r/20241128112240.8867-3-anuj20.g@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio-integrity.c

index a448a25d13dee177075d821f9875abc1a7f2384d..4341b0d4efa16a836ef224b486bb1d3a6212f176 100644 (file)
@@ -118,17 +118,18 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs,
 
 static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
 {
-       unsigned short nr_vecs = bip->bip_max_vcnt - 1;
-       struct bio_vec *copy = &bip->bip_vec[1];
-       size_t bytes = bip->bip_iter.bi_size;
-       struct iov_iter iter;
+       unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1;
+       struct bio_vec *orig_bvecs = &bip->bip_vec[1];
+       struct bio_vec *bounce_bvec = &bip->bip_vec[0];
+       size_t bytes = bounce_bvec->bv_len;
+       struct iov_iter orig_iter;
        int ret;
 
-       iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes);
-       ret = copy_to_iter(bvec_virt(bip->bip_vec), bytes, &iter);
+       iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes);
+       ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter);
        WARN_ON_ONCE(ret != bytes);
 
-       bio_integrity_unpin_bvec(copy, nr_vecs, true);
+       bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true);
 }
 
 /**