linux/fs/overlayfs
Amir Goldstein a1a541fbfa ovl: support encoding fid from inode with no alias
[ Upstream commit c45beebfde ]

Dmitry Safonov reported that a WARN_ON() assertion can be trigered by
userspace when calling inotify_show_fdinfo() for an overlayfs watched
inode, whose dentry aliases were discarded with drop_caches.

The WARN_ON() assertion in inotify_show_fdinfo() was removed, because
it is possible for encoding file handle to fail for other reason, but
the impact of failing to encode an overlayfs file handle goes beyond
this assertion.

As shown in the LTP test case mentioned in the link below, failure to
encode an overlayfs file handle from a non-aliased inode also leads to
failure to report an fid with FAN_DELETE_SELF fanotify events.

As Dmitry notes in his analyzis of the problem, ovl_encode_fh() fails
if it cannot find an alias for the inode, but this failure can be fixed.
ovl_encode_fh() seldom uses the alias and in the case of non-decodable
file handles, as is often the case with fanotify fid info,
ovl_encode_fh() never needs to use the alias to encode a file handle.

Defer finding an alias until it is actually needed so ovl_encode_fh()
will not fail in the common case of FAN_DELETE_SELF fanotify events.

Fixes: 16aac5ad1f ("ovl: support encoding non-decodable file handles")
Reported-by: Dmitry Safonov <dima@arista.com>
Closes: https://lore.kernel.org/linux-fsdevel/CAOQ4uxiie81voLZZi2zXS1BziXZCM24nXqPAxbu8kxXCUWdwOg@mail.gmail.com/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/r/20250105162404.357058-3-amir73il@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-01-17 13:36:10 +01:00
..
copy_up.c ovl: pass realinode to ovl_encode_real_fh() instead of realdentry 2025-01-17 13:36:10 +01:00
dir.c ovl: remove upper umask handling from ovl_create_upper() 2024-06-12 11:12:24 +02:00
export.c ovl: support encoding fid from inode with no alias 2025-01-17 13:36:10 +01:00
file.c ovl: fix file reference leak when submitting aio 2023-10-02 13:08:31 +03:00
inode.c ovl: properly handle large files in ovl_security_fileattr 2024-12-09 10:33:08 +01: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: pass realinode to ovl_encode_real_fh() instead of realdentry 2025-01-17 13:36:10 +01:00
overlayfs.h ovl: pass realinode to ovl_encode_real_fh() instead of realdentry 2025-01-17 13:36:10 +01:00
ovl_entry.h ovl: make use of ->layers safe in rcu pathwalk 2023-10-02 17:45:02 +03:00
params.c ovl: fail if trusted xattrs are needed but caller lacks permission 2024-10-10 11:57:44 +02:00
params.h ovl: store and show the user provided lowerdir mount option 2024-03-26 18:19:18 -04:00
readdir.c vfs: get rid of old '->iterate' directory operation 2023-08-06 15:08:35 +02:00
super.c ovl: do not encode lower fh with upper sb_writers held 2025-01-17 13:36:10 +01:00
util.c ovl: do not encode lower fh with upper sb_writers held 2025-01-17 13:36:10 +01:00