[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 22/24] vhost-user-fs: Extend VhostUserFSSlaveMsg to pass addition
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH 22/24] vhost-user-fs: Extend VhostUserFSSlaveMsg to pass additional info |
Date: |
Tue, 9 Feb 2021 19:02:22 +0000 |
From: Vivek Goyal <vgoyal@redhat.com>
Extend VhostUserFSSlaveMsg so that slave can ask it to drop CAP_FSETID
before doing I/O on fd.
In some cases, virtiofsd takes the onus of clearing setuid bit on a file
when WRITE happens. Generally virtiofsd does the WRITE to fd (from guest
memory which is mapped in virtiofsd as well), but if this memory is
unmappable in virtiofsd (like cache window), then virtiofsd asks qemu
to do the I/O instead.
To retain the capability to drop suid bit on write, qemu needs to
drop the CAP_FSETID as well before write to fd. Extend VhostUserFSSlaveMsg
so that virtiofsd can specify in message if CAP_FSETID needs to be
dropped.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
hw/virtio/vhost-user-fs.c | 5 +++++
include/hw/virtio/vhost-user-fs.h | 6 ++++++
subprojects/libvhost-user/libvhost-user.h | 6 ++++++
3 files changed, 17 insertions(+)
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
index 357bc1d04e..61e891c82d 100644
--- a/hw/virtio/vhost-user-fs.c
+++ b/hw/virtio/vhost-user-fs.c
@@ -176,6 +176,11 @@ uint64_t vhost_user_fs_slave_io(struct vhost_dev *dev,
VhostUserFSSlaveMsg *sm,
return (uint64_t)-1;
}
+ if (sm->gen_flags & VHOST_USER_FS_GENFLAG_DROP_FSETID) {
+ error_report("Dropping CAP_FSETID is not supported");
+ return (uint64_t)-ENOTSUP;
+ }
+
for (i = 0; i < VHOST_USER_FS_SLAVE_ENTRIES && !res; i++) {
if (sm->len[i] == 0) {
continue;
diff --git a/include/hw/virtio/vhost-user-fs.h
b/include/hw/virtio/vhost-user-fs.h
index ffd3165c29..e646eb004a 100644
--- a/include/hw/virtio/vhost-user-fs.h
+++ b/include/hw/virtio/vhost-user-fs.h
@@ -30,7 +30,13 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserFS, VHOST_USER_FS)
#define VHOST_USER_FS_FLAG_MAP_R (1ull << 0)
#define VHOST_USER_FS_FLAG_MAP_W (1ull << 1)
+/* Generic flags for the overall message and not individual ranges */
+/* Drop capability CAP_FSETID during the operation */
+#define VHOST_USER_FS_GENFLAG_DROP_FSETID (1ull << 0)
+
typedef struct {
+ /* Generic flags for the overall message */
+ uint64_t gen_flags;
/* Offsets within the file being mapped */
uint64_t fd_offset[VHOST_USER_FS_SLAVE_ENTRIES];
/* Offsets within the cache */
diff --git a/subprojects/libvhost-user/libvhost-user.h
b/subprojects/libvhost-user/libvhost-user.h
index a398148ed9..f7de8f6387 100644
--- a/subprojects/libvhost-user/libvhost-user.h
+++ b/subprojects/libvhost-user/libvhost-user.h
@@ -132,7 +132,13 @@ typedef enum VhostUserSlaveRequest {
#define VHOST_USER_FS_FLAG_MAP_R (1ull << 0)
#define VHOST_USER_FS_FLAG_MAP_W (1ull << 1)
+/* Generic flags for the overall message and not individual ranges */
+/* Drop capability CAP_FSETID during the operation */
+#define VHOST_USER_FS_GENFLAG_DROP_FSETID (1ull << 0)
+
typedef struct {
+ /* Generic flags for the overall message */
+ uint64_t gen_flags;
/* Offsets within the file being mapped */
uint64_t fd_offset[VHOST_USER_FS_SLAVE_ENTRIES];
/* Offsets within the cache */
--
2.29.2
- Re: [PATCH 14/24] DAX: virtiofsd: route se down to destroy method, (continued)
- [PATCH 15/24] DAX: virtiofsd: Perform an unmap on destroy, Dr. David Alan Gilbert (git), 2021/02/09
- [PATCH 19/24] DAX/unmap virtiofsd: Route unmappable reads, Dr. David Alan Gilbert (git), 2021/02/09
- [PATCH 18/24] DAX/unmap virtiofsd: Parse unmappable elements, Dr. David Alan Gilbert (git), 2021/02/09
- [PATCH 17/24] DAX/unmap virtiofsd: Add wrappers for VHOST_USER_SLAVE_FS_IO, Dr. David Alan Gilbert (git), 2021/02/09
- [PATCH 20/24] DAX/unmap virtiofsd: route unmappable write to slave command, Dr. David Alan Gilbert (git), 2021/02/09
- [PATCH 21/24] DAX:virtiofsd: implement FUSE_INIT map_alignment field, Dr. David Alan Gilbert (git), 2021/02/09
- [PATCH 22/24] vhost-user-fs: Extend VhostUserFSSlaveMsg to pass additional info,
Dr. David Alan Gilbert (git) <=
- [PATCH 16/24] DAX/unmap: virtiofsd: Add VHOST_USER_SLAVE_FS_IO, Dr. David Alan Gilbert (git), 2021/02/09
- [PATCH 23/24] vhost-user-fs: Implement drop CAP_FSETID functionality, Dr. David Alan Gilbert (git), 2021/02/09
[PATCH 24/24] virtiofsd: Ask qemu to drop CAP_FSETID if client asked for it, Dr. David Alan Gilbert (git), 2021/02/09