[PATCH 1/4] inotify_user: pass directory fd to inotify_find_inode()

From: Max Kellermann
Date: Mon Sep 18 2023 - 08:33:45 EST


Preparing for inotify_add_watch_at().

To: Jan Kara <jack@xxxxxxx>
Cc: Amir Goldstein <amir73il@xxxxxxxxx>
To: linux-fsdevel@xxxxxxxxxxxxxxx
To: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
---
fs/notify/inotify/inotify_user.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 1c4bfdab008d..1853439a24f6 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -370,12 +370,12 @@ static const struct file_operations inotify_fops = {
/*
* find_inode - resolve a user-given path to a specific inode
*/
-static int inotify_find_inode(const char __user *dirname, struct path *path,
+static int inotify_find_inode(int dfd, const char __user *dirname, struct path *path,
unsigned int flags, __u64 mask)
{
int error;

- error = user_path_at(AT_FDCWD, dirname, flags, path);
+ error = user_path_at(dfd, dirname, flags, path);
if (error)
return error;
/* you can only watch an inode if you have read permissions on it */
@@ -774,7 +774,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
if (mask & IN_ONLYDIR)
flags |= LOOKUP_DIRECTORY;

- ret = inotify_find_inode(pathname, &path, flags,
+ ret = inotify_find_inode(AT_FDCWD, pathname, &path, flags,
(mask & IN_ALL_EVENTS));
if (ret)
goto fput_and_out;
--
2.39.2