linux/fs/overlayfs
Amir Goldstein 05a7289a5d ovl: fix failed copyup of fileattr on a symlink
commit ab04830202 upstream.

Some local filesystems support setting persistent fileattr flags
(e.g. FS_NOATIME_FL) on directories and regular files via ioctl.
Some of those persistent fileattr flags are reflected to vfs as
in-memory inode flags (e.g. S_NOATIME).

Overlayfs uses the in-memory inode flags (e.g. S_NOATIME) on a lower file
as an indication that a the lower file may have persistent inode fileattr
flags (e.g. FS_NOATIME_FL) that need to be copied to upper file.

However, in some cases, the S_NOATIME in-memory flag could be a false
indication for persistent FS_NOATIME_FL fileattr. For example, with NFS
and FUSE lower fs, as was the case in the two bug reports, the S_NOATIME
flag is set unconditionally for all inodes.

Users cannot set persistent fileattr flags on symlinks and special files,
but in some local fs, such as ext4/btrfs/tmpfs, the FS_NOATIME_FL fileattr
flag are inheritted to symlinks and special files from parent directory.

In both cases described above, when lower symlink has the S_NOATIME flag,
overlayfs will try to copy the symlink's fileattrs and fail with error
ENOXIO, because it could not open the symlink for the ioctl security hook.

To solve this failure, do not attempt to copyup fileattrs for anything
other than directories and regular files.

Reported-by: Ruiwen Zhao <ruiwen@google.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217850
Fixes: 72db82115d ("ovl: copy up sync/noatime fileattr flags")
Cc: <stable@vger.kernel.org> # v5.15
Reviewed-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-09-23 11:10:01 +02:00
..
copy_up.c ovl: fix failed copyup of fileattr on a symlink 2023-09-23 11:10:01 +02:00
dir.c ovl: update of dentry revalidate flags after copy up 2023-07-23 13:47:10 +02:00
export.c ovl: update of dentry revalidate flags after copy up 2023-07-23 13:47:10 +02:00
file.c ovl: remove privs in ovl_fallocate() 2022-12-31 13:14:00 +01:00
inode.c ovl: fix null pointer dereference in ovl_get_acl_rcu() 2023-07-23 13:47:36 +02:00
Kconfig docs: fix broken references to text files 2020-04-20 15:35:59 -06:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
namei.c ovl: update of dentry revalidate flags after copy up 2023-07-23 13:47:10 +02:00
overlayfs.h ovl: update of dentry revalidate flags after copy up 2023-07-23 13:47:10 +02:00
ovl_entry.h ovl: check type and offset of struct vfsmount in ovl_entry 2023-08-26 14:23:23 +02:00
readdir.c ovl: skip stale entries in merge dir cache iteration 2021-08-10 10:21:30 +02:00
super.c ovl: Always reevaluate the file signature for IMA 2023-09-19 12:22:28 +02:00
util.c ovl: update of dentry revalidate flags after copy up 2023-07-23 13:47:10 +02:00