C Chaitanya Kulkarni #
Message details and related content
The nvme-core sets the bdev to NULL when admin comamnd is issued from IOCTL in the following path e.g. nvme list :- block_ioctl() blkdev_ioctl() nvme_ioctl() nvme_user_cmd() nvme_submit_user_cmd() The commit 309dca309fc3 ("block: store a block_device pointer in struct bio") now uses bdev unconditionally in the macro bio_set_dev() and assumes that bdev value is not NULL which results in the following crash in since thats where bdev is actually accessed :- void bio_associate_blkg_from_css(struct bio *bio, struct cgroup_subsys_state *css) { if (bio->bi_blkg) blkg_put(bio->bi_blkg); if (css && css->parent) { bio->bi_blkg = blkg_tryget_closest(bio, css); } else { --------------> blkg_get(bio->bi_bdev->bd_disk->queue->root_blkg); bio->bi_blkg = bio->bi_bdev->bd_disk->queue->root_blkg; } } EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css); <1>[ 345.385947] BUG: kernel NULL pointer dereference, address: 0000000000000690 <1>[ 345.387103] #PF: supervisor read access in kernel mode <1>[ 345.387894] #PF: error_code(0x0000) - not-present page <6>[ 345.388756] PGD 162a2b067 P4D 162a2b067 PUD 1633eb067 PMD 0 <4>[ 345.389625] Oops: 0000 [#1] SMP NOPTI <4>[ 345.390206] CPU: 15 PID: 4100 Comm: nvme Tainted: G OE 5.11.0-rc5blk+ #141 <4>[ 345.391377] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba52764 <4>[ 345.393074] RIP: 0010:bio_associate_blkg_from_css.cold.47+0x58/0x21f <4>[ 345.396362] RSP: 0018:ffffc90000dbbce8 EFLAGS: 00010246 <4>[ 345.397078] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000027
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ba5df80881ea..1a3cdc6b1036 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c@@ -1133,7 +1133,8 @@ static int nvme_submit_user_cmd(struct request_queue *q, if (ret) goto out; bio = req->bio; - bio_set_dev(bio, bdev); + if (bdev) + bio_set_dev(bio, bdev); if (bdev && meta_buffer && meta_len) { meta = nvme_add_user_metadata(bio, meta_buffer, meta_len, meta_seed, write);
--
2.22.1