linux-yocto/fs/fuse
Guang Yuan Wu 3a0f33c420 fuse: fix race between concurrent setattrs from multiple nodes
[ Upstream commit 69efbff69f ]

When mounting a user-space filesystem on multiple clients, after
concurrent ->setattr() calls from different node, stale inode
attributes may be cached in some node.

This is caused by fuse_setattr() racing with
fuse_reverse_inval_inode().

When filesystem server receives setattr request, the client node
with valid iattr cached will be required to update the fuse_inode's
attr_version and invalidate the cache by fuse_reverse_inval_inode(),
and at the next call to ->getattr() they will be fetched from user
space.

The race scenario is:
1. client-1 sends setattr (iattr-1) request to server
2. client-1 receives the reply from server
3. before client-1 updates iattr-1 to the cached attributes by
   fuse_change_attributes_common(), server receives another setattr
   (iattr-2) request from client-2
4. server requests client-1 to update the inode attr_version and
   invalidate the cached iattr, and iattr-1 becomes staled
5. client-2 receives the reply from server, and caches iattr-2
6. continue with step 2, client-1 invokes
   fuse_change_attributes_common(), and caches iattr-1

The issue has been observed from concurrent of chmod, chown, or
truncate, which all invoke ->setattr() call.

The solution is to use fuse_inode's attr_version to check whether
the attributes have been modified during the setattr request's
lifetime.  If so, mark the attributes as invalid in the function
fuse_change_attributes_common().

Signed-off-by: Guang Yuan Wu <gwu@ddn.com>
Reviewed-by: Bernd Schubert <bschubert@ddn.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-07-06 11:01:32 +02:00
..
acl.c fuse: support idmapped ->set_acl 2024-09-04 16:51:11 +02:00
control.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
cuse.c cuse: add kernel-doc comments to cuse_process_init_reply() 2024-04-15 11:02:10 +02:00
dax.c fuse: fix dax truncate/punch_hole fault path 2025-04-10 14:39:25 +02:00
dev.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
dir.c fuse: fix race between concurrent setattrs from multiple nodes 2025-07-06 11:01:32 +02:00
file.c fuse: fix dax truncate/punch_hole fault path 2025-04-10 14:39:25 +02:00
fuse_i.h virtiofs: use pages instead of pointer for kernel direct IO 2024-12-05 14:02:21 +01:00
fuse_trace.h fuse: add simple request tracepoints 2024-08-29 11:43:13 +02:00
inode.c fs/fuse: introduce and use fuse_simple_idmap_request() helper 2024-09-23 11:07:55 +02:00
ioctl.c fs/fuse: introduce and use fuse_simple_idmap_request() helper 2024-09-23 11:07:55 +02:00
iomode.c fuse: fix parallel dio write on file open in passthrough mode 2024-04-15 10:12:44 +02:00
Kconfig fuse: introduce FUSE_PASSTHROUGH capability 2024-02-23 17:36:32 +01:00
Makefile fuse: add simple request tracepoints 2024-08-29 11:43:13 +02:00
passthrough.c fuse: remove stray debug line 2024-10-25 17:05:49 +02:00
readdir.c fs/fuse: introduce and use fuse_simple_idmap_request() helper 2024-09-23 11:07:55 +02:00
virtio_fs.c virtiofs: add filesystem context source name check 2025-04-25 10:47:55 +02:00
xattr.c fs/fuse: introduce and use fuse_simple_idmap_request() helper 2024-09-23 11:07:55 +02:00