Skip to content

Commit

Permalink
virtio_p9fs: fix panic on qemu/kvm
Browse files Browse the repository at this point in the history
When the module is loaded on a system running on qemu/kvm the "modern"
virtio infrastructure is used and virtio_read_device_config() will end
up calling vtpci_modern_read_dev_config(). This function cannot read
values of arbitrary sizes and will panic if the p9fs mount tag size is
not supported by it.

Use virtio_read_device_config_array() instead. It was tested on both
bhyve and qemu/kvm.

PR:	280098
Co-authored-by:	Mark Peek <[email protected]>
  • Loading branch information
daniloegea committed Jul 6, 2024
1 parent 0b82dac commit 14ae695
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sys/dev/virtio/p9fs/virtio_p9fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ vt9p_attach(device_t dev)
mount_tag = malloc(mount_tag_len + 1, M_P9FS_MNTTAG,
M_WAITOK | M_ZERO);

virtio_read_device_config(dev,
virtio_read_device_config_array(dev,
offsetof(struct virtio_9pnet_config, mount_tag),
mount_tag, mount_tag_len);
mount_tag, 1, mount_tag_len);

device_printf(dev, "Mount tag: %s\n", mount_tag);

Check warning on line 360 in sys/dev/virtio/p9fs/virtio_p9fs.c

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
Expand Down

0 comments on commit 14ae695

Please sign in to comment.