linux/fs/fuse
Vivek Goyal 8981bdfda7 fuse: don't send ATTR_MODE to kill suid/sgid for handle_killpriv_v2
If client does a write() on a suid/sgid file, VFS will first call
fuse_setattr() with ATTR_KILL_S[UG]ID set.  This requires sending setattr
to file server with ATTR_MODE set to kill suid/sgid.  But to do that client
needs to know latest mode otherwise it is racy.

To reduce the race window, current code first call fuse_do_getattr() to get
latest ->i_mode and then resets suid/sgid bits and sends rest to server
with setattr(ATTR_MODE).  This does not reduce the race completely but
narrows race window significantly.

With fc->handle_killpriv_v2 enabled, it should be possible to remove this
race completely.  Do not kill suid/sgid with ATTR_MODE at all.  It will be
killed by server when WRITE request is sent to server soon.  This is
similar to fc->handle_killpriv logic.  V2 is just more refined version of
protocol.  Hence this patch does not send ATTR_MODE to kill suid/sgid if
fc->handle_killpriv_v2 is enabled.

This creates an issue if fc->writeback_cache is enabled.  In that case
WRITE can be cached in guest and server might not see WRITE request and
hence will not kill suid/sgid.  Miklos suggested that in such cases, we
should fallback to a writethrough WRITE instead and that will generate
WRITE request and kill suid/sgid.  This patch implements that too.

But this relies on client seeing the suid/sgid set.  If another client sets
suid/sgid and this client does not see it immideately, then we will not
fallback to writethrough WRITE.  So this is one limitation with both
fc->handle_killpriv_v2 and fc->writeback_cache enabled.  Both the options
are not fully compatible.  But might be good enough for many use cases.

Note: This patch is not checking whether security.capability is set or not
      when falling back to writethrough path.  If suid/sgid is not set and
      only security.capability is set, that will be taken care of by
      file_remove_privs() call in ->writeback_cache path.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2020-11-11 17:22:33 +01:00
..
acl.c fuse: Support fuse filesystems outside of init_user_ns 2018-03-20 17:11:44 +01:00
control.c fuse: split fuse_mount off of fuse_conn 2020-09-18 15:17:41 +02:00
cuse.c fuse: split fuse_mount off of fuse_conn 2020-09-18 15:17:41 +02:00
dax.c fuse: split fuse_mount off of fuse_conn 2020-09-18 15:17:41 +02:00
dev.c fuse: split fuse_mount off of fuse_conn 2020-09-18 15:17:41 +02:00
dir.c fuse: don't send ATTR_MODE to kill suid/sgid for handle_killpriv_v2 2020-11-11 17:22:33 +01:00
file.c fuse: don't send ATTR_MODE to kill suid/sgid for handle_killpriv_v2 2020-11-11 17:22:33 +01:00
fuse_i.h fuse: introduce the notion of FUSE_HANDLE_KILLPRIV_V2 2020-11-11 17:22:32 +01:00
inode.c fuse: introduce the notion of FUSE_HANDLE_KILLPRIV_V2 2020-11-11 17:22:32 +01:00
Kconfig virtiofs: implement dax read/write operations 2020-09-10 11:39:23 +02:00
Makefile virtiofs: add a mount option to enable dax 2020-09-10 11:39:22 +02:00
readdir.c fuse: split fuse_mount off of fuse_conn 2020-09-18 15:17:41 +02:00
virtio_fs.c virtiofs: clean up error handling in virtio_fs_get_tree() 2020-11-11 17:22:32 +01:00
xattr.c fuse: split fuse_mount off of fuse_conn 2020-09-18 15:17:41 +02:00