23 Oct, 2015

3 commits

  • commit 9391dd00d13c853ab4f2a85435288ae2202e0e43 upstream.

    when opening a directory we want the overlayfs inode, not one from
    the topmost layer.

    Reported-By: Andrey Jr. Melnikov
    Tested-By: Andrey Jr. Melnikov
    Signed-off-by: Al Viro
    Cc: "Kamata, Munehisa"
    Signed-off-by: Greg Kroah-Hartman

    Al Viro
     
  • commit 4bacc9c9234c7c8eec44f5ed4e960d9f96fa0f01 upstream.

    Make file->f_path always point to the overlay dentry so that the path in
    /proc/pid/fd is correct and to ensure that label-based LSMs have access to the
    overlay as well as the underlay (path-based LSMs probably don't need it).

    Using my union testsuite to set things up, before the patch I see:

    [root@andromeda union-testsuite]# bash 5 /a/foo107
    [root@andromeda union-testsuite]# stat /mnt/a/foo107
    ...
    Device: 23h/35d Inode: 13381 Links: 1
    ...
    [root@andromeda union-testsuite]# stat -L /proc/$$/fd/5
    ...
    Device: 23h/35d Inode: 13381 Links: 1
    ...

    After the patch:

    [root@andromeda union-testsuite]# bash 5 /mnt/a/foo107
    [root@andromeda union-testsuite]# stat /mnt/a/foo107
    ...
    Device: 23h/35d Inode: 40346 Links: 1
    ...
    [root@andromeda union-testsuite]# stat -L /proc/$$/fd/5
    ...
    Device: 23h/35d Inode: 40346 Links: 1
    ...

    Note the change in where /proc/$$/fd/5 points to in the ls command. It was
    pointing to /a/foo107 (which doesn't exist) and now points to /mnt/a/foo107
    (which is correct).

    The inode accessed, however, is the lower layer. The union layer is on device
    25h/37d and the upper layer on 24h/36d.

    Signed-off-by: David Howells
    Signed-off-by: Al Viro
    Cc: "Kamata, Munehisa"
    Signed-off-by: Greg Kroah-Hartman

    David Howells
     
  • commit f25801ee4680ef1db21e15c112e6e5fe3ffe8da5 upstream.

    Call ovl_drop_write() earlier in ovl_dentry_open() before we call vfs_open()
    as we've done the copy up for which we needed the freeze-write lock by that
    point.

    Signed-off-by: David Howells
    Signed-off-by: Al Viro
    Cc: "Kamata, Munehisa"
    Signed-off-by: Greg Kroah-Hartman

    David Howells
     

13 Dec, 2014

3 commits

  • This patch adds two macros:

    OVL_XATTR_PRE_NAME and OVL_XATTR_PRE_LEN

    to present ovl_xattr name prefix and its length. Also, a
    new macro OVL_XATTR_OPAQUE is introduced to replace old
    *ovl_opaque_xattr*.

    Fix the length of "trusted.overlay." to *16*.

    Signed-off-by: hujianyang
    Signed-off-by: Miklos Szeredi

    hujianyang
     
  • This patch removes redundant blanks lines in overlayfs.

    Signed-off-by: hujianyang
    Signed-off-by: Miklos Szeredi

    hujianyang
     
  • OVL_PATH_PURE_UPPER -> __OVL_PATH_UPPER | __OVL_PATH_PURE
    OVL_PATH_UPPER -> __OVL_PATH_UPPER
    OVL_PATH_MERGE -> __OVL_PATH_UPPER | __OVL_PATH_MERGE
    OVL_PATH_LOWER -> 0

    Multiple R/O layers will allow __OVL_PATH_MERGE without __OVL_PATH_UPPER.

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     

20 Nov, 2014

1 commit

  • Xattr operations can race with copy up. This does not matter as long as
    we consistently fiter out "trunsted.overlay.opaque" attribute on upper
    directories.

    Previously we checked parent against OVL_PATH_MERGE. This is too general,
    and prone to race with copy-up. I.e. we found the parent to be on the
    lower layer but ovl_dentry_real() would return the copied-up dentry,
    possibly with the "opaque" attribute.

    So instead use ovl_path_real() and decide to filter the attributes based on
    the actual type of the dentry we'll use.

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     

24 Oct, 2014

1 commit

  • Overlayfs allows one, usually read-write, directory tree to be
    overlaid onto another, read-only directory tree. All modifications
    go to the upper, writable layer.

    This type of mechanism is most often used for live CDs but there's a
    wide variety of other uses.

    The implementation differs from other "union filesystem"
    implementations in that after a file is opened all operations go
    directly to the underlying, lower or upper, filesystems. This
    simplifies the implementation and allows native performance in these
    cases.

    The dentry tree is duplicated from the underlying filesystems, this
    enables fast cached lookups without adding special support into the
    VFS. This uses slightly more memory than union mounts, but dentries
    are relatively small.

    Currently inodes are duplicated as well, but it is a possible
    optimization to share inodes for non-directories.

    Opening non directories results in the open forwarded to the
    underlying filesystem. This makes the behavior very similar to union
    mounts (with the same limitations vs. fchmod/fchown on O_RDONLY file
    descriptors).

    Usage:

    mount -t overlayfs overlayfs -olowerdir=/lower,upperdir=/upper/upper,workdir=/upper/work /overlay

    The following cotributions have been folded into this patch:

    Neil Brown :
    - minimal remount support
    - use correct seek function for directories
    - initialise is_real before use
    - rename ovl_fill_cache to ovl_dir_read

    Felix Fietkau :
    - fix a deadlock in ovl_dir_read_merged
    - fix a deadlock in ovl_remove_whiteouts

    Erez Zadok
    - fix cleanup after WARN_ON

    Sedat Dilek
    - fix up permission to confirm to new API

    Robin Dong
    - fix possible leak in ovl_new_inode
    - create new inode in ovl_link

    Andy Whitcroft
    - switch to __inode_permission()
    - copy up i_uid/i_gid from the underlying inode

    AV:
    - ovl_copy_up_locked() - dput(ERR_PTR(...)) on two failure exits
    - ovl_clear_empty() - one failure exit forgetting to do unlock_rename(),
    lack of check for udir being the parent of upper, dropping and regaining
    the lock on udir (which would require _another_ check for parent being
    right).
    - bogus d_drop() in copyup and rename [fix from your mail]
    - copyup/remove and copyup/rename races [fix from your mail]
    - ovl_dir_fsync() leaving ERR_PTR() in ->realfile
    - ovl_entry_free() is pointless - it's just a kfree_rcu()
    - fold ovl_do_lookup() into ovl_lookup()
    - manually assigning ->d_op is wrong. Just use ->s_d_op.
    [patches picked from Miklos]:
    * copyup/remove and copyup/rename races
    * bogus d_drop() in copyup and rename

    Also thanks to the following people for testing and reporting bugs:

    Jordi Pujol
    Andy Whitcroft
    Michal Suchanek
    Felix Fietkau
    Erez Zadok
    Randy Dunlap

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi