]> git.hungrycats.org Git - linux/commitdiff
[PATCH] dm-crypt end_io bv_offset fix
authorAndrew Morton <akpm@osdl.org>
Mon, 1 Mar 2004 15:02:51 +0000 (07:02 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 1 Mar 2004 15:02:51 +0000 (07:02 -0800)
From: Christophe Saout <christophe@saout.de>

We should copy the bvec array for read requests so that we still
have the unmodified bvec array to decrypt the data afterwards.

(as discussed earlier this day for highmem bounces)

drivers/md/dm-crypt.c

index 6008824c438c6943ebf63b1ff818da931adeac3e..898f4d04762904dd5c318c9da73ae4ff696e9137 100644 (file)
@@ -593,8 +593,21 @@ crypt_clone(struct crypt_config *cc, struct crypt_io *io, struct bio *bio,
                                return NULL;
                        }
                }
-       } else
-               clone = bio_clone(bio, GFP_NOIO);
+       } else {
+               /*
+                * The block layer might modify the bvec array, so always
+                * copy the required bvecs because we need the original
+                * one in order to decrypt the whole bio data *afterwards*.
+                */
+               clone = bio_alloc(GFP_NOIO, bio_segments(bio));
+               if (clone) {
+                       clone->bi_idx = 0;
+                       clone->bi_vcnt = bio_segments(bio);
+                       clone->bi_size = bio->bi_size;
+                       memcpy(clone->bi_io_vec, bio_iovec(bio),
+                              sizeof(struct bio_vec) * clone->bi_vcnt);
+               }
+       }
 
        if (!clone)
                return NULL;