* [PATCH] block: warn once for cloned bio in bio_for_each_segment_all()
@ 2015-12-23 2:48 Ming Lei
2016-01-04 19:21 ` Josh Boyer
0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2015-12-23 2:48 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Kent Overstreet, Artem S. Tashkinov, Linus Torvalds,
Ming Lei
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] block: warn once for cloned bio in bio_for_each_segment_all()
2015-12-23 2:48 [PATCH] block: warn once for cloned bio in bio_for_each_segment_all() Ming Lei
@ 2016-01-04 19:21 ` Josh Boyer
0 siblings, 0 replies; 2+ messages in thread
From: Josh Boyer @ 2016-01-04 19:21 UTC (permalink / raw)
To: Ming Lei
Cc: Jens Axboe, Linux-Kernel@Vger. Kernel. Org, linux-block,
Kent Overstreet, Artem S. Tashkinov, Linus Torvalds
On Tue, Dec 22, 2015 at 9:48 PM, Ming Lei <ming.lei@canonical.com> wrote:
> 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)); \
All this will do is spit out a backtrace. It doesn't prevent the
corruption from happening, and it requires a user to know to report it
upstream. That tends to be iffy, as they're more likely to report the
latest issue found in dmesg, which will have occurred after the
corruption. Is that really the behavior you want?
josh
> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-04 19:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-23 2:48 [PATCH] block: warn once for cloned bio in bio_for_each_segment_all() Ming Lei
2016-01-04 19:21 ` Josh Boyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®