Skip to content

Commit 1cda52f

Browse files
liu-song-6jankara
authored andcommitted
fsnotify, lsm: Decouple fsnotify from lsm
Currently, fsnotify_open_perm() is called from security_file_open(). This is a a bit unexpected and creates otherwise unnecessary dependency of CONFIG_FANOTIFY_ACCESS_PERMISSIONS on CONFIG_SECURITY. Fix this by calling fsnotify_open_perm() directly. Signed-off-by: Song Liu <song@kernel.org> Acked-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20241013002248.3984442-1-song@kernel.org
1 parent 6485cf5 commit 1cda52f

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

fs/notify/fanotify/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ config FANOTIFY
1515
config FANOTIFY_ACCESS_PERMISSIONS
1616
bool "fanotify permissions checking"
1717
depends on FANOTIFY
18-
depends on SECURITY
1918
default n
2019
help
2120
Say Y here is you want fanotify listeners to be able to make permissions

fs/open.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,10 @@ static int do_dentry_open(struct file *f,
946946
if (error)
947947
goto cleanup_all;
948948

949+
error = fsnotify_open_perm(f);
950+
if (error)
951+
goto cleanup_all;
952+
949953
error = break_lease(file_inode(f), f->f_flags);
950954
if (error)
951955
goto cleanup_all;

security/security.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/kernel.h>
2020
#include <linux/kernel_read_file.h>
2121
#include <linux/lsm_hooks.h>
22-
#include <linux/fsnotify.h>
2322
#include <linux/mman.h>
2423
#include <linux/mount.h>
2524
#include <linux/personality.h>
@@ -3104,13 +3103,7 @@ int security_file_receive(struct file *file)
31043103
*/
31053104
int security_file_open(struct file *file)
31063105
{
3107-
int ret;
3108-
3109-
ret = call_int_hook(file_open, file);
3110-
if (ret)
3111-
return ret;
3112-
3113-
return fsnotify_open_perm(file);
3106+
return call_int_hook(file_open, file);
31143107
}
31153108

31163109
/**

0 commit comments

Comments
 (0)