From patchwork Tue May 22 23:55:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10419769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 86486601E8 for ; Tue, 22 May 2018 23:55:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C04128E56 for ; Tue, 22 May 2018 23:55:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E28728E4B; Tue, 22 May 2018 23:55:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D11928E5E for ; Tue, 22 May 2018 23:55:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753308AbeEVXzH (ORCPT ); Tue, 22 May 2018 19:55:07 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:50355 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753268AbeEVXzG (ORCPT ); Tue, 22 May 2018 19:55:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1527033306; x=1558569306; h=from:to:cc:subject:date:message-id; bh=OF40uMuurKmEmsMsna39wXcQW+E7uaUbUb56o/BSE5s=; b=mhU06Rb7A1uBIjByatqyPMYHxCFc7gtkcrPt/afL5Zo8HzBTCPmOCjyU I9mNp5b0yv+CHfwgr5eNhaWiQz/zd7UpS9YB1owZ32weDxiDEr2aerjjM d3+avoaRruYlZ0zXgHYMq+u/DegFSo8GlpOFgvZJQHsQZeZu+g7ps1rQr qa3P0UCrP9Ka8Kcz4+4MBacssTJ7eXIp27XV1Az+MJ2rx5PfrqmAHof0A li/ilKCuThkWyuZkA1EaK6UHz7xGnrRgoXiu2nAhaWRdi3bLc7u6nDVY/ pmGlgKZ6eGhkEbXbrtNAOjV+jJklTzqjNdySf/gRmAtQG68fKHeKMONwA g==; X-IronPort-AV: E=Sophos;i="5.49,431,1520870400"; d="scan'208";a="79600034" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 May 2018 07:55:06 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 22 May 2018 16:46:01 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip01.wdc.com with ESMTP; 22 May 2018 16:55:07 -0700 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Kent Overstreet Subject: [PATCH] Revert "block: Add warning for bi_next not NULL in bio_endio()" Date: Tue, 22 May 2018 16:55:05 -0700 Message-Id: <20180522235505.20937-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.3 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch avoids that KASAN reports the following complaint when running the srp-test software: BUG: KASAN: use-after-free in bio_advance+0x110/0x1b0 Read of size 4 at addr ffff88014c7aa950 by task ksoftirqd/10/72 Call Trace: dump_stack+0x9a/0xeb print_address_description+0x65/0x270 kasan_report+0x232/0x350 bio_advance+0x110/0x1b0 blk_update_request+0x9d/0x5a0 scsi_end_request+0x4c/0x300 [scsi_mod] scsi_io_completion+0x71e/0xa40 [scsi_mod] __blk_mq_complete_request+0x13e/0x220 srp_recv_done+0x454/0x1100 [ib_srp] __ib_process_cq+0x9a/0xf0 [ib_core] ib_poll_handler+0x2d/0x90 [ib_core] irq_poll_softirq+0xe5/0x1e0 __do_softirq+0x112/0x5f0 run_ksoftirqd+0x29/0x50 smpboot_thread_fn+0x30f/0x410 kthread+0x1b2/0x1d0 ret_from_fork+0x24/0x30 This reverts commit 0ba99ca4838bc75481a4bf0e70bad20b0a5457c7. Fixes: commit 45db54d58de0 ("block: Split out bio_list_copy_data()") Signed-off-by: Bart Van Assche Cc: Kent Overstreet --- block/bio.c | 3 --- block/blk-core.c | 8 +------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/block/bio.c b/block/bio.c index 0a4df92cd689..e22ebab450f8 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1777,9 +1777,6 @@ void bio_endio(struct bio *bio) if (!bio_integrity_endio(bio)) return; - if (WARN_ONCE(bio->bi_next, "driver left bi_next not NULL")) - bio->bi_next = NULL; - /* * Need to have a real endio function for chained bios, otherwise * various corner cases will break (like stacking block devices that diff --git a/block/blk-core.c b/block/blk-core.c index a216b8b137f4..4d69f91a6431 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -277,10 +277,6 @@ static void req_bio_endio(struct request *rq, struct bio *bio, bio_advance(bio, nbytes); /* don't actually finish bio if it's part of flush sequence */ - /* - * XXX this code looks suspicious - it's not consistent with advancing - * req->bio in caller - */ if (bio->bi_iter.bi_size == 0 && !(rq->rq_flags & RQF_FLUSH_SEQ)) bio_endio(bio); } @@ -3115,10 +3111,8 @@ bool blk_update_request(struct request *req, blk_status_t error, struct bio *bio = req->bio; unsigned bio_bytes = min(bio->bi_iter.bi_size, nr_bytes); - if (bio_bytes == bio->bi_iter.bi_size) { + if (bio_bytes == bio->bi_iter.bi_size) req->bio = bio->bi_next; - bio->bi_next = NULL; - } /* Completion has already been traced */ bio_clear_flag(bio, BIO_TRACE_COMPLETION);