Merge tag 'fsnotify_for_v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Jul 2019 03:09:17 +0000 (20:09 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Jul 2019 03:09:17 +0000 (20:09 -0700)
Pull fsnotify updates from Jan Kara:
 "This contains cleanups of the fsnotify name removal hook and also a
  patch to disable fanotify permission events for 'proc' filesystem"

* tag 'fsnotify_for_v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  fsnotify: get rid of fsnotify_nameremove()
  fsnotify: move fsnotify_nameremove() hook out of d_delete()
  configfs: call fsnotify_rmdir() hook
  debugfs: call fsnotify_{unlink,rmdir}() hooks
  debugfs: simplify __debugfs_remove_file()
  devpts: call fsnotify_unlink() hook
  tracefs: call fsnotify_{unlink,rmdir}() hooks
  rpc_pipefs: call fsnotify_{unlink,rmdir}() hooks
  btrfs: call fsnotify_rmdir() hook
  fsnotify: add empty fsnotify_{unlink,rmdir}() hooks
  fanotify: Disallow permission events for proc filesystem

1  2 
fs/btrfs/ioctl.c
fs/configfs/dir.c
fs/tracefs/inode.c
include/linux/fs.h
include/linux/fsnotify_backend.h

diff --combined fs/btrfs/ioctl.c
index 2a1be0d1a69866754fe2932ee72d03ff4fe98a0e,2cfd1bfb387181449ffce9eea3357a2de834f515..56ae2f659b6d6e9bd5b5f792f1588362ca72ed3d
@@@ -312,6 -312,8 +312,6 @@@ static int btrfs_ioctl_setflags(struct 
                        btrfs_abort_transaction(trans, ret);
                        goto out_end_trans;
                }
 -              set_bit(BTRFS_INODE_COPY_EVERYTHING,
 -                      &BTRFS_I(inode)->runtime_flags);
        } else {
                ret = btrfs_set_prop(trans, inode, "btrfs.compression", NULL,
                                     0, 0);
@@@ -2928,8 -2930,10 +2928,10 @@@ static noinline int btrfs_ioctl_snap_de
        inode_lock(inode);
        err = btrfs_delete_subvolume(dir, dentry);
        inode_unlock(inode);
-       if (!err)
+       if (!err) {
+               fsnotify_rmdir(dir, dentry);
                d_delete(dentry);
+       }
  
  out_dput:
        dput(dentry);
diff --combined fs/configfs/dir.c
index d2ca5287762d8129998979296bf9c7fd97c6360d,ba17881a8d84823e1ab8600ca86d57c3d823ee5e..92112915de8e752a1a9ae1b548513e41c7d0f7e4
@@@ -1,9 -1,23 +1,9 @@@
 +// SPDX-License-Identifier: GPL-2.0-or-later
  /* -*- mode: c; c-basic-offset: 8; -*-
   * vim: noexpandtab sw=8 ts=8 sts=0:
   *
   * dir.c - Operations for configfs directories.
   *
 - * This program is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU General Public
 - * License as published by the Free Software Foundation; either
 - * version 2 of the License, or (at your option) any later version.
 - *
 - * This program is distributed in the hope that it will be useful,
 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * General Public License for more details.
 - *
 - * You should have received a copy of the GNU General Public
 - * License along with this program; if not, write to the
 - * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 - * Boston, MA 021110-1307, USA.
 - *
   * Based on sysfs:
   *    sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel
   *
@@@ -13,6 -27,7 +13,7 @@@
  #undef DEBUG
  
  #include <linux/fs.h>
+ #include <linux/fsnotify.h>
  #include <linux/mount.h>
  #include <linux/module.h>
  #include <linux/slab.h>
@@@ -44,13 -59,15 +45,13 @@@ static void configfs_d_iput(struct dent
        if (sd) {
                /* Coordinate with configfs_readdir */
                spin_lock(&configfs_dirent_lock);
 -              /* Coordinate with configfs_attach_attr where will increase
 -               * sd->s_count and update sd->s_dentry to new allocated one.
 -               * Only set sd->dentry to null when this dentry is the only
 -               * sd owner.
 -               * If not do so, configfs_d_iput may run just after
 -               * configfs_attach_attr and set sd->s_dentry to null
 -               * even it's still in use.
 +              /*
 +               * Set sd->s_dentry to null only when this dentry is the one
 +               * that is going to be killed.  Otherwise configfs_d_iput may
 +               * run just after configfs_attach_attr and set sd->s_dentry to
 +               * NULL even it's still in use.
                 */
 -              if (atomic_read(&sd->s_count) <= 2)
 +              if (sd->s_dentry == dentry)
                        sd->s_dentry = NULL;
  
                spin_unlock(&configfs_dirent_lock);
@@@ -1788,6 -1805,7 +1789,7 @@@ void configfs_unregister_group(struct c
        configfs_detach_group(&group->cg_item);
        d_inode(dentry)->i_flags |= S_DEAD;
        dont_mount(dentry);
+       fsnotify_rmdir(d_inode(parent), dentry);
        d_delete(dentry);
        inode_unlock(d_inode(parent));
  
@@@ -1916,6 -1934,7 +1918,7 @@@ void configfs_unregister_subsystem(stru
        configfs_detach_group(&group->cg_item);
        d_inode(dentry)->i_flags |= S_DEAD;
        dont_mount(dentry);
+       fsnotify_rmdir(d_inode(root), dentry);
        inode_unlock(d_inode(dentry));
  
        d_delete(dentry);
diff --combined fs/tracefs/inode.c
index a5bab190a2972c015b0f4eec15c239856a2f4d05,497a8682b5b94f870528fab7daa550c492b39d40..eeeae0475da9d0cc15b5b6fe363fd77404e481b9
@@@ -1,4 -1,3 +1,4 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   *  inode.c - part of tracefs, a pseudo file system for activating tracing
   *
@@@ -6,7 -5,12 +6,7 @@@
   *
   *  Copyright (C) 2014 Red Hat Inc, author: Steven Rostedt <srostedt@redhat.com>
   *
 - *    This program is free software; you can redistribute it and/or
 - *    modify it under the terms of the GNU General Public License version
 - *    2 as published by the Free Software Foundation.
 - *
   * tracefs is the file system that is used by the tracing infrastructure.
 - *
   */
  
  #include <linux/module.h>
@@@ -505,9 -509,12 +505,12 @@@ static int __tracefs_remove(struct dent
                        switch (dentry->d_inode->i_mode & S_IFMT) {
                        case S_IFDIR:
                                ret = simple_rmdir(parent->d_inode, dentry);
+                               if (!ret)
+                                       fsnotify_rmdir(parent->d_inode, dentry);
                                break;
                        default:
                                simple_unlink(parent->d_inode, dentry);
+                               fsnotify_unlink(parent->d_inode, dentry);
                                break;
                        }
                        if (!ret)
diff --combined include/linux/fs.h
index 4fb399b7732711334be3ea72151c11f6d3b12fa6,c7136c98b5baf4fb63422a462d5387d261af2278..201ebb1e062d2dcc38e0a9ee1c25a970e11c0ad3
@@@ -694,7 -694,7 +694,7 @@@ struct inode 
        atomic_t                i_count;
        atomic_t                i_dio_count;
        atomic_t                i_writecount;
 -#ifdef CONFIG_IMA
 +#if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING)
        atomic_t                i_readcount; /* struct files open RO */
  #endif
        union {
@@@ -1769,7 -1769,7 +1769,7 @@@ struct block_device_operations
  /*
   * These flags control the behavior of the remap_file_range function pointer.
   * If it is called with len == 0 that means "remap to end of source file".
 - * See Documentation/filesystems/vfs.txt for more details about this call.
 + * See Documentation/filesystems/vfs.rst for more details about this call.
   *
   * REMAP_FILE_DEDUP: only remap if contents identical (i.e. deduplicate)
   * REMAP_FILE_CAN_SHORTEN: caller can handle a shortened request
@@@ -2184,6 -2184,7 +2184,7 @@@ struct file_system_type 
  #define FS_BINARY_MOUNTDATA   2
  #define FS_HAS_SUBTYPE                4
  #define FS_USERNS_MOUNT               8       /* Can be mounted by userns root */
+ #define FS_DISALLOW_NOTIFY_PERM       16      /* Disable fanotify permission events */
  #define FS_RENAME_DOES_D_MOVE 32768   /* FS will handle d_move() during rename() internally. */
        int (*init_fs_context)(struct fs_context *);
        const struct fs_parameter_description *parameters;
@@@ -2890,7 -2891,7 +2891,7 @@@ static inline bool inode_is_open_for_wr
        return atomic_read(&inode->i_writecount) > 0;
  }
  
 -#ifdef CONFIG_IMA
 +#if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING)
  static inline void i_readcount_dec(struct inode *inode)
  {
        BUG_ON(!atomic_read(&inode->i_readcount));
index d4844cad2c2bb92ca885f2d3c113f21a47c3c285,c28f6ed1f59b82302b0a733090fecfb42bc1436c..2de3b2ddd19ac446fe076d35d9fcdd8b8696e027
@@@ -292,9 -292,7 +292,9 @@@ typedef struct fsnotify_mark_connector 
   */
  struct fsnotify_mark_connector {
        spinlock_t lock;
 -      unsigned int type;      /* Type of object [lock] */
 +      unsigned short type;    /* Type of object [lock] */
 +#define FSNOTIFY_CONN_FLAG_HAS_FSID   0x01
 +      unsigned short flags;   /* flags [lock] */
        __kernel_fsid_t fsid;   /* fsid of filesystem containing object */
        union {
                /* Object pointer [lock] */
@@@ -357,7 -355,6 +357,6 @@@ extern int __fsnotify_parent(const stru
  extern void __fsnotify_inode_delete(struct inode *inode);
  extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
  extern void fsnotify_sb_delete(struct super_block *sb);
- extern void fsnotify_nameremove(struct dentry *dentry, int isdir);
  extern u32 fsnotify_get_cookie(void);
  
  static inline int fsnotify_inode_watches_children(struct inode *inode)
@@@ -527,9 -524,6 +526,6 @@@ static inline void __fsnotify_vfsmount_
  static inline void fsnotify_sb_delete(struct super_block *sb)
  {}
  
- static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
- {}
  static inline void fsnotify_update_flags(struct dentry *dentry)
  {}