lkml.org 
[lkml]   [2015]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] block: warn once for cloned bio in bio_for_each_segment_all()
Date
For one cloned bio, kernel shouldn't touch all segments of this
bio via the helper, because the bvec table is shared among all
related bios, so warn once for this usage.

This change should catch recent memory corruption issue, which is
fixed by 23688bf4f830(block: ensure to split after potentially
bouncing a bio).

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
include/linux/bio.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/linux/bio.h b/include/linux/bio.h
index b9b6e04..b4a298d 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -191,6 +191,7 @@ static inline void *bio_data(struct bio *bio)
* before it got to the driver and the driver won't own all of it
*/
#define bio_for_each_segment_all(bvl, bio, i) \
+ WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); \
for (i = 0, bvl = (bio)->bi_io_vec; i < (bio)->bi_vcnt; i++, bvl++)

static inline void bvec_iter_advance(struct bio_vec *bv, struct bvec_iter *iter,
--
1.9.1


\
 
 \ /
  Last update: 2015-12-23 04:01    [W:0.096 / U:0.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site