From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755812AbbLWCtN (ORCPT ); Tue, 22 Dec 2015 21:49:13 -0500 Received: from mail-ig0-f181.google.com ([209.85.213.181]:38047 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752638AbbLWCtL (ORCPT ); Tue, 22 Dec 2015 21:49:11 -0500 From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Kent Overstreet , "Artem S. Tashkinov" , Linus Torvalds , Ming Lei Subject: [PATCH] block: warn once for cloned bio in bio_for_each_segment_all() Date: Wed, 23 Dec 2015 10:48:45 +0800 Message-Id: <1450838925-7247-1-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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