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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxhh-qMLnHWJKwxZ3PZqCNq13tM9c++2W8hCAegW_Vt7Tw@mail.gmail.com>
Date:   Tue, 19 Oct 2021 09:09:36 +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>,
        Ext4 <linux-ext4@...r.kernel.org>,
        Linux API <linux-api@...r.kernel.org>, kernel@...labora.com,
        Jan Kara <jack@...e.cz>
Subject: Re: [PATCH v8 23/32] fanotify: Wrap object_fh inline space in a
 creator macro

On Tue, Oct 19, 2021 at 3:03 AM Gabriel Krisman Bertazi
<krisman@...labora.com> wrote:
>
> fanotify_error_event would duplicate this sequence of declarations that
> already exist elsewhere with a slight different size.  Create a helper
> macro to avoid code duplication.
>
> Suggested-by: Jan Kara <jack@...e.cz>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com>
>

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

with minor nit

> ---
> Among the suggestions, I think this is simpler because it avoids
> deep nesting the variable-sized attribute, which would have been hidden
> inside fee->ffe->object_fh.buf.
>
> It also avoids touching the allocators, which are nicely hidden inside
> helper KMEM_CACHE() macros that hides several parameters.

I like this option best as well.

> ---
>  fs/notify/fanotify/fanotify.h | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h
> index 2b032b79d5b0..a5e81d759f65 100644
> --- a/fs/notify/fanotify/fanotify.h
> +++ b/fs/notify/fanotify/fanotify.h
> @@ -171,12 +171,19 @@ static inline void fanotify_init_event(struct fanotify_event *event,
>         event->pid = NULL;
>  }
>
> +#define FANOTIFY_INLINE_FH(size)                                       \
> +struct {                                                               \
> +       struct fanotify_fh object_fh;                                   \
> +       /* Space for object_fh.buf[] - access with fanotify_fh_buf() */ \
> +       unsigned char _inline_fh_buf[(size)];                           \
> +}
> +
>  struct fanotify_fid_event {
>         struct fanotify_event fae;
>         __kernel_fsid_t fsid;
> -       struct fanotify_fh object_fh;
> -       /* Reserve space in object_fh.buf[] - access with fanotify_fh_buf() */
> -       unsigned char _inline_fh_buf[FANOTIFY_INLINE_FH_LEN];
> +
> +       /* This must be the last element of the structure. */
> +       FANOTIFY_INLINE_FH(FANOTIFY_INLINE_FH_LEN);
>  };

It's not true that is must be the last element.
this is only true for struct fanotify_fh with zero size buf[].

Thanks,
Amir.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ