When a polled bio is split across a target boundary (for example a dm-striped chunk boundary), dm_split_and_process_bio() re-submits the trimmed remainder of the original bio and then calls dm_queue_poll_io(), which sets REQ_DM_POLL_LIST (aliased to REQ_DRV) on the original bio. When the remainder subsequently enters dm_split_and_process_bio(), alloc_io() clones it into the embedded io->tio.clone, inheriting REQ_DM_POLL_LIST. alloc_tio() only clears REQ_DM_POLL_LIST in its else branch for non-embedded clones, leaving REQ_DRV set on the embedded clone that polled normal I/O uses. The leaked REQ_DRV flag is misinterpreted by lower layers. On NVMe (where REQ_NVME_MPATH is also defined as REQ_DRV), nvme_start_request() calls nvme_mpath_start_request(). For a single-path namespace where ns->head->disk is NULL (with CONFIG_NVME_MULTIPATH=y), dereferencing disk->queue triggers a kernel NULL pointer dereference: BUG: kernel NULL pointer dereference, address: 0000000000000050 RIP: 0010:nvme_mpath_start_request+0x28/0xc0 Call Trace: nvme_prep_rq+0x5e0/0xa90 nvme_queue_rq+0x40/0x1a0 __blk_mq_issue_directly+0x45/0xb0 blk_mq_try_issue_directly+0x85/0x100 blk_mq_submit_bio+0x6c9/0x710 submit_bio_noacct_nocheck+0x127/0x330 blkdev_direct_IO+0x230/0x680 On stacked DM devices, a lower DM layer also sees REQ_DM_POLL_LIST already set on the incoming clone and treats its bi_private as a dm_io poll list head. Move the REQ_DM_POLL_LIST clear out of the else branch in alloc_tio() so it applies to both embedded and non-embedded clones. Fixes: b99fdcdc3636 ("dm: support bio polling") Cc: stable@vger.kernel.org Signed-off-by: Louis Thiery --- drivers/md/dm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 1881d8611..79972f17f 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -628,13 +628,13 @@ static struct bio *alloc_tio(struct clone_info *ci, struct dm_target *ti, if (!clone) return NULL; - /* REQ_DM_POLL_LIST shouldn't be inherited */ - clone->bi_opf &= ~REQ_DM_POLL_LIST; - tio = clone_to_tio(clone); tio->flags = 0; /* also clears DM_TIO_INSIDE_DM_IO */ } + /* REQ_DM_POLL_LIST shouldn't be inherited */ + clone->bi_opf &= ~REQ_DM_POLL_LIST; + tio->magic = DM_TIO_MAGIC; tio->io = ci->io; tio->ti = ti; -- 2.43.0