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: <CAOQ4uxi9HfMZFLb4joE42AZeVAZPDPPJRREaUdrKwhoQsuRHrQ@mail.gmail.com>
Date:   Tue, 26 Oct 2021 10:02:46 +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,
        Jan Kara <jack@...e.cz>
Subject: Re: [PATCH v9 23/31] fanotify: Add helpers to decide whether to
 report FID/DFID

On Mon, Oct 25, 2021 at 10:30 PM Gabriel Krisman Bertazi
<krisman@...labora.com> wrote:
>
> Now that there is an event that reports FID records even for a zeroed
> file handle, wrap the logic that deides whether to issue the records
> into helper functions.  This shouldn't have any impact on the code, but
> simplifies further patches.
>
> Reviewed-by: Jan Kara <jack@...e.cz>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.com>
>
Reviewed-by: Amir Goldstein <amir73il@...il.com>

> ---
> Changes since v8:
>   - Simplify constructs (Amir)
> ---
>  fs/notify/fanotify/fanotify.h      | 10 ++++++++++
>  fs/notify/fanotify/fanotify_user.c | 13 +++++++------
>  2 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h
> index 3510d06654ed..80af269eebb8 100644
> --- a/fs/notify/fanotify/fanotify.h
> +++ b/fs/notify/fanotify/fanotify.h
> @@ -264,6 +264,16 @@ static inline int fanotify_event_dir_fh_len(struct fanotify_event *event)
>         return info ? fanotify_info_dir_fh_len(info) : 0;
>  }
>
> +static inline bool fanotify_event_has_object_fh(struct fanotify_event *event)
> +{
> +       return fanotify_event_object_fh_len(event) > 0;
> +}
> +
> +static inline bool fanotify_event_has_dir_fh(struct fanotify_event *event)
> +{
> +       return fanotify_event_dir_fh_len(event) > 0;
> +}
> +
>  struct fanotify_path_event {
>         struct fanotify_event fae;
>         struct path path;
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index 2f4182b754b2..a9b5c36ee49e 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -140,10 +140,9 @@ static size_t fanotify_event_len(unsigned int info_mode,
>                 return event_len;
>
>         info = fanotify_event_info(event);
> -       dir_fh_len = fanotify_event_dir_fh_len(event);
> -       fh_len = fanotify_event_object_fh_len(event);
>
> -       if (dir_fh_len) {
> +       if (fanotify_event_has_dir_fh(event)) {
> +               dir_fh_len = fanotify_event_dir_fh_len(event);
>                 event_len += fanotify_fid_info_len(dir_fh_len, info->name_len);
>         } else if ((info_mode & FAN_REPORT_NAME) &&
>                    (event->mask & FAN_ONDIR)) {
> @@ -157,8 +156,10 @@ static size_t fanotify_event_len(unsigned int info_mode,
>         if (info_mode & FAN_REPORT_PIDFD)
>                 event_len += FANOTIFY_PIDFD_INFO_HDR_LEN;
>
> -       if (fh_len)
> +       if (fanotify_event_has_object_fh(event)) {
> +               fh_len = fanotify_event_object_fh_len(event);
>                 event_len += fanotify_fid_info_len(fh_len, dot_len);
> +       }
>
>         return event_len;
>  }
> @@ -451,7 +452,7 @@ static int copy_info_records_to_user(struct fanotify_event *event,
>         /*
>          * Event info records order is as follows: dir fid + name, child fid.
>          */
> -       if (fanotify_event_dir_fh_len(event)) {
> +       if (fanotify_event_has_dir_fh(event)) {
>                 info_type = info->name_len ? FAN_EVENT_INFO_TYPE_DFID_NAME :
>                                              FAN_EVENT_INFO_TYPE_DFID;
>                 ret = copy_fid_info_to_user(fanotify_event_fsid(event),
> @@ -467,7 +468,7 @@ static int copy_info_records_to_user(struct fanotify_event *event,
>                 total_bytes += ret;
>         }
>
> -       if (fanotify_event_object_fh_len(event)) {
> +       if (fanotify_event_has_object_fh(event)) {
>                 const char *dot = NULL;
>                 int dot_len = 0;
>
> --
> 2.33.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ