Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1617912

[PATCH 3/5] bio: Protect submit_bio from bdevless bio-s

From Dmitry Monakhov <dmonakhov@openvz.org>
Newsgroups linux.kernel
Subject [PATCH 3/5] bio: Protect submit_bio from bdevless bio-s
Date 2017-04-06 14:10 +0200
Message-ID <tteoG-8jD-21@gated-at.bofh.it> (permalink)
References <tteoF-8jD-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <dmonakhov@openvz.org>
---
 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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 3/5] bio: Protect submit_bio from bdevless bio-s Dmitry Monakhov <dmonakhov@openvz.org> - 2017-04-06 14:10 +0200

csiph-web