linux/fs/overlayfs
Amir Goldstein ab04830202 ovl: fix failed copyup of fileattr on a symlink
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>
2023-09-04 18:27:18 +03:00
..
copy_up.c ovl: fix failed copyup of fileattr on a symlink 2023-09-04 18:27:18 +03:00
dir.c ovl: store enum redirect_mode in config instead of a string 2023-06-19 14:02:01 +03:00
export.c ovl: make consistent use of OVL_FS() 2023-08-12 19:02:54 +03:00
file.c overlayfs update for 6.6 2023-08-30 11:54:09 -07:00
inode.c overlayfs update for 6.6 2023-08-30 11:54:09 -07:00
Kconfig ovl: Kconfig: introduce CONFIG_OVERLAY_FS_DEBUG 2023-08-12 19:02:53 +03:00
Makefile ovl: modify layer parameter parsing 2023-06-20 14:10:40 +03:00
namei.c ovl: make consistent use of OVL_FS() 2023-08-12 19:02:54 +03:00
overlayfs.h overlayfs update for 6.6 2023-08-30 11:54:09 -07:00
ovl_entry.h ovl: validate superblock in OVL_FS() 2023-08-12 19:02:54 +03:00
params.c ovl: make consistent use of OVL_FS() 2023-08-12 19:02:54 +03:00
params.h ovl: move all parameter handling into params.{c,h} 2023-07-03 16:08:17 +03:00
readdir.c vfs: get rid of old '->iterate' directory operation 2023-08-06 15:08:35 +02:00
super.c ovl: make consistent use of OVL_FS() 2023-08-12 19:02:54 +03:00
util.c overlayfs update for 6.6 2023-08-30 11:54:09 -07:00