Commit 6fda981cafbf908acd11e1e636fec50e99d56a47
1 parent
df2cb6daa4
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
block: Fix a buffer overrun in bio_integrity_split()
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>
Showing 2 changed files with 6 additions and 3 deletions Side-by-side Diff
fs/bio-integrity.c
... | ... | @@ -112,6 +112,7 @@ |
112 | 112 | |
113 | 113 | bip->bip_slab = idx; |
114 | 114 | bip->bip_bio = bio; |
115 | + bip->bip_vec = bip->bip_inline_vecs; | |
115 | 116 | bio->bi_integrity = bip; |
116 | 117 | |
117 | 118 | return bip; |
... | ... | @@ -697,8 +698,8 @@ |
697 | 698 | bp->iv1 = bip->bip_vec[0]; |
698 | 699 | bp->iv2 = bip->bip_vec[0]; |
699 | 700 | |
700 | - bp->bip1.bip_vec[0] = bp->iv1; | |
701 | - bp->bip2.bip_vec[0] = bp->iv2; | |
701 | + bp->bip1.bip_vec = &bp->iv1; | |
702 | + bp->bip2.bip_vec = &bp->iv2; | |
702 | 703 | |
703 | 704 | bp->iv1.bv_len = sectors * bi->tuple_size; |
704 | 705 | bp->iv2.bv_offset += sectors * bi->tuple_size; |
include/linux/bio.h
... | ... | @@ -182,7 +182,9 @@ |
182 | 182 | unsigned short bip_idx; /* current bip_vec index */ |
183 | 183 | |
184 | 184 | struct work_struct bip_work; /* I/O completion */ |
185 | - struct bio_vec bip_vec[0]; /* embedded bvec array */ | |
185 | + | |
186 | + struct bio_vec *bip_vec; | |
187 | + struct bio_vec bip_inline_vecs[0];/* embedded bvec array */ | |
186 | 188 | }; |
187 | 189 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ |
188 | 190 |