Skip to content

Commit 7ea26f9

Browse files
amir73ilbrauner
authored andcommitted
fsnotify: compile out fsnotify permission hooks if !FANOTIFY_ACCESS_PERMISSIONS
The depency of FANOTIFY_ACCESS_PERMISSIONS on SECURITY made sure that the fsnotify permission hooks were never called when SECURITY was disabled. Moving the fsnotify permission hook out of the secutiy hook broke that optimisation. Reported-and-tested-by: Jens Axboe <axboe@kernel.dk> Closes: https://lore.kernel.org/linux-fsdevel/53682ece-f0e7-48de-9a1c-879ee34b0449@kernel.dk/ Fixes: d9e5d31 ("fsnotify: optionally pass access range in file permission hooks") Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20240109182245.38884-1-amir73il@gmail.com Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 70d201a commit 7ea26f9

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

include/linux/fsnotify.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ static inline int fsnotify_file(struct file *file, __u32 mask)
100100
return fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
101101
}
102102

103+
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
103104
/*
104105
* fsnotify_file_area_perm - permission hook before access to file range
105106
*/
@@ -145,6 +146,24 @@ static inline int fsnotify_open_perm(struct file *file)
145146
return fsnotify_file(file, FS_OPEN_PERM);
146147
}
147148

149+
#else
150+
static inline int fsnotify_file_area_perm(struct file *file, int perm_mask,
151+
const loff_t *ppos, size_t count)
152+
{
153+
return 0;
154+
}
155+
156+
static inline int fsnotify_file_perm(struct file *file, int perm_mask)
157+
{
158+
return 0;
159+
}
160+
161+
static inline int fsnotify_open_perm(struct file *file)
162+
{
163+
return 0;
164+
}
165+
#endif
166+
148167
/*
149168
* fsnotify_link_count - inode's link count changed
150169
*/

0 commit comments

Comments
 (0)