qemu-e2k/tools/virtiofsd
Vivek Goyal f1aa1774df virtiofsd: Switch creds, drop FSETID for system.posix_acl_access xattr
When posix access acls are set on a file, it can lead to adjusting file
permissions (mode) as well. If caller does not have CAP_FSETID and it
also does not have membership of owner group, this will lead to clearing
SGID bit in mode.

Current fuse code is written in such a way that it expects file server
to take care of chaning file mode (permission), if there is a need.
Right now, host kernel does not clear SGID bit because virtiofsd is
running as root and has CAP_FSETID. For host kernel to clear SGID,
virtiofsd need to switch to gid of caller in guest and also drop
CAP_FSETID (if caller did not have it to begin with).

If SGID needs to be cleared, client will set the flag
FUSE_SETXATTR_ACL_KILL_SGID in setxattr request. In that case server
should kill sgid.

Currently just switch to uid/gid of the caller and drop CAP_FSETID
and that should do it.

This should fix the xfstest generic/375 test case.

We don't have to switch uid for this to work. That could be one optimization
that pass a parameter to lo_change_cred() to only switch gid and not uid.

Also this will not work whenever (if ever) we support idmapped mounts. In
that case it is possible that uid/gid in request are 0/0 but still we
need to clear SGID. So we will have to pick a non-root sgid and switch
to that instead. That's an TODO item for future when idmapped mount
support is introduced.

This patch only adds the capability to switch creds and drop FSETID
when acl xattr is set. This does not take affect yet. It can take
affect when next patch adds the capability to enable posix_acl.

Reported-by: Luis Henriques <lhenriques@suse.de>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Message-Id: <20210622150852.1507204-7-vgoyal@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2021-07-05 10:51:26 +01:00
..
50-qemu-virtiofsd.json.in virtiofsd: add vhost-user.json file 2020-01-23 16:41:36 +00:00
buffer.c tools/virtiofsd/buffer.c: replaced a calloc call with GLib's g_try_new0 2021-05-26 18:39:32 +01:00
fuse_common.h virtiofsd: Fix fuse setxattr() API change issue 2021-07-05 10:51:26 +01:00
fuse_i.h tools/virtiofsd: add support for --socket-group 2020-10-12 12:39:38 +01:00
fuse_log.c Clean up includes 2020-12-10 17:16:44 +01:00
fuse_log.h Clean up includes 2020-12-10 17:16:44 +01:00
fuse_lowlevel.c virtiofsd: Add support for extended setxattr 2021-07-05 10:51:26 +01:00
fuse_lowlevel.h virtiofsd: Add support for extended setxattr 2021-07-05 10:51:26 +01:00
fuse_misc.h Clean up includes 2020-12-10 17:16:44 +01:00
fuse_opt.c tools/virtiofsd/fuse_opt.c: Replaced a malloc with GLib's g_try_malloc 2021-05-26 18:39:32 +01:00
fuse_opt.h virtiofsd: Format imported files to qemu style 2020-01-23 16:41:36 +00:00
fuse_signals.c Clean up includes 2020-12-10 17:16:44 +01:00
fuse_virtio.c virtiofsd: Set req->reply_sent right after sending reply 2021-05-26 18:39:32 +01:00
fuse_virtio.h virtiofsd: cleanup allocated resource in se 2020-01-23 16:41:37 +00:00
helper.c virtiofsd: Add help for -o xattr-mapping 2021-05-06 19:47:44 +01:00
meson.build libvhost-user: make it a meson subproject 2020-12-08 13:48:58 -05:00
passthrough_helpers.h virtiofsd: Format imported files to qemu style 2020-01-23 16:41:36 +00:00
passthrough_ll.c virtiofsd: Switch creds, drop FSETID for system.posix_acl_access xattr 2021-07-05 10:51:26 +01:00
passthrough_seccomp.c virtiofsd: Add umask to seccom allow list 2021-07-05 10:51:26 +01:00
passthrough_seccomp.h Clean up includes 2020-12-10 17:16:44 +01:00