Re: [PATCH v5 21/22] fanotify: report parent fid + name + child fid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 16, 2020 at 6:59 PM Jan Kara <jack@xxxxxxx> wrote:
>
> On Thu 16-07-20 11:42:29, Amir Goldstein wrote:
> > For a group with fanotify_init() flag FAN_REPORT_DFID_NAME, the parent
> > fid and name are reported for events on non-directory objects with an
> > info record of type FAN_EVENT_INFO_TYPE_DFID_NAME.
> >
> > If the group also has the init flag FAN_REPORT_FID, the child fid
> > is also reported with another info record that follows the first info
> > record. The second info record is the same info record that would have
> > been reported to a group with only FAN_REPORT_FID flag.
> >
> > When the child fid needs to be recorded, the variable size struct
> > fanotify_name_event is preallocated with enough space to store the
> > child fh between the dir fh and the name.
> >
> > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> > ---
> >  fs/notify/fanotify/fanotify.c      | 30 ++++++++++++++++++++++++++----
> >  fs/notify/fanotify/fanotify.h      |  8 +++++++-
> >  fs/notify/fanotify/fanotify_user.c |  3 ++-
> >  3 files changed, 35 insertions(+), 6 deletions(-)
> >
> > diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> > index c77b37eb33a9..1d8eb886fe08 100644
> > --- a/fs/notify/fanotify/fanotify.c
> > +++ b/fs/notify/fanotify/fanotify.c
> > @@ -479,15 +479,22 @@ static struct fanotify_event *fanotify_alloc_fid_event(struct inode *id,
> >  static struct fanotify_event *fanotify_alloc_name_event(struct inode *id,
> >                                                       __kernel_fsid_t *fsid,
> >                                                       const struct qstr *file_name,
> > +                                                     struct inode *child,
> >                                                       gfp_t gfp)
> >  {
> >       struct fanotify_name_event *fne;
> >       struct fanotify_info *info;
> > -     struct fanotify_fh *dfh;
> > +     struct fanotify_fh *dfh, *ffh;
> >       unsigned int dir_fh_len = fanotify_encode_fh_len(id);
> > +     unsigned int child_fh_len = fanotify_encode_fh_len(child);
> >       unsigned int size;
> >
> > +     if (WARN_ON_ONCE(dir_fh_len % FANOTIFY_FH_HDR_LEN))
> > +             child_fh_len = 0;
> > +
>
> Why this check? Do you want to check everything is 4-byte aligned? But then
> FANOTIFY_FH_HDR_LEN works mostly by accident...

Good catch.
That's indeed a mistake.
Should be % 4 which is expected because
...
        return dwords << 2;

If you think that is over defensive, you can drop it.

Thanks,
Amir.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux