diff mbox series

[v7,12/28] fanotify: Support null inode event in fanotify_dfid_inode

Message ID 20211014213646.1139469-13-krisman@collabora.com (mailing list archive)
State New, archived
Headers show
Series file system-wide error monitoring | expand

Commit Message

Gabriel Krisman Bertazi Oct. 14, 2021, 9:36 p.m. UTC
FAN_FS_ERROR doesn't support DFID, but this function is still called for
every event.  The problem is that it is not capable of handling null
inodes, which now can happen in case of superblock error events.  For
this case, just returning dir will be enough.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
---
 fs/notify/fanotify/fanotify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Amir Goldstein Oct. 15, 2021, 5:49 a.m. UTC | #1
On Fri, Oct 15, 2021 at 12:38 AM Gabriel Krisman Bertazi
<krisman@collabora.com> wrote:
>
> FAN_FS_ERROR doesn't support DFID, but this function is still called for
> every event.  The problem is that it is not capable of handling null
> inodes, which now can happen in case of superblock error events.  For
> this case, just returning dir will be enough.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>


Please also fortify fsnotify_handle_inode_event() against calling
->handle_inode_event() with NULL inode.

> ---
>  fs/notify/fanotify/fanotify.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index c620b4f6fe12..397ee623ff1e 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -452,7 +452,7 @@ static struct inode *fanotify_dfid_inode(u32 event_mask, const void *data,
>         if (event_mask & ALL_FSNOTIFY_DIRENT_EVENTS)
>                 return dir;
>
> -       if (S_ISDIR(inode->i_mode))
> +       if (inode && S_ISDIR(inode->i_mode))
>                 return inode;
>
>         return dir;
> --
> 2.33.0
>
Jan Kara Oct. 15, 2021, 9:30 a.m. UTC | #2
On Thu 14-10-21 18:36:30, Gabriel Krisman Bertazi wrote:
> FAN_FS_ERROR doesn't support DFID, but this function is still called for
> every event.  The problem is that it is not capable of handling null
> inodes, which now can happen in case of superblock error events.  For
> this case, just returning dir will be enough.
> 
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/notify/fanotify/fanotify.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index c620b4f6fe12..397ee623ff1e 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -452,7 +452,7 @@ static struct inode *fanotify_dfid_inode(u32 event_mask, const void *data,
>  	if (event_mask & ALL_FSNOTIFY_DIRENT_EVENTS)
>  		return dir;
>  
> -	if (S_ISDIR(inode->i_mode))
> +	if (inode && S_ISDIR(inode->i_mode))
>  		return inode;
>  
>  	return dir;
> -- 
> 2.33.0
>
diff mbox series

Patch

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index c620b4f6fe12..397ee623ff1e 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -452,7 +452,7 @@  static struct inode *fanotify_dfid_inode(u32 event_mask, const void *data,
 	if (event_mask & ALL_FSNOTIFY_DIRENT_EVENTS)
 		return dir;
 
-	if (S_ISDIR(inode->i_mode))
+	if (inode && S_ISDIR(inode->i_mode))
 		return inode;
 
 	return dir;