Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756175AbdDFMDh (ORCPT ); Thu, 6 Apr 2017 08:03:37 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36416 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755704AbdDFMC6 (ORCPT ); Thu, 6 Apr 2017 08:02:58 -0400 From: Dmitry Monakhov To: linux-kernel@vger.kernel.org Cc: darrick.wong@oracle.com, axboe@kernel.dk, tytso@mit.edu, jack@suse.cz, hch@infradead.org, Dmitry Monakhov Subject: [PATCH 3/5] bio: Protect submit_bio from bdevless bio-s Date: Thu, 6 Apr 2017 16:02:47 +0400 Message-Id: <1491480169-1889-4-git-send-email-dmonakhov@openvz.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1491480169-1889-1-git-send-email-dmonakhov@openvz.org> References: <1491480169-1889-1-git-send-email-dmonakhov@openvz.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 755 Lines: 27 Idially this type of check should be handled at generic_make_request_checks , but it is too late for bdevless bios, bad pointer was already dereferenced at that point. Signed-off-by: Dmitry Monakhov --- block/blk-core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index 275c1e4..e583ded 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2065,6 +2065,11 @@ EXPORT_SYMBOL(generic_make_request); */ blk_qc_t submit_bio(struct bio *bio) { + if (WARN_ON_ONCE(!bio->bi_bdev)) { + bio_io_error(bio); + return BLK_QC_T_NONE; + } + /* * If it's a regular read/write or a barrier with data attached, * go through the normal accounting stuff before submission. -- 2.9.3