1. 24 9月, 2018 3 次提交
    • A
      vfs: swap names of {do,vfs}_clone_file_range() · a725356b
      Amir Goldstein 提交于
      Commit 031a072a ("vfs: call vfs_clone_file_range() under freeze
      protection") created a wrapper do_clone_file_range() around
      vfs_clone_file_range() moving the freeze protection to former, so
      overlayfs could call the latter.
      
      The more common vfs practice is to call do_xxx helpers from vfs_xxx
      helpers, where freeze protecction is taken in the vfs_xxx helper, so
      this anomality could be a source of confusion.
      
      It seems that commit 8ede2055 ("ovl: add reflink/copyfile/dedup
      support") may have fallen a victim to this confusion -
      ovl_clone_file_range() calls the vfs_clone_file_range() helper in the
      hope of getting freeze protection on upper fs, but in fact results in
      overlayfs allowing to bypass upper fs freeze protection.
      
      Swap the names of the two helpers to conform to common vfs practice
      and call the correct helpers from overlayfs and nfsd.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      a725356b
    • A
      ovl: fix freeze protection bypass in ovl_clone_file_range() · d9d150ae
      Amir Goldstein 提交于
      Tested by doing clone on overlayfs while upper xfs+reflink is frozen:
      
        xfs_io -f /ovl/y
                                   fsfreeze -f /xfs
        xfs_io> reflink /ovl/x
      
      Before the fix xfs_io enters xfs_reflink_remap_range() and blocks
      in xfs_trans_alloc(). After the fix, xfs_io blocks outside xfs code
      in ovl_clone_file_range().
      
      Fixes: 8ede2055 ("ovl: add reflink/copyfile/dedup support")
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      d9d150ae
    • A
      ovl: fix freeze protection bypass in ovl_write_iter() · 898cc19d
      Amir Goldstein 提交于
      Tested by re-writing to an open overlayfs file while upper ext4 is frozen:
      
        xfs_io -f /ovl/x
        xfs_io> pwrite 0 4096
                                   fsfreeze -f /ext4
        xfs_io> pwrite 0 4096
      
        WARNING: CPU: 0 PID: 1492 at fs/ext4/ext4_jbd2.c:53 \
                 ext4_journal_check_start+0x48/0x82
      
      After the fix, the second write blocks in ovl_write_iter() and avoids
      hitting WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE) in
      ext4_journal_check_start().
      
      Fixes: 2a92e07e ("ovl: add ovl_write_iter()")
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      898cc19d
  2. 03 9月, 2018 1 次提交
  3. 30 8月, 2018 1 次提交
    • A
      ovl: fix GPF in swapfile_activate of file from overlayfs over xfs · 5b910bd6
      Amir Goldstein 提交于
      Since overlayfs implements stacked file operations, the underlying
      filesystems are not supposed to be exposed to the overlayfs file,
      whose f_inode is an overlayfs inode.
      
      Assigning an overlayfs file to swap_file results in an attempt of xfs
      code to dereference an xfs_inode struct from an ovl_inode pointer:
      
       CPU: 0 PID: 2462 Comm: swapon Not tainted
       4.18.0-xfstests-12721-g33e17876 #3402
       RIP: 0010:xfs_find_bdev_for_inode+0x23/0x2f
       Call Trace:
        xfs_iomap_swapfile_activate+0x1f/0x43
        __se_sys_swapon+0xb1a/0xee9
      
      Fix this by not assigning the real inode mapping to f_mapping, which
      will cause swapon() to return an error (-EINVAL). Although it makes
      sense not to allow setting swpafile on an overlayfs file, some users
      may depend on it, so we may need to fix this up in the future.
      
      Keeping f_mapping pointing to overlay inode mapping will cause O_DIRECT
      open to fail. Fix this by installing ovl_aops with noop_direct_IO in
      overlay inode mapping.
      
      Keeping f_mapping pointing to overlay inode mapping will cause other
      a_ops related operations to fail (e.g. readahead()). Those will be
      fixed by follow up patches.
      Suggested-by: NMiklos Szeredi <mszeredi@redhat.com>
      Fixes: f7c72396 ("ovl: add O_DIRECT support")
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      5b910bd6
  4. 20 7月, 2018 2 次提交
    • V
      ovl: Do not do metacopy only for ioctl modifying file attr · 935a074f
      Vivek Goyal 提交于
      ovl_copy_up() by default will only do metadata only copy up (if enabled).
      That means when ovl_real_ioctl() calls ovl_real_file(), it will still get
      the lower file (as ovl_real_file() opens data file and not metacopy).  And
      that means "chattr +i" will end up modifying lower inode.
      
      There seem to be two ways to solve this.
      A. Open metacopy file in ovl_real_ioctl() and do operations on that
      B. Force full copy up when FS_IOC_SETFLAGS is called.
      
      I am resorting to option B for now as it feels little safer option.  If
      there are performance issues due to this, we can revisit it.
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      935a074f
    • V
      ovl: Open file with data except for the case of fsync · 8c444d2a
      Vivek Goyal 提交于
      ovl_open() should open file which contains data and not open metacopy
      inode.  With the introduction of metacopy inodes, with current
      implementaion we will end up opening metacopy inode as well.
      
      But there can be certain circumstances like ovl_fsync() where we want to
      allow opening a metacopy inode instead.
      
      Hence, change ovl_open_realfile() and and add extra parameter which
      specifies whether to allow opening metacopy inode or not.  If this
      parameter is false, we look for data inode and open that.
      
      This should allow covering both the cases.
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      8c444d2a
  5. 18 7月, 2018 10 次提交