All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm: make sure dm_table is binded before queue request
@ 2022-02-09  9:37 ` Zhang Yi
  0 siblings, 0 replies; 8+ messages in thread
From: Zhang Yi @ 2022-02-09  9:37 UTC (permalink / raw)
  To: dm-devel; +Cc: linux-block, agk, snitzer, axboe, yi.zhang, yukuai3

We found a NULL pointer dereference problem when using dm-mpath target.
The problem is if we submit IO between loading and binding the table,
we could neither get a valid dm_target nor a valid dm table when
submitting request in dm_mq_queue_rq(). BIO based dm target could
handle this case in dm_submit_bio(). This patch fix this by checking
the mapping table before submitting request.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
---
 drivers/md/dm-rq.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index 579ab6183d4d..af2cf71519e9 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -499,8 +499,15 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
 
 	if (unlikely(!ti)) {
 		int srcu_idx;
-		struct dm_table *map = dm_get_live_table(md, &srcu_idx);
-
+		struct dm_table *map;
+
+		map = dm_get_live_table(md, &srcu_idx);
+		if (!map) {
+			DMERR_LIMIT("%s: mapping table unavailable, erroring io",
+				    dm_device_name(md));
+			dm_put_live_table(md, srcu_idx);
+			return BLK_STS_IOERR;
+		}
 		ti = dm_table_find_target(map, 0);
 		dm_put_live_table(md, srcu_idx);
 	}
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-02-28  6:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09  9:37 [PATCH] dm: make sure dm_table is binded before queue request Zhang Yi
2022-02-09  9:37 ` [dm-devel] " Zhang Yi
2022-02-14  8:29 ` Zhang Yi
2022-02-14  8:29   ` [dm-devel] " Zhang Yi
2022-02-22 18:27 ` Mike Snitzer
2022-02-22 18:27   ` [dm-devel] " Mike Snitzer
2022-02-23 12:34   ` Zhang Yi
2022-02-23 12:34     ` [dm-devel] " Zhang Yi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.