From: Lorenzo Stoakes <lstoakes@gmail.com>
To: linux-block@vger.kernel.org,
Dmitry Fomichev <dmitry.fomichev@wdc.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>,
virtualization@lists.linux-foundation.org,
virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org,
Hannes Reinecke <hare@suse.de>, Sam Li <faithilikerun@gmail.com>,
Lorenzo Stoakes <lstoakes@gmail.com>
Subject: [PATCH] virtio-blk: avoid kernel panic on VIRTIO_BLK_F_ZONED check
Date: Wed, 21 Dec 2022 14:00:12 +0000 [thread overview]
Message-ID: <20221221140012.238494-1-lstoakes@gmail.com> (raw)
virtio zoned block device support is added by commit 0562d7bf1604
("virtio-blk: add support for zoned block devices") which adds
VIRTIO_BLK_F_ZONED to the features array in virtio_blk.c but makes it
conditional on CONFIG_BLK_DEV_ZONED.
In it virtblk_probe() calls virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)
unconditionally, which invokes virtio_check_driver_offered_feature().
This function checks whether virtio_blk.feature_table (assigned to
the static features array) contains the specified feature enum, and if not
_causes a kernel panic_ via BUG().
This therefore means that failing to enable CONFIG_BLK_DEV_ZONED while
using virtio is a guaranteed kernel panic. Fix the issue by making the
feature test also conditional on CONFIG_BLK_DEV_ZONED.
Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
---
drivers/block/virtio_blk.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index ff49052e26f7..34fdc141fb21 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -1580,11 +1580,13 @@ static int virtblk_probe(struct virtio_device *vdev)
virtblk_update_capacity(vblk, false);
virtio_device_ready(vdev);
+#ifdef CONFIG_BLK_DEV_ZONED
if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) {
err = virtblk_probe_zoned_device(vdev, vblk, q);
if (err)
goto out_cleanup_disk;
}
+#endif /* CONFIG_BLK_DEV_ZONED */
dev_info(&vdev->dev, "blk config size: %zu\n",
sizeof(struct virtio_blk_config));
--
2.39.0
next reply other threads:[~2022-12-21 14:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-21 14:00 Lorenzo Stoakes [this message]
2022-12-21 14:53 ` [PATCH] virtio-blk: avoid kernel panic on VIRTIO_BLK_F_ZONED check Lorenzo Stoakes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221221140012.238494-1-lstoakes@gmail.com \
--to=lstoakes@gmail.com \
--cc=axboe@kernel.dk \
--cc=damien.lemoal@opensource.wdc.com \
--cc=dmitry.fomichev@wdc.com \
--cc=faithilikerun@gmail.com \
--cc=hare@suse.de \
--cc=jasowang@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox