Skip to contentSkip to conversation

vduse: add virtio_fs to allowed dev id

PATCH In review Eugenio Pérez 4 participants 9 messages Jan 21, 2025 – Mar 5, 2025 virtio core

lore
Share & tools
lore

Eugenio Pérez

author maintainer
#0 lore raw

PATCH 1/1 vduse: add virtio_fs to allowed dev id

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

---
 drivers/vdpa/vdpa_user/vduse_dev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vdpa/vdpa_user/vduse_dev.c +1 -0
index 7ae99691efdf..6a9a37351310 100644
@@ -144,6 +144,7 @@ static struct workqueue_struct *vduse_irq_bound_wq;
 static u32 allowed_device_id[] = {
 	VIRTIO_ID_BLOCK,
 	VIRTIO_ID_NET,
+	VIRTIO_ID_FS,
 };
 
 static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa)

--
2.48.1

Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Eugenio Pérez

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

The virtiofs DAX Window feature might require extra work. It is not widely enabled though, so must virtiofs devices will work fine with just virtqueue and configuration space support.

#2 lore raw
Quoted 8 lines · Stefan Hajnoczi
Quoted 2 lines · Eugenio Pérez

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

The virtiofs DAX Window feature might require extra work. It is not widely enabled though, so must virtiofs devices will work fine with just virtqueue and configuration space support.

+1.

The DAX Window may help to reduce the bounce buffer copying and fit for the case where an AI application just accesses one single large file.

We need to consider implementing this via VDUSE.

Thanks

Quoted 2 lines
author maintainer
#3 lore raw
Quoted 13 lines · Jason Wang
Quoted 8 lines · Stefan Hajnoczi
Quoted 2 lines · Eugenio Pérez

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

The virtiofs DAX Window feature might require extra work. It is not widely enabled though, so must virtiofs devices will work fine with just virtqueue and configuration space support.

+1.

Quoted 9 lines

The DAX Window may help to reduce the bounce buffer copying and fit for the case where an AI application just accesses one single large file.

We need to consider implementing this via VDUSE.

Thanks

I thought DAX can only be applied in the VM case. Is it possible to apply it using virtio_vdpa?

Is it possible to detect that the device is trying to use DAX so it fails the negotiation?

#4 lore raw
Quoted 18 lines · Eugenio Perez Martin
Quoted 17 lines · Jason Wang
Quoted 8 lines · Stefan Hajnoczi
Quoted 2 lines · Eugenio Pérez

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

The virtiofs DAX Window feature might require extra work. It is not widely enabled though, so must virtiofs devices will work fine with just virtqueue and configuration space support.

+1.

The DAX Window may help to reduce the bounce buffer copying and fit for the case where an AI application just accesses one single large file.

Quoted 8 lines
Quoted 5 lines

We need to consider implementing this via VDUSE.

Thanks

I thought DAX can only be applied in the VM case. Is it possible to apply it using virtio_vdpa?

Hardware could implement the DAX Window feature. In virtio-pci it's implemented as a range within a BAR on the PCI device.

Quoted 2 lines

Is it possible to detect that the device is trying to use DAX so it fails the negotiation?

Yes, DAX is optional. It's only available when the device reports a Shared Memory Region with ID 0:
https://github.com/oasis-tcs/virtio-spec/blob/master/device-types/fs/description.tex#L233

Just to let you know, the QEMU vhost-user implementation of the DAX Window is not complete. In the past David Gilbert had out-of-tree patches to enable it in QEMU.

The guest driver support is in Linux.

Stefan

#5 lore raw
In reply to Eugenio Pérez
Quoted 4 lines · Eugenio Pérez

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

OK, but the commit log really should say why
you are doing this. And also why is it safe.

Quoted 18 lines
---
 drivers/vdpa/vdpa_user/vduse_dev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vdpa/vdpa_user/vduse_dev.c +1 -1
index 7ae99691efdf..6a9a37351310 100644
@@ -144,6 +144,7 @@ static struct workqueue_struct *vduse_irq_bound_wq;
 static u32 allowed_device_id[] = {
 	VIRTIO_ID_BLOCK,
 	VIRTIO_ID_NET,
+	VIRTIO_ID_FS,
 };
 
 static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa)
--

2.48.1

author maintainer
#6 lore raw
Quoted 10 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

OK, but the commit log really should say why
you are doing this.

Sure I can expand on the motivation.

Something like "Allowing VDUSE FS type allows to build filesystems that run in userspace and can be presented transparently to the host and the guest. After modifying userland's libfuse, this allows to expose a good amount to already available userland FS through vDPA."

I'd add using the high performance virtio protocol but I still need to do more tests for this TBH.

Quoted 2 lines

And also why is it safe.

Can you expand on the scenarios you think this is insecure? While I understand it's security sensitive, you already need root to perform vdpa device operations. Is FS different from net or block?

Thanks!

Quoted 19 lines
Quoted 18 lines
---
 drivers/vdpa/vdpa_user/vduse_dev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vdpa/vdpa_user/vduse_dev.c +1 -1
index 7ae99691efdf..6a9a37351310 100644
@@ -144,6 +144,7 @@ static struct workqueue_struct *vduse_irq_bound_wq;
 static u32 allowed_device_id[] = {
      VIRTIO_ID_BLOCK,
      VIRTIO_ID_NET,
+     VIRTIO_ID_FS,
 };
 
 static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa)
--

2.48.1

#7 lore raw
Quoted 22 lines · Eugenio Perez Martin
Quoted 10 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

OK, but the commit log really should say why
you are doing this.

Sure I can expand on the motivation.

Something like "Allowing VDUSE FS type allows to build filesystems that run in userspace and can be presented transparently to the host and the guest. After modifying userland's libfuse, this allows to expose a good amount to already available userland FS through vDPA."

I'd add using the high performance virtio protocol but I still need to do more tests for this TBH.

Quoted 8 lines
Quoted 2 lines

And also why is it safe.

Can you expand on the scenarios you think this is insecure? While I understand it's security sensitive, you already need root to perform vdpa device operations. Is FS different from net or block?

Thanks!

I did not say it was insecure, just that you need to explain the security considerations in the commit log.
The issue is that when one gave access to vdpa user device previously it would only allow mounting blk now a filesystem.

Net is different, it is gated by CAP_NET_ADMIN.

When net was introduced, selinux was there initially then it was deferred and never surfaced.
Maybe we should revive it so it is possible to control which devices can be created in a granular way.

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
---
 drivers/vdpa/vdpa_user/vduse_dev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vdpa/vdpa_user/vduse_dev.c +1 -1
index 7ae99691efdf..6a9a37351310 100644
@@ -144,6 +144,7 @@ static struct workqueue_struct *vduse_irq_bound_wq;
 static u32 allowed_device_id[] = {
      VIRTIO_ID_BLOCK,
      VIRTIO_ID_NET,
+     VIRTIO_ID_FS,
 };
 
 static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa)
--

2.48.1

#8 lore raw
Quoted 38 lines · Michael S. Tsirkin
Quoted 22 lines · Eugenio Perez Martin
Quoted 10 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez

A VDUSE device that implements virtiofs device works fine just by adding the device id to the whitelist.

OK, but the commit log really should say why
you are doing this.

Sure I can expand on the motivation.

Something like "Allowing VDUSE FS type allows to build filesystems that run in userspace and can be presented transparently to the host and the guest. After modifying userland's libfuse, this allows to expose a good amount to already available userland FS through vDPA."

I'd add using the high performance virtio protocol but I still need to do more tests for this TBH.

Quoted 8 lines
Quoted 2 lines

And also why is it safe.

Can you expand on the scenarios you think this is insecure? While I understand it's security sensitive, you already need root to perform vdpa device operations. Is FS different from net or block?

Thanks!

I did not say it was insecure, just that you need to explain the security considerations in the commit log.
The issue is that when one gave access to vdpa user device previously it would only allow mounting blk now a filesystem.

Quoted 6 lines

Net is different, it is gated by CAP_NET_ADMIN.

When net was introduced, selinux was there initially then it was deferred and never surfaced.
Maybe we should revive it so it is possible to control which devices can be created in a granular way.

Can we simply start from CAP_SYS_ADMIN?

Thanks

Quoted 21 lines
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
---
 drivers/vdpa/vdpa_user/vduse_dev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vdpa/vdpa_user/vduse_dev.c +1 -1
index 7ae99691efdf..6a9a37351310 100644
@@ -144,6 +144,7 @@ static struct workqueue_struct *vduse_irq_bound_wq;
 static u32 allowed_device_id[] = {
      VIRTIO_ID_BLOCK,
      VIRTIO_ID_NET,
+     VIRTIO_ID_FS,
 };
 
 static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa)
--

2.48.1