diff options
author | Gabriel Krisman Bertazi <krisman@collabora.com> | 2021-10-25 21:27:26 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2021-10-27 12:34:12 +0200 |
commit | 24dca90590509a7a6cbe0650100c90c5b8a3468a (patch) | |
tree | ba1f0305c3b3159bb3c8524f8780e19744a35f2e /fs | |
parent | fsnotify: Retrieve super block from the data field (diff) | |
download | linux-24dca90590509a7a6cbe0650100c90c5b8a3468a.tar.xz linux-24dca90590509a7a6cbe0650100c90c5b8a3468a.zip |
fsnotify: Protect fsnotify_handle_inode_event from no-inode events
FAN_FS_ERROR allows events without inodes - i.e. for file system-wide
errors. Even though fsnotify_handle_inode_event is not currently used
by fanotify, this patch protects other backends from cases where neither
inode or dir are provided. Also document the constraints of the
interface (inode and dir cannot be both NULL).
Link: https://lore.kernel.org/r/20211025192746.66445-12-krisman@collabora.com
Suggested-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/filecache.c | 3 | ||||
-rw-r--r-- | fs/notify/fsnotify.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index be3c1aad50ea..fdf89fcf1a0c 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -602,6 +602,9 @@ nfsd_file_fsnotify_handle_event(struct fsnotify_mark *mark, u32 mask, struct inode *inode, struct inode *dir, const struct qstr *name, u32 cookie) { + if (WARN_ON_ONCE(!inode)) + return 0; + trace_nfsd_file_fsnotify_handle_event(inode, mask); /* Should be no marks on non-regular files */ diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index fde3a1115a17..4034ca566f95 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -252,6 +252,9 @@ static int fsnotify_handle_inode_event(struct fsnotify_group *group, if (WARN_ON_ONCE(!ops->handle_inode_event)) return 0; + if (WARN_ON_ONCE(!inode && !dir)) + return 0; + if ((inode_mark->mask & FS_EXCL_UNLINK) && path && d_unlinked(path->dentry)) return 0; |