lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 26 Oct 2021 10:01:12 +0300
From:   Amir Goldstein <amir73il@...il.com>
To:     Gabriel Krisman Bertazi <krisman@...labora.com>
Cc:     Jan Kara <jack@...e.com>, "Darrick J. Wong" <djwong@...nel.org>,
        Theodore Tso <tytso@....edu>,
        Dave Chinner <david@...morbit.com>,
        David Howells <dhowells@...hat.com>,
        Khazhismel Kumykov <khazhy@...gle.com>,
        linux-fsdevel <linux-fsdevel@...r.kernel.org>,
        Linux API <linux-api@...r.kernel.org>,
        Ext4 <linux-ext4@...r.kernel.org>, kernel@...labora.com
Subject: Re: [PATCH v9 11/31] fsnotify: Protect fsnotify_handle_inode_event
 from no-inode events

On Mon, Oct 25, 2021 at 10:29 PM Gabriel Krisman Bertazi
<krisman@...labora.com> wrote:
>
> 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).
>
> Suggested-by: Amir Goldstein <amir73il@...il.com>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com>
>

Reviewed-by: Amir Goldstein <amir73il@...il.com>

> ---
> Changes since v8:
>   - Convert verifications to WARN_ON
>   - Require either inode or dir
>   - Protect nfsd backend from !inode.
> ---
>  fs/nfsd/filecache.c              | 3 +++
>  fs/notify/fsnotify.c             | 3 +++
>  include/linux/fsnotify_backend.h | 1 +
>  3 files changed, 7 insertions(+)
>
> 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;
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index 035438fe4a43..b71dc788018e 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -136,6 +136,7 @@ struct mem_cgroup;
>   * @dir:       optional directory associated with event -
>   *             if @file_name is not NULL, this is the directory that
>   *             @file_name is relative to.
> + *             Either @inode or @dir must be non-NULL.
>   * @file_name: optional file name associated with event
>   * @cookie:    inotify rename cookie
>   *
> --
> 2.33.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ