From patchwork Wed Dec 23 02:48:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 7908651 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 948019F350 for ; Wed, 23 Dec 2015 02:49:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB8F620431 for ; Wed, 23 Dec 2015 02:49:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 972012042A for ; Wed, 23 Dec 2015 02:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752702AbbLWCtM (ORCPT ); Tue, 22 Dec 2015 21:49:12 -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 Received: by mail-ig0-f181.google.com with SMTP id jw2so70404137igc.1; Tue, 22 Dec 2015 18:49:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=VHigPBYscul+zK3TRsGsZYR9pg3FO7kvtn28SVQDlRQ=; b=E5o6OMsMBWmT6MpeyBQxDboSin6ckPf1EJ/NYwyJjCNcBxjPXONVv0C2E9n+Z9e0pb uIVo15mQxlHPMBUvYe3CJfgr9Z0GuuNphx0GXk6z97/N+ibYMDQJk0ZCTIijXCDh0mIM +qE9jsMo7k4Np+lyoiEtYB8Lm3B6Tzi+d3yNhp9Xb8GGGwOX3Ckz62eZCpZJTCF4+q7n UOKz10pYUXNfoFFX0Z95aaY4yeDG2AKMBrAJ3PpIMvxaCRnyeQD4E/RMXa4q7+9q9QNl 9OXnbrWP7I686gpHkNOPT3s+EvW3nbZ7RkRrHnNDvkCKqGcBriGiNefLC4Okf0JIrrg2 e2vA== X-Received: by 10.50.49.68 with SMTP id s4mr27540775ign.39.1450838950885; Tue, 22 Dec 2015 18:49:10 -0800 (PST) Received: from localhost (56.34.213.162.lcy-01.canonistack.canonical.com. [162.213.34.56]) by smtp.gmail.com with ESMTPSA id rv1sm11336855igb.15.2015.12.22.18.49.08 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 22 Dec 2015 18:49:09 -0800 (PST) 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-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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,