1. 20 4月, 2017 2 次提交
    • A
      ovl: check IS_APPEND() on real upper inode · b0990fbb
      Amir Goldstein 提交于
      For overlay file open, check IS_APPEND() on the real upper inode
      inside d_real(), because the overlay inode does not have the
      S_APPEND flag and IS_APPEND() can only be checked at open time.
      
      Note that because overlayfs does not copy up the chattr inode flags
      (i.e. S_APPEND, S_IMMUTABLE), the IS_APPEND() check is only relevant
      for upper inodes that were set with chattr +a and not to lower
      inodes that had chattr +a before copy up.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      b0990fbb
    • K
      ovl: Use designated initializers · 33006cdf
      Kees Cook 提交于
      Prepare to mark sensitive kernel structures for randomization by making
      sure they're using designated initializers. These were identified during
      allyesconfig builds of x86, arm, and arm64, with most initializer fixes
      extracted from grsecurity.
      
      For these cases, use { }, which will be zero-filled, instead of
      undesignated NULLs.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      33006cdf
  2. 02 3月, 2017 1 次提交
  3. 07 2月, 2017 4 次提交
  4. 16 12月, 2016 15 次提交
    • G
      ovl: fix return value of ovl_fill_super · 313684c4
      Geliang Tang 提交于
      If kcalloc() failed, the return value of ovl_fill_super() is -EINVAL,
      not -ENOMEM. So this patch sets this value to -ENOMEM before calling
      kcalloc(), and sets it back to -EINVAL after calling kcalloc().
      Signed-off-by: NGeliang Tang <geliangtang@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      313684c4
    • A
      ovl: clean up kstat usage · 32a3d848
      Al Viro 提交于
      FWIW, there's a bit of abuse of struct kstat in overlayfs object
      creation paths - for one thing, it ends up with a very small subset
      of struct kstat (mode + rdev), for another it also needs link in
      case of symlinks and ends up passing it separately.
      
      IMO it would be better to introduce a separate object for that.
      
      In principle, we might even lift that thing into general API and switch
       ->mkdir()/->mknod()/->symlink() to identical calling conventions.  Hell
      knows, perhaps ->create() as well...
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      32a3d848
    • A
      ovl: show redirect_dir mount option · c5bef3a7
      Amir Goldstein 提交于
      Show the value of redirect_dir in /proc/mounts.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      c5bef3a7
    • M
      ovl: allow redirect_dir to default to "on" · 688ea0e5
      Miklos Szeredi 提交于
      This patch introduces a kernel config option and a module param.  Both can
      be used independently to turn the default value of redirect_dir on or off.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      688ea0e5
    • M
      ovl: redirect on rename-dir · a6c60655
      Miklos Szeredi 提交于
      Current code returns EXDEV when a directory would need to be copied up to
      move.  We could copy up the directory tree in this case, but there's
      another, simpler solution: point to old lower directory from moved upper
      directory.
      
      This is achieved with a "trusted.overlay.redirect" xattr storing the path
      relative to the root of the overlay.  After such attribute has been set,
      the directory can be moved without further actions required.
      
      This is a backward incompatible feature, old kernels won't be able to
      correctly mount an overlay containing redirected directories.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      a6c60655
    • M
      ovl: lookup redirects · 02b69b28
      Miklos Szeredi 提交于
      If a directory has the "trusted.overlay.redirect" xattr, it means that the
      value of the xattr should be used to find the underlying directory on the
      next lower layer.
      
      The redirect may be relative or absolute.  Absolute redirects begin with a
      slash.
      
      A relative redirect means: instead of the current dentry's name use the
      value of the redirect to find the directory in the next lower
      layer. Relative redirects must not contain a slash.
      
      An absolute redirect means: look up the directory relative to the root of
      the overlay using the value of the redirect in the next lower layer.
      
      Redirects work on lower layers as well.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      02b69b28
    • A
      ovl: fix nested overlayfs mount · 48fab5d7
      Amir Goldstein 提交于
      When the upper overlayfs checks "trusted.overlay.*" xattr on the underlying
      overlayfs mount, it gets -EPERM, which confuses the upper overlayfs.
      
      Fix this by returning -EOPNOTSUPP instead of -EPERM from
      ovl_own_xattr_get() and ovl_own_xattr_set().  This behavior is consistent
      with the behavior of ovl_listxattr(), which filters out the private
      overlayfs xattrs.
      
      Note: nested overlays are deprecated.  But this change makes sense
      regardless: these xattrs are private to the overlay and should always be
      hidden.  Hence getting and setting them should indicate this.
      
      [SzMi: Use EOPNOTSUPP instead of ENODATA and use it for both getting and
      setting "trusted.overlay." xattrs.  This is a perfectly valid error code
      for "we don't support this prefix", which is the case here.]
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      48fab5d7
    • M
      ovl: check namelen · 6b2d5fe4
      Miklos Szeredi 提交于
      We already calculate f_namelen in statfs as the maximum of the name lengths
      provided by the filesystems taking part in the overlay.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      6b2d5fe4
    • M
      ovl: split super.c · bbb1e54d
      Miklos Szeredi 提交于
      fs/overlayfs/super.c is the biggest of the overlayfs source files and it
      contains various utility functions as well as the rather complicated lookup
      code.  Split these parts out to separate files.
      
      Before:
      
       1446 fs/overlayfs/super.c
      
      After:
      
        919 fs/overlayfs/super.c
        267 fs/overlayfs/namei.c
        235 fs/overlayfs/util.c
         51 fs/overlayfs/ovl_entry.h
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      bbb1e54d
    • M
      ovl: use d_is_dir() · 2b8c30e9
      Miklos Szeredi 提交于
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      2b8c30e9
    • M
      ovl: simplify lookup · 8ee6059c
      Miklos Szeredi 提交于
      If encountering a non-directory, then stop looking at lower layers.
      
      In this case the oe->opaque flag is not set anymore, which doesn't matter
      since existence of lower file is now checked at remove/rename time.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      8ee6059c
    • M
      ovl: get rid of PURE type · 38e813db
      Miklos Szeredi 提交于
      The remainging uses of __OVL_PATH_PURE can be replaced by
      ovl_dentry_is_opaque().
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      38e813db
    • M
      ovl: check lower existence when removing · 2aff4534
      Miklos Szeredi 提交于
      Currently ovl_lookup() checks existence of lower file even if there's a
      non-directory on upper (which is always opaque).  This is done so that
      remove can decide whether a whiteout is needed or not.
      
      It would be better to defer this check to unlink, since most of the time
      the gathered information about opaqueness will be unused.
      
      This adds a helper ovl_lower_positive() that checks if there's anything on
      the lower layer(s).
      
      The following patches also introduce changes to how the "opaque" attribute
      is updated on directories: this attribute is added when the directory is
      creted or moved over a whiteout or object covering something on the lower
      layer.  However following changes will allow the attribute to remain on the
      directory after being moved, even if the new location doesn't cover
      anything.  Because of this, we need to check lower layers even for opaque
      directories, so that whiteout is only created when necessary.
      
      This function will later be also used to decide about marking a directory
      opaque, so deal with negative dentries as well.  When dealing with
      negative, it's enough to check for being a whiteout
      
      If the dentry is positive but not upper then it also obviously needs
      whiteout/opaque.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      2aff4534
    • M
      ovl: add ovl_dentry_is_whiteout() · c412ce49
      Miklos Szeredi 提交于
      And use it instead of ovl_dentry_is_opaque() where appropriate.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      c412ce49
    • M
      ovl: treat special files like a regular fs · ca4c8a3a
      Miklos Szeredi 提交于
      No sense in opening special files on the underlying layers, they work just
      as well if opened on the overlay.
      
      Side effect is that it's no longer possible to connect one side of a pipe
      opened on overlayfs with the other side opened on the underlying layer.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      ca4c8a3a
  5. 29 11月, 2016 1 次提交
    • M
      ovl: fix d_real() for stacked fs · c4fcfc16
      Miklos Szeredi 提交于
      Handling of recursion in d_real() is completely broken.  Recursion is only
      done in the 'inode != NULL' case.  But when opening the file we have
      'inode == NULL' hence d_real() will return an overlay dentry.  This won't
      work since overlayfs doesn't define its own file operations, so all file
      ops will fail.
      
      Fix by doing the recursion first and the check against the inode second.
      
      Bash script to reproduce the issue written by Quentin:
      
       - 8< - - - - - 8< - - - - - 8< - - - - - 8< - - - -
      tmpdir=$(mktemp -d)
      pushd ${tmpdir}
      
      mkdir -p {upper,lower,work}
      echo -n 'rocks' > lower/ksplice
      mount -t overlay level_zero upper -o lowerdir=lower,upperdir=upper,workdir=work
      cat upper/ksplice
      
      tmpdir2=$(mktemp -d)
      pushd ${tmpdir2}
      
      mkdir -p {upper,work}
      mount -t overlay level_one upper -o lowerdir=${tmpdir}/upper,upperdir=upper,workdir=work
      ls -l upper/ksplice
      cat upper/ksplice
       - 8< - - - - - 8< - - - - - 8< - - - - - 8< - - - - 
      Reported-by: NQuentin Casasnovas <quentin.casasnovas@oracle.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      Fixes: 2d902671 ("vfs: merge .d_select_inode() into .d_real()")
      Cc: <stable@vger.kernel.org> # v4.8+
      c4fcfc16
  6. 31 10月, 2016 1 次提交
  7. 15 10月, 2016 1 次提交
  8. 14 10月, 2016 1 次提交
  9. 08 10月, 2016 1 次提交
  10. 16 9月, 2016 2 次提交
    • M
      ovl: lookup: do getxattr with mounter's permission · 2b6bc7f4
      Miklos Szeredi 提交于
      The getxattr() in ovl_is_opaquedir() was missed when converting all
      operations on underlying fs to be done under mounter's permission.
      
      This patch fixes this by moving the ovl_override_creds()/revert_creds() out
      from ovl_lookup_real() to ovl_lookup().
      
      Also convert to using vfs_getxattr() instead of directly calling
      i_op->getxattr().
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      2b6bc7f4
    • M
      locks: fix file locking on overlayfs · c568d683
      Miklos Szeredi 提交于
      This patch allows flock, posix locks, ofd locks and leases to work
      correctly on overlayfs.
      
      Instead of using the underlying inode for storing lock context use the
      overlay inode.  This allows locks to be persistent across copy-up.
      
      This is done by introducing locks_inode() helper and using it instead of
      file_inode() to get the inode in locking code.  For non-overlayfs the two
      are equivalent, except for an extra pointer dereference in locks_inode().
      
      Since lock operations are in "struct file_operations" we must also make
      sure not to call underlying filesystem's lock operations.  Introcude a
      super block flag MS_NOREMOTELOCK to this effect.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      Acked-by: NJeff Layton <jlayton@poochiereds.net>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      c568d683
  11. 05 9月, 2016 1 次提交
  12. 01 9月, 2016 7 次提交
  13. 29 7月, 2016 3 次提交