1. 17 7月, 2018 1 次提交
  2. 12 4月, 2018 1 次提交
  3. 24 1月, 2018 2 次提交
  4. 20 1月, 2018 2 次提交
    • A
      ovl: take mnt_want_write() for removing impure xattr · a5a927a7
      Amir Goldstein 提交于
      The optimization in ovl_cache_get_impure() that tries to remove an
      unneeded "impure" xattr needs to take mnt_want_write() on upper fs.
      
      Fixes: 4edb83bb ("ovl: constant d_ino for non-merge dirs")
      Cc: <stable@vger.kernel.org> #v4.14
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      a5a927a7
    • A
      ovl: take lower dir inode mutex outside upper sb_writers lock · 6d0a8a90
      Amir Goldstein 提交于
      The functions ovl_lower_positive() and ovl_check_empty_dir() both take
      inode mutex on the real lower dir under ovl_want_write() which takes
      the upper_mnt sb_writers lock.
      
      While this is not a clear locking order or layering violation, it creates
      an undesired lock dependency between two unrelated layers for no good
      reason.
      
      This lock dependency materializes to a false(?) positive lockdep warning
      when calling rmdir() on a nested overlayfs, where both nested and
      underlying overlayfs both use the same fs type as upper layer.
      
      rmdir() on the nested overlayfs creates the lock chain:
        sb_writers of upper_mnt (e.g. tmpfs) in ovl_do_remove()
        ovl_i_mutex_dir_key[] of lower overlay dir in ovl_lower_positive()
      
      rmdir() on the underlying overlayfs creates the lock chain in
      reverse order:
        ovl_i_mutex_dir_key[] of lower overlay dir in vfs_rmdir()
        sb_writers of nested upper_mnt (e.g. tmpfs) in ovl_do_remove()
      
      To rid of the unneeded locking dependency, move both ovl_lower_positive()
      and ovl_check_empty_dir() to before ovl_want_write() in rmdir() and
      rename() implementation.
      
      This change spreads the pieces of ovl_check_empty_and_clear() directly
      inside the rmdir()/rename() implementations so the helper is no longer
      needed and removed.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      6d0a8a90
  5. 19 1月, 2018 1 次提交
  6. 17 12月, 2017 1 次提交
  7. 14 12月, 2017 1 次提交
  8. 11 12月, 2017 1 次提交
  9. 09 11月, 2017 3 次提交
  10. 24 10月, 2017 2 次提交
    • A
      ovl: do not cleanup unsupported index entries · fa0096e3
      Amir Goldstein 提交于
      With index=on, ovl_indexdir_cleanup() tries to cleanup invalid index
      entries (e.g. bad index name). This behavior could result in cleaning of
      entries created by newer kernels and is therefore undesirable.
      Instead, abort mount if such entries are encountered. We still cleanup
      'stale' entries and 'orphan' entries, both those cases can be a result
      of offline changes to lower and upper dirs.
      
      When encoutering an index entry of type directory or whiteout, kernel
      was supposed to fallback to read-only mount, but the fill_super()
      operation returns EROFS in this case instead of returning success with
      read-only mount flag, so mount fails when encoutering directory or
      whiteout index entries. Bless this behavior by returning -EINVAL on
      directory and whiteout index entries as we do for all unsupported index
      entries.
      
      Fixes: 61b67471 ("ovl: do not cleanup directory and whiteout index..")
      Cc: <stable@vger.kernel.org> # v4.13
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      fa0096e3
    • W
      locking/barriers: Convert users of lockless_dereference() to READ_ONCE() · 506458ef
      Will Deacon 提交于
      READ_ONCE() now has an implicit smp_read_barrier_depends() call, so it
      can be used instead of lockless_dereference() without any change in
      semantics.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1508840570-22169-4-git-send-email-will.deacon@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      506458ef
  11. 05 10月, 2017 1 次提交
  12. 10 8月, 2017 1 次提交
  13. 28 7月, 2017 3 次提交
    • M
      ovl: constant d_ino for non-merge dirs · 4edb83bb
      Miklos Szeredi 提交于
      Impure directories are ones which contain objects with origins (i.e. those
      that have been copied up).  These are relevant to readdir operation only
      because of the d_ino field, no other transformation is necessary.  Also a
      directory can become impure between two getdents(2) calls.
      
      This patch creates a cache for impure directories.  Unlike the cache for
      merged directories, this one only contains entries with origin and is not
      refcounted but has a its lifetime tied to that of the dentry.
      
      Similarly to the merged cache, the impure cache is invalidated based on a
      version number.  This version number is incremented when an entry with
      origin is added or removed from the directory.
      
      If the cache is empty, then the impure xattr is removed from the directory.
      
      This patch also fixes up handling of d_ino for the ".." entry if the parent
      directory is merged.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      4edb83bb
    • A
      ovl: constant d_ino across copy up · b5efccbe
      Amir Goldstein 提交于
      When all layers are on the same fs, and iterating a directory which may
      contain copy up entries, call vfs_getattr() on the overlay entries to make
      sure that d_ino will be consistent with st_ino from stat(2).
      
      There is an overhead of lookup per upper entry in readdir.
      
      The overhead is minimal if the iterated entries are already in dcache.  It
      is also quite useful for the common case of 'ls -l' that readdir() pre
      populates the dcache with the listed entries, making the following stat()
      calls faster.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      b5efccbe
    • M
      ovl: fix readdir error value · 31e8ccea
      Miklos Szeredi 提交于
      actor's return value is taken as a bool (filled/not filled) so we need to
      return the error in the context.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      31e8ccea
  14. 20 7月, 2017 1 次提交
    • A
      ovl: do not cleanup directory and whiteout index entries · 61b67471
      Amir Goldstein 提交于
      Directory index entries are going to be used for looking up
      redirected upper dirs by lower dir fh when decoding an overlay
      file handle of a merge dir.
      
      Whiteout index entries are going to be used as an indication that
      an exported overlay file handle should be treated as stale (i.e.
      after unlink of the overlay inode).
      
      We don't know the verification rules for directory and whiteout
      index entries, because they have not been implemented yet, so fail
      to mount overlay rw if those entries are found to avoid corrupting
      an index that was created by a newer kernel.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      61b67471
  15. 05 7月, 2017 1 次提交
    • A
      ovl: cleanup bad and stale index entries on mount · 415543d5
      Amir Goldstein 提交于
      Bad index entries are entries whose name does not match the
      origin file handle stored in trusted.overlay.origin xattr.
      Bad index entries could be a result of a system power off in
      the middle of copy up.
      
      Stale index entries are entries whose origin file handle is
      stale. Stale index entries could be a result of copying layers
      or removing lower entries while the overlay is not mounted.
      The case of copying layers should be detected earlier by the
      verification of upper root dir origin and index dir origin.
      
      Both bad and stale index entries are detected and removed
      on mount.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      415543d5
  16. 01 9月, 2016 1 次提交
    • M
      ovl: proper cleanup of workdir · eea2fb48
      Miklos Szeredi 提交于
      When mounting overlayfs it needs a clean "work" directory under the
      supplied workdir.
      
      Previously the mount code removed this directory if it already existed and
      created a new one.  If the removal failed (e.g. directory was not empty)
      then it fell back to a read-only mount not using the workdir.
      
      While this has never been reported, it is possible to get a non-empty
      "work" dir from a previous mount of overlayfs in case of crash in the
      middle of an operation using the work directory.
      
      In this case the left over state should be discarded and the overlay
      filesystem will be consistent, guaranteed by the atomicity of operations on
      moving to/from the workdir to the upper layer.
      
      This patch implements cleaning out any files left in workdir.  It is
      implemented using real recursion for simplicity, but the depth is limited
      to 2, because the worst case is that of a directory containing whiteouts
      under "work".
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      Cc: <stable@vger.kernel.org>
      eea2fb48
  17. 27 5月, 2016 1 次提交
    • A
      ovl: override creds with the ones from the superblock mounter · 3fe6e52f
      Antonio Murdaca 提交于
      In user namespace the whiteout creation fails with -EPERM because the
      current process isn't capable(CAP_SYS_ADMIN) when setting xattr.
      
      A simple reproducer:
      
      $ mkdir upper lower work merged lower/dir
      $ sudo mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merged
      $ unshare -m -p -f -U -r bash
      
      Now as root in the user namespace:
      
      \# touch merged/dir/{1,2,3} # this will force a copy up of lower/dir
      \# rm -fR merged/*
      
      This ends up failing with -EPERM after the files in dir has been
      correctly deleted:
      
      unlinkat(4, "2", 0)                     = 0
      unlinkat(4, "1", 0)                     = 0
      unlinkat(4, "3", 0)                     = 0
      close(4)                                = 0
      unlinkat(AT_FDCWD, "merged/dir", AT_REMOVEDIR) = -1 EPERM (Operation not
      permitted)
      
      Interestingly, if you don't place files in merged/dir you can remove it,
      meaning if upper/dir does not exist, creating the char device file works
      properly in that same location.
      
      This patch uses ovl_sb_creator_cred() to get the cred struct from the
      superblock mounter and override the old cred with these new ones so that
      the whiteout creation is possible because overlay is wrong in assuming that
      the creds it will get with prepare_creds will be in the initial user
      namespace.  The old cap_raise game is removed in favor of just overriding
      the old cred struct.
      
      This patch also drops from ovl_copy_up_one() the following two lines:
      
      override_cred->fsuid = stat->uid;
      override_cred->fsgid = stat->gid;
      
      This is because the correct uid and gid are taken directly with the stat
      struct and correctly set with ovl_set_attr().
      Signed-off-by: NAntonio Murdaca <runcom@redhat.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      3fe6e52f
  18. 26 5月, 2016 1 次提交
  19. 03 5月, 2016 1 次提交
  20. 22 3月, 2016 2 次提交
    • M
      ovl: rename is_merge to is_lowest · 56656e96
      Miklos Szeredi 提交于
      The 'is_merge' is an historical naming from when only a single lower layer
      could exist.  With the introduction of multiple lower layers the meaning of
      this flag was changed to mean only the "lowest layer" (while all lower
      layers were being merged).
      
      So now 'is_merge' is inaccurate and hence renaming to 'is_lowest'
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      56656e96
    • V
      ovl: Ensure upper filesystem supports d_type · 45aebeaf
      Vivek Goyal 提交于
      In some instances xfs has been created with ftype=0 and there if a file
      on lower fs is removed, overlay leaves a whiteout in upper fs but that
      whiteout does not get filtered out and is visible to overlayfs users.
      
      And reason it does not get filtered out because upper filesystem does
      not report file type of whiteout as DT_CHR during iterate_dir().
      
      So it seems to be a requirement that upper filesystem support d_type for
      overlayfs to work properly. Do this check during mount and fail if d_type
      is not supported.
      Suggested-by: NDave Chinner <dchinner@redhat.com>
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      45aebeaf
  21. 23 1月, 2016 1 次提交
    • A
      wrappers for ->i_mutex access · 5955102c
      Al Viro 提交于
      parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
      inode_foo(inode) being mutex_foo(&inode->i_mutex).
      
      Please, use those for access to ->i_mutex; over the coming cycle
      ->i_mutex will become rwsem, with ->lookup() done with it held
      only shared.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      5955102c
  22. 11 12月, 2015 1 次提交
    • K
      ovl: check dentry positiveness in ovl_cleanup_whiteouts() · 84889d49
      Konstantin Khlebnikov 提交于
      This patch fixes kernel crash at removing directory which contains
      whiteouts from lower layers.
      
      Cache of directory content passed as "list" contains entries from all
      layers, including whiteouts from lower layers. So, lookup in upper dir
      (moved into work at this stage) will return negative entry. Plus this
      cache is filled long before and we can race with external removal.
      
      Example:
       mkdir -p lower0/dir lower1/dir upper work overlay
       touch lower0/dir/a lower0/dir/b
       mknod lower1/dir/a c 0 0
       mount -t overlay none overlay -o lowerdir=lower1:lower0,upperdir=upper,workdir=work
       rm -fr overlay/dir
      Signed-off-by: NKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: NMiklos Szeredi <miklos@szeredi.hu>
      Cc: <stable@vger.kernel.org> # 3.18+
      84889d49
  23. 22 6月, 2015 1 次提交
    • M
      ovl: lookup whiteouts outside iterate_dir() · cdb67279
      Miklos Szeredi 提交于
      If jffs2 can deadlock on overlayfs readdir because it takes the same lock
      on ->iterate() as in ->lookup().
      
      Fix by moving whiteout checking outside iterate_dir().  Optimized by
      collecting potential whiteouts (DT_CHR) in a temporary list and if
      non-empty iterating throug these and checking for a 0/0 chardev.
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Fixes: 49c21e1c ("ovl: check whiteout while reading directory")
      Reported-by: Roman Yeryomin <leroi.lists@gmail.com> 
      cdb67279
  24. 09 1月, 2015 1 次提交
  25. 13 12月, 2014 4 次提交
  26. 20 11月, 2014 2 次提交
  27. 05 11月, 2014 1 次提交
  28. 01 11月, 2014 1 次提交