linux/fs/fuse
Miklos Szeredi df2ae00d96 fuse: don't truncate cached, mutated symlink
[ Upstream commit b4c173dfbb ]

Fuse allows the value of a symlink to change and this property is exploited
by some filesystems (e.g. CVMFS).

It has been observed, that sometimes after changing the symlink contents,
the value is truncated to the old size.

This is caused by fuse_getattr() racing with fuse_reverse_inval_inode().
fuse_reverse_inval_inode() updates the fuse_inode's attr_version, which
results in fuse_change_attributes() exiting before updating the cached
attributes

This is okay, as the cached attributes remain invalid and the next call to
fuse_change_attributes() will likely update the inode with the correct
values.

The reason this causes problems is that cached symlinks will be
returned through page_get_link(), which truncates the symlink to
inode->i_size.  This is correct for filesystems that don't mutate
symlinks, but in this case it causes bad behavior.

The solution is to just remove this truncation.  This can cause a
regression in a filesystem that relies on supplying a symlink larger than
the file size, but this is unlikely.  If that happens we'd need to make
this behavior conditional.

Reported-by: Laura Promberger <laura.promberger@cern.ch>
Tested-by: Sam Lewis <samclewis@google.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Link: https://lore.kernel.org/r/20250220100258.793363-1-mszeredi@redhat.com
Reviewed-by: Bernd Schubert <bschubert@ddn.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-03-22 12:54:20 -07: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 fs/fuse: introduce and use fuse_simple_idmap_request() helper 2024-09-23 11:07:55 +02:00
dev.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
dir.c fuse: don't truncate cached, mutated symlink 2025-03-22 12:54:20 -07:00
file.c virtiofs: use pages instead of pointer for kernel direct IO 2024-12-05 14:02:21 +01: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: use pages instead of pointer for kernel direct IO 2024-12-05 14:02:21 +01:00
xattr.c fs/fuse: introduce and use fuse_simple_idmap_request() helper 2024-09-23 11:07:55 +02:00