2022-06-07 06:22:32

by Oliver Ford

[permalink] [raw]
Subject: [PATCH 0/1] fs: inotify: Add full paths option to inotify

Adds an option to return the full path in inotify events. Currently, user space has to keep track of watch descriptors and paths, mapping the descriptor returned when reading inotify events to the path. Adding an option to return the full path simplifies user space code.

The patch adds a flag, IN_FULL_PATHS, to the available mask in inotify_add_watch. When set, the full path is returned when events are added to the watch queue and a path is available. For the event IN_MOVE_SELF, a check is performed that the user has access to the new path. This prevents exposing the names of directories if, for example, root moves "/home/dmr/watched" to "/root/top_secret/watched". In that case, the watch is removed and a Permission Denied error is returned. For the IN_DELETE_SELF/IN_IGNORED pair, no path is returned.

Oliver Ford (1):
fs: inotify: Add full paths option to inotify

fs/notify/inotify/inotify_fsnotify.c | 55 ++++++++++++++++++++++------
fs/notify/inotify/inotify_user.c | 19 +++++++++-
include/linux/inotify.h | 2 +-
include/uapi/linux/inotify.h | 1 +
4 files changed, 63 insertions(+), 14 deletions(-)

--
2.35.1


2022-06-07 13:11:58

by Amir Goldstein

[permalink] [raw]
Subject: Re: [PATCH 0/1] fs: inotify: Add full paths option to inotify

On Tue, Jun 7, 2022 at 1:43 AM Oliver Ford <[email protected]> wrote:
>
> Adds an option to return the full path in inotify events. Currently, user space has to keep track of watch descriptors and paths, mapping the descriptor returned when reading inotify events to the path. Adding an option to return the full path simplifies user space code.

That is exactly what FAN_REPORT_DFID_NAME fanofiy mode is for.
Please try to use it and see if it fits your needs.

Thanks,
Amir.