linux/include/uapi
Amir Goldstein ffe1766a3a fanotify: allow reporting errors on failure to open fd
[ Upstream commit 522249f05c ]

When working in "fd mode", fanotify_read() needs to open an fd
from a dentry to report event->fd to userspace.

Opening an fd from dentry can fail for several reasons.
For example, when tasks are gone and we try to open their
/proc files or we try to open a WRONLY file like in sysfs
or when trying to open a file that was deleted on the
remote network server.

Add a new flag FAN_REPORT_FD_ERROR for fanotify_init().
For a group with FAN_REPORT_FD_ERROR, we will send the
event with the error instead of the open fd, otherwise
userspace may not get the error at all.

For an overflow event, we report -EBADF to avoid confusing FAN_NOFD
with -EPERM.  Similarly for pidfd open errors we report either -ESRCH
or the open error instead of FAN_NOPIDFD and FAN_EPIDFD.

In any case, userspace will not know which file failed to
open, so add a debug print for further investigation.

Reported-by: Krishna Vivek Vitta <kvitta@microsoft.com>
Link: https://lore.kernel.org/linux-fsdevel/SI2P153MB07182F3424619EDDD1F393EED46D2@SI2P153MB0718.APCP153.PROD.OUTLOOK.COM/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20241003142922.111539-1-amir73il@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-12-14 20:00:05 +01:00
..
asm-generic syscalls: fix compat_sys_io_pgetevents_time64 usage 2024-07-05 09:34:04 +02:00
drm drm/amdgpu: handle gfx12 in amdgpu_display_verify_sizes 2024-09-12 11:11:43 +02:00
linux fanotify: allow reporting errors on failure to open fd 2024-12-14 20:00:05 +01:00
misc Revert "misc: fastrpc: Restrict untrusted app to attach to privileged PD" 2024-08-29 17:33:10 +02:00
mtd This pull request contains updates for UBI and UBIFS 2022-10-14 18:23:23 -07:00
rdma RDMA/bnxt_re: Adds MSN table capability for Gen P7 adapters 2024-06-12 11:12:10 +02:00
scsi scsi: mpi3mr: Avoid memcpy field-spanning write WARNING 2024-05-17 12:02:11 +02:00
sound ASoC: SOF: topology: Add a token for dropping widget name in kcontrol name 2023-08-15 13:25:56 +01:00
video License cleanup: add SPDX license identifier to uapi header files with a license 2017-11-02 11:20:11 +01:00
xen xen: irqfd: Use _IOW instead of the internal _IOC() macro 2023-11-20 11:59:12 +01:00
Kbuild kbuild: re-implement Makefile.headersinst without recursion 2019-06-15 19:57:02 +09:00