]> git.karo-electronics.de Git - linux-beck.git/commitdiff
block: Fix a buffer overrun in bio_integrity_split()
authorKent Overstreet <koverstreet@google.com>
Fri, 12 Oct 2012 20:18:27 +0000 (13:18 -0700)
committerKent Overstreet <koverstreet@google.com>
Sat, 23 Mar 2013 21:15:26 +0000 (14:15 -0700)
bio_integrity_split() seemed to be confusing pointers and arrays -
bip_vec in bio_integrity_payload was an array appended to the end of the
payload, so the bio_vecs in struct bio_pair should have come after the
bio_integrity_payload they're for.

Fix it by making bip_vec a pointer to the inline vecs - a later patch is
going to make more use of this pointer.

Signed-off-by: Kent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: Martin K. Petersen <martin.petersen@oracle.com>
fs/bio-integrity.c
include/linux/bio.h

index a3f28f331b2bba7e6653da30dce92adba5d97140..94fa1c562c0efb76b98cdf42d44f38e74bfc4e76 100644 (file)
@@ -112,6 +112,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
 
        bip->bip_slab = idx;
        bip->bip_bio = bio;
+       bip->bip_vec = bip->bip_inline_vecs;
        bio->bi_integrity = bip;
 
        return bip;
@@ -697,8 +698,8 @@ void bio_integrity_split(struct bio *bio, struct bio_pair *bp, int sectors)
        bp->iv1 = bip->bip_vec[0];
        bp->iv2 = bip->bip_vec[0];
 
-       bp->bip1.bip_vec[0] = bp->iv1;
-       bp->bip2.bip_vec[0] = bp->iv2;
+       bp->bip1.bip_vec = &bp->iv1;
+       bp->bip2.bip_vec = &bp->iv2;
 
        bp->iv1.bv_len = sectors * bi->tuple_size;
        bp->iv2.bv_offset += sectors * bi->tuple_size;
index b31036ff779f216d78b8b6ad7c7f8c9b43dacff7..81004fdcc277a4f023d5283433349d90b6b3ba3e 100644 (file)
@@ -182,7 +182,9 @@ struct bio_integrity_payload {
        unsigned short          bip_idx;        /* current bip_vec index */
 
        struct work_struct      bip_work;       /* I/O completion */
-       struct bio_vec          bip_vec[0];     /* embedded bvec array */
+
+       struct bio_vec          *bip_vec;
+       struct bio_vec          bip_inline_vecs[0];/* embedded bvec array */
 };
 #endif /* CONFIG_BLK_DEV_INTEGRITY */