Re: [dm-devel] [PATCH v3 01/26] block: Fix a buffer overrun in bio_integrity_split()

From
Vivek Goyal <hidden>
Date
2012-10-01 21:23:50
Also in
dm-devel, lkml
Reply to
Kent Overstreet, 2012-09-24
On Mon, Sep 24, 2012 at 03:34:41PM -0700, Kent Overstreet wrote:
quoted hunk ↗ jump to hunk
bio_integrity_split() seemed to be confusing pointers and arrays -
bip_vec in bio_integrity_payload is an array appended to the end of the
payload, so the bio_vecs in struct bio_pair need to come immediately
after the bio_integrity_payload they're for, and there was an assignment
in bio_integrity_split() that didn't make any sense.

Signed-off-by: Kent Overstreet <redacted>
CC: Jens Axboe <redacted>
CC: Martin K. Petersen <redacted>
---
 fs/bio-integrity.c  | 3 ---
 include/linux/bio.h | 6 ++++--
 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index a3f28f3..c7b6b52 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -697,9 +697,6 @@ 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->iv1.bv_len = sectors * bi->tuple_size;
 	bp->iv2.bv_offset += sectors * bi->tuple_size;
 	bp->iv2.bv_len -= sectors * bi->tuple_size;
diff --git a/include/linux/bio.h b/include/linux/bio.h
index b31036f..8e2d108 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -200,8 +200,10 @@ struct bio_pair {
 	struct bio			bio1, bio2;
 	struct bio_vec			bv1, bv2;
 #if defined(CONFIG_BLK_DEV_INTEGRITY)
-	struct bio_integrity_payload	bip1, bip2;
-	struct bio_vec			iv1, iv2;
+	struct bio_integrity_payload	bip1;
+	struct bio_vec			iv1;
+	struct bio_integrity_payload	bip2;
+	struct bio_vec			iv2;
 #endif
I think it probably is a good idea to put a comment here so that we
know that certain elements of structure assume ordering.

Also I am wondering that what's the gurantee that there are no padding
bytes between bipi1 and iv1 (or bip2 or iv2). I think if there are padding
bytes then the assumption that bio_vec is always following bip will be
broken?

Also had a general question about split logic. We seem to have only one
global pool for bio pair (bio_split_pool). So in the IO stack if we split
a bio more than once, we have the deadlock possibility again?

Thanks
Vivek
Thread (68 messages) 68 messages, 7 authors, last reply 2012-10-04
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help