Re: [PATCH v2 02/16] fsnotify: factor helpers fsnotify_dentry() and fsnotify_file()

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

 



On Tue, Feb 25, 2020 at 3:46 PM Jan Kara <jack@xxxxxxx> wrote:
>
> On Mon 17-02-20 15:14:41, Amir Goldstein wrote:
> > Most of the code in fsnotify hooks is boiler plate of one or the other.
> >
> > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> > ---
> >  include/linux/fsnotify.h | 96 +++++++++++++++-------------------------
> >  1 file changed, 36 insertions(+), 60 deletions(-)
>
> Nice cleanup. Just two comments below.
>
> > @@ -58,8 +78,6 @@ static inline int fsnotify_path(struct inode *inode, const struct path *path,
> >  static inline int fsnotify_perm(struct file *file, int mask)
> >  {
> >       int ret;
> > -     const struct path *path = &file->f_path;
> > -     struct inode *inode = file_inode(file);
> >       __u32 fsnotify_mask = 0;
> >
> >       if (file->f_mode & FMODE_NONOTIFY)
>
> I guess you can drop the NONOTIFY check from here. You've moved it to
> fsnotify_file() and there's not much done in this function to be worth
> skipping...

True.

>
> > @@ -70,7 +88,7 @@ static inline int fsnotify_perm(struct file *file, int mask)
> >               fsnotify_mask = FS_OPEN_PERM;
> >
> >               if (file->f_flags & __FMODE_EXEC) {
> > -                     ret = fsnotify_path(inode, path, FS_OPEN_EXEC_PERM);
> > +                     ret = fsnotify_file(file, FS_OPEN_EXEC_PERM);
> >
> >                       if (ret)
> >                               return ret;
>
> Hum, I think we could simplify fsnotify_perm() even further by having:
>
>         if (mask & MAY_OPEN) {
>                 if (file->f_flags & __FMODE_EXEC)
>                         fsnotify_mask = FS_OPEN_EXEC_PERM;
>                 else
>                         fsnotify_mask = FS_OPEN_PERM;
>         } ...
>

But the current code sends both FS_OPEN_EXEC_PERM and FS_OPEN_PERM
on an open for exec. I believe that is what was discussed when Matthew wrote
the OPEN_EXEC patches, so existing receivers of OPEN_PERM event on exec
will not regress..

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