Thread (28 messages) 28 messages, 4 authors, 2025-05-19

Re: [PATCH v9 4/4] vhost: Add a KConfig knob to enable IOCTL VHOST_FORK_FROM_OWNER

From: Cindy Lu <hidden>
Date: 2025-04-23 01:01:45
Also in: lkml, virtualization

On Tue, Apr 22, 2025 at 9:50 PM Stefano Garzarella [off-list ref] wrote:
On Mon, Apr 21, 2025 at 10:44:10AM +0800, Cindy Lu wrote:
quoted
Introduce a new config knob `CONFIG_VHOST_ENABLE_FORK_OWNER_IOCTL`,
to control the availability of the `VHOST_FORK_FROM_OWNER` ioctl.
When CONFIG_VHOST_ENABLE_FORK_OWNER_IOCTL is set to n, the ioctl
is disabled, and any attempt to use it will result in failure.

Signed-off-by: Cindy Lu <redacted>
---
drivers/vhost/Kconfig | 15 +++++++++++++++
drivers/vhost/vhost.c |  3 +++
2 files changed, 18 insertions(+)
diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig
index 020d4fbb947c..bc8fadb06f98 100644
--- a/drivers/vhost/Kconfig
+++ b/drivers/vhost/Kconfig
@@ -96,3 +96,18 @@ config VHOST_CROSS_ENDIAN_LEGACY
        If unsure, say "N".
endif
+
+config VHOST_ENABLE_FORK_OWNER_IOCTL
+      bool "Enable IOCTL VHOST_FORK_FROM_OWNER"
+      default n
+      help
+        This option enables the IOCTL VHOST_FORK_FROM_OWNER, which allows
+        userspace applications to modify the thread mode for vhost devices.
+
+          By default, `CONFIG_VHOST_ENABLE_FORK_OWNER_IOCTL` is set to `n`,
+          meaning the ioctl is disabled and any operation using this ioctl
+          will fail.
+          When the configuration is enabled (y), the ioctl becomes
+          available, allowing users to set the mode if needed.
I think I already pointed out, but here there is a mix of tabs and
spaces that IMHO we should fix.
Sorry, I missed this comment while preparing the patch; I’ll fix it.
quoted
+
+        If unsure, say "N".
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index fb0c7fb43f78..568e43cb54a9 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -2294,6 +2294,8 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
              r = vhost_dev_set_owner(d);
              goto done;
      }
+
+#ifdef CONFIG_VHOST_ENABLE_FORK_OWNER_IOCTL
As I mentioned in the previous version, IMO this patch should be merged
with the previous patch. I don't think it is good for bisection to have
a commit with an IOCTL supported in any case and in the next commit
instead supported only through a config.

Maybe I'm missing something, but what's the point of having a separate
patch for this?

Thanks,
Stefano
will fix this
thanks
cindy
quoted
      if (ioctl == VHOST_FORK_FROM_OWNER) {
              u8 inherit_owner;
              /*inherit_owner can only be modified before owner is set*/
@@ -2313,6 +2315,7 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
              r = 0;
              goto done;
      }
+#endif
      /* You must be the owner to do anything else */
      r = vhost_dev_check_owner(d);
      if (r)
--
2.45.0
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help