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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 16 Jun 2021 12:38:38 +0300
From:   Amir Goldstein <amir73il@...il.com>
To:     Gabriel Krisman Bertazi <krisman@...labora.com>
Cc:     kernel@...labora.com, "Darrick J. Wong" <djwong@...nel.org>,
        Theodore Tso <tytso@....edu>,
        Dave Chinner <david@...morbit.com>, Jan Kara <jack@...e.com>,
        David Howells <dhowells@...hat.com>,
        Khazhismel Kumykov <khazhy@...gle.com>,
        linux-fsdevel <linux-fsdevel@...r.kernel.org>,
        Ext4 <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH v2 10/14] fsnotify: Introduce helpers to send error_events

On Wed, Jun 16, 2021 at 2:56 AM Gabriel Krisman Bertazi
<krisman@...labora.com> wrote:
>
> Introduce helpers for filesystems interested in reporting FS_ERROR
> events.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com>
>
> ---
> Changes since v1:
>   - Use the inode argument (Amir)
>   - Protect s_fsnotify_marks with ifdef guard
> ---
>  fs/notify/fsnotify.c             |  2 +-
>  include/linux/fsnotify.h         | 20 ++++++++++++++++++++
>  include/linux/fsnotify_backend.h |  1 +
>  3 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
> index 36205a769dde..ac05eb3fb368 100644
> --- a/fs/notify/fsnotify.c
> +++ b/fs/notify/fsnotify.c
> @@ -491,7 +491,7 @@ int __fsnotify(__u32 mask, const struct fsnotify_event_info *event_info)
>                  */
>                 parent = event_info->dir;
>         }
> -       sb = inode->i_sb;
> +       sb = event_info->sb ?: inode->i_sb;
>
>         /*
>          * Optimization: srcu_read_lock() has a memory barrier which can
> diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
> index 8c2c681b4495..c0dbc5a65381 100644
> --- a/include/linux/fsnotify.h
> +++ b/include/linux/fsnotify.h
> @@ -326,4 +326,24 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
>                 fsnotify_dentry(dentry, mask);
>  }
>
> +static inline int fsnotify_sb_error(struct super_block *sb, struct inode *inode,
> +                                       int error)
> +{
> +#ifdef CONFIG_FSNOTIFY
> +       if (sb->s_fsnotify_marks) {

__fsnotify() has this optimization very early
so you do not need it here and you do not need the ifdef.
performance of fsnotify_sb_error() is utterly not important.

> +               struct fs_error_report report = {
> +                       .error = error,
> +                       .inode = inode,
> +               };
> +
> +               return __fsnotify(FS_ERROR, &(struct fsnotify_event_info) {
> +                               .data = &report,
> +                               .data_type = FSNOTIFY_EVENT_ERROR,
> +                               .inode = NULL, .cookie = 0, .sb = sb

No need to set members to 0/NULL with this type of initializer.

Thanks,
Amir.

Powered by blists - more mailing lists