15 May, 2019

1 commit


08 May, 2019

2 commits

  • This nasty little syzbot repro:
    https://syzkaller.appspot.com/x/repro.syz?x=12c7a94f400000

    Creates overlay mounts where the same directory is both in upper and lower
    layers. Simplified example:

    mkdir foo work
    mount -t overlay none foo -o"lowerdir=.,upperdir=foo,workdir=work"

    The repro runs several threads in parallel that attempt to chdir into foo
    and attempt to symlink/rename/exec/mkdir the file bar.

    The repro hits a WARN_ON() I placed in ovl_instantiate(), which suggests
    that an overlay inode already exists in cache and is hashed by the pointer
    of the real upper dentry that ovl_create_real() has just created. At the
    point of the WARN_ON(), for overlay dir inode lock is held and upper dir
    inode lock, so at first, I did not see how this was possible.

    On a closer look, I see that after ovl_create_real(), because of the
    overlapping upper and lower layers, a lookup by another thread can find the
    file foo/bar that was just created in upper layer, at overlay path
    foo/foo/bar and hash the an overlay inode with the new real dentry as lower
    dentry. This is possible because the overlay directory foo/foo is not
    locked and the upper dentry foo/bar is in dcache, so ovl_lookup() can find
    it without taking upper dir inode shared lock.

    Overlapping layers is considered a wrong setup which would result in
    unexpected behavior, but it shouldn't crash the kernel and it shouldn't
    trigger WARN_ON() either, so relax this WARN_ON() and leave a pr_warn()
    instead to cover all cases of failure to get an overlay inode.

    The error returned from failure to insert new inode to cache with
    inode_insert5() was changed to -EEXIST, to distinguish from the error
    -ENOMEM returned on failure to get/allocate inode with iget5_locked().

    Reported-by: syzbot+9c69c282adc4edd2b540@syzkaller.appspotmail.com
    Fixes: 01b39dcc9568 ("ovl: use inode_insert5() to hash a newly...")
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • Pull misc dcache updates from Al Viro:
    "Most of this pile is putting name length into struct name_snapshot and
    making use of it.

    The beginning of this series ("ovl_lookup_real_one(): don't bother
    with strlen()") ought to have been split in two (separate switch of
    name_snapshot to struct qstr from overlayfs reaping the trivial
    benefits of that), but I wanted to avoid a rebase - by the time I'd
    spotted that it was (a) in -next and (b) close to 5.1-final ;-/"

    * 'work.dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    audit_compare_dname_path(): switch to const struct qstr *
    audit_update_watch(): switch to const struct qstr *
    inotify_handle_event(): don't bother with strlen()
    fsnotify: switch send_to_group() and ->handle_event to const struct qstr *
    fsnotify(): switch to passing const struct qstr * for file_name
    switch fsnotify_move() to passing const struct qstr * for old_name
    ovl_lookup_real_one(): don't bother with strlen()
    sysv: bury the broken "quietly truncate the long filenames" logics
    nsfs: unobfuscate
    unexport d_alloc_pseudo()

    Linus Torvalds
     

06 May, 2019

4 commits

  • We found that it return success when we set IMMUTABLE_FL flag to a file in
    docker even though the docker didn't have the capability
    CAP_LINUX_IMMUTABLE.

    The commit d1d04ef8572b ("ovl: stack file ops") and dab5ca8fd9dd ("ovl: add
    lsattr/chattr support") implemented chattr operations on a regular overlay
    file. ovl_real_ioctl() overridden the current process's subjective
    credentials with ofs->creator_cred which have the capability
    CAP_LINUX_IMMUTABLE so that it will return success in
    vfs_ioctl()->cap_capable().

    Fix this by checking the capability before cred overridden. And here we
    only care about APPEND_FL and IMMUTABLE_FL, so get these information from
    inode.

    [SzM: move check and call to underlying fs inside inode locked region to
    prevent two such calls from racing with each other]

    Signed-off-by: Jiufei Xue
    Signed-off-by: Miklos Szeredi

    Jiufei Xue
     
  • Overlayfs "fake" path is used for stacked file operations on underlying
    files. Operations on files with "fake" path must not generate fsnotify
    events with path data, because those events have already been generated at
    overlayfs layer and because the reported event->fd for fanotify marks on
    underlying inode/filesystem will have the wrong path (the overlayfs path).

    Link: https://lore.kernel.org/linux-fsdevel/20190423065024.12695-1-jencce.kernel@gmail.com/
    Reported-by: Murphy Zhou
    Fixes: d1d04ef8572b ("ovl: stack file ops")
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • Overlay file f_pos is the master copy that is preserved
    through copy up and modified on read/write, but only real
    fs knows how to SEEK_HOLE/SEEK_DATA and real fs may impose
    limitations that are more strict than ->s_maxbytes for specific
    files, so we use the real file to perform seeks.

    We do not call real fs for SEEK_CUR:0 query and for SEEK_SET:0
    requests.

    Fixes: d1d04ef8572b ("ovl: stack file ops")
    Reported-by: Eddie Horng
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • Generalize the helper ovl_open_maybe_copy_up() and use it to copy up file
    with data before FS_IOC_SETFLAGS ioctl.

    The FS_IOC_SETFLAGS ioctl is a bit of an odd ball in vfs, which probably
    caused the confusion. File may be open O_RDONLY, but ioctl modifies the
    file. VFS does not call mnt_want_write_file() nor lock inode mutex, but
    fs-specific code for FS_IOC_SETFLAGS does. So ovl_ioctl() calls
    mnt_want_write_file() for the overlay file, and fs-specific code calls
    mnt_want_write_file() for upper fs file, but there was no call for
    ovl_want_write() for copy up duration which prevents overlayfs from copying
    up on a frozen upper fs.

    Fixes: dab5ca8fd9dd ("ovl: add lsattr/chattr support")
    Cc: # v4.19
    Signed-off-by: Amir Goldstein
    Acked-by: Vivek Goyal
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     

02 May, 2019

1 commit


27 Apr, 2019

1 commit


13 Feb, 2019

1 commit

  • If a file has been copied up metadata only, and later data is copied up,
    upper loses any security.capability xattr it has (underlying filesystem
    clears it as upon file write).

    From a user's point of view, this is just a file copy-up and that should
    not result in losing security.capability xattr. Hence, before data copy
    up, save security.capability xattr (if any) and restore it on upper after
    data copy up is complete.

    Signed-off-by: Vivek Goyal
    Reviewed-by: Amir Goldstein
    Fixes: 0c2888749363 ("ovl: A new xattr OVL_XATTR_METACOPY for file on upper")
    Cc: # v4.19+
    Signed-off-by: Miklos Szeredi

    Vivek Goyal
     

04 Feb, 2019

1 commit

  • If a file with capability set (and hence security.capability xattr) is
    written kernel clears security.capability xattr. For overlay, during file
    copy up if xattrs are copied up first and then data is, copied up. This
    means data copy up will result in clearing of security.capability xattr
    file on lower has. And this can result into surprises. If a lower file has
    CAP_SETUID, then it should not be cleared over copy up (if nothing was
    actually written to file).

    This also creates problems with chown logic where it first copies up file
    and then tries to clear setuid bit. But by that time security.capability
    xattr is already gone (due to data copy up), and caller gets -ENODATA.
    This has been reported by Giuseppe here.

    https://github.com/containers/libpod/issues/2015#issuecomment-447824842

    Fix this by copying up data first and then metadta. This is a regression
    which has been introduced by my commit as part of metadata only copy up
    patches.

    TODO: There will be some corner cases where a file is copied up metadata
    only and later data copy up happens and that will clear security.capability
    xattr. Something needs to be done about that too.

    Fixes: bd64e57586d3 ("ovl: During copy up, first copy up metadata and then data")
    Cc: # v4.19+
    Reported-by: Giuseppe Scrivano
    Signed-off-by: Vivek Goyal
    Signed-off-by: Miklos Szeredi

    Vivek Goyal
     

04 Dec, 2018

1 commit

  • This reverts commit 007ea44892e6fa963a0876a979e34890325c64eb.

    The commit broke some selinux-testsuite cases, and it looks like there's no
    straightforward fix keeping the direction of this patch, so revert for now.

    The original patch was trying to fix the consistency of permission checks, and
    not an observed bug. So reverting should be safe.

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     

21 Nov, 2018

1 commit

  • When decoding a lower file handle, we first call ovl_check_origin_fh()
    with connected=false to get any real lower dentry for overlay inode
    cache lookup.

    If the real dentry is a disconnected dir dentry, ovl_check_origin_fh()
    is called again with connected=true to get a connected real dentry
    and find the lower layer the real dentry belongs to.

    If the first call returned a connected real dentry, we use it to
    lookup an overlay connected dentry, but the first ovl_check_origin_fh()
    call with connected=false did not check that the found dentry is under
    the root of the layer (see ovl_acceptable()), it only checked that
    the found dentry super block matches the uuid of the lower file handle.

    In case there are multiple lower layers on the same fs and the found
    dentry is not from the top most lower layer, using the layer index
    returned from the first ovl_check_origin_fh() is wrong and we end
    up failing to decode the file handle.

    Fix this by always calling ovl_check_origin_fh() with connected=true
    if we got a directory dentry in the first call.

    Fixes: 8b58924ad55c ("ovl: lookup in inode cache first when decoding...")
    Cc: # v4.17
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     

19 Nov, 2018

1 commit

  • Theodore Ts'o reported a v4.19 regression with docker-dropbox:
    https://marc.info/?l=linux-fsdevel&m=154070089431116&w=2

    "I was rebuilding my dropbox Docker container, and it failed in 4.19
    with the following error:
    ...
    dpkg: error: error creating new backup file \
    '/var/lib/dpkg/status-old': Invalid cross-device link"

    The problem did not reproduce with metacopy feature disabled.
    The error was caused by insufficient credentials to set
    "trusted.overlay.redirect" xattr on link of a metacopy file.

    Reproducer:

    echo Y > /sys/module/overlay/parameters/redirect_dir
    echo Y > /sys/module/overlay/parameters/metacopy
    cd /tmp
    mkdir l u w m
    chmod 777 l u
    touch l/foo
    ln l/foo l/link
    chmod 666 l/foo
    mount -t overlay none -olowerdir=l,upperdir=u,workdir=w m
    su fsgqa
    ln m/foo m/bar
    [ 21.455823] overlayfs: failed to set redirect (-1)
    ln: failed to create hard link 'm/bar' => 'm/foo':\
    Invalid cross-device link

    Reported-by: Theodore Y. Ts'o
    Reported-by: Maciej Zięba
    Fixes: 4120fe64dce4 ("ovl: Set redirect on upper inode when it is linked")
    Cc: # v4.19
    Signed-off-by: Amir Goldstein
    Acked-by: Vivek Goyal
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     

03 Nov, 2018

1 commit

  • Pull vfs dedup fixes from Dave Chinner:
    "This reworks the vfs data cloning infrastructure.

    We discovered many issues with these interfaces late in the 4.19 cycle
    - the worst of them (data corruption, setuid stripping) were fixed for
    XFS in 4.19-rc8, but a larger rework of the infrastructure fixing all
    the problems was needed. That rework is the contents of this pull
    request.

    Rework the vfs_clone_file_range and vfs_dedupe_file_range
    infrastructure to use a common .remap_file_range method and supply
    generic bounds and sanity checking functions that are shared with the
    data write path. The current VFS infrastructure has problems with
    rlimit, LFS file sizes, file time stamps, maximum filesystem file
    sizes, stripping setuid bits, etc and so they are addressed in these
    commits.

    We also introduce the ability for the ->remap_file_range methods to
    return short clones so that clones for vfs_copy_file_range() don't get
    rejected if the entire range can't be cloned. It also allows
    filesystems to sliently skip deduplication of partial EOF blocks if
    they are not capable of doing so without requiring errors to be thrown
    to userspace.

    Existing filesystems are converted to user the new remap_file_range
    method, and both XFS and ocfs2 are modified to make use of the new
    generic checking infrastructure"

    * tag 'xfs-4.20-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (28 commits)
    xfs: remove [cm]time update from reflink calls
    xfs: remove xfs_reflink_remap_range
    xfs: remove redundant remap partial EOF block checks
    xfs: support returning partial reflink results
    xfs: clean up xfs_reflink_remap_blocks call site
    xfs: fix pagecache truncation prior to reflink
    ocfs2: remove ocfs2_reflink_remap_range
    ocfs2: support partial clone range and dedupe range
    ocfs2: fix pagecache truncation prior to reflink
    ocfs2: truncate page cache for clone destination file before remapping
    vfs: clean up generic_remap_file_range_prep return value
    vfs: hide file range comparison function
    vfs: enable remap callers that can handle short operations
    vfs: plumb remap flags through the vfs dedupe functions
    vfs: plumb remap flags through the vfs clone functions
    vfs: make remap_file_range functions take and return bytes completed
    vfs: remap helper should update destination inode metadata
    vfs: pass remap flags to generic_remap_checks
    vfs: pass remap flags to generic_remap_file_range_prep
    vfs: combine the clone and dedupe into a single remap_file_range
    ...

    Linus Torvalds
     

02 Nov, 2018

1 commit

  • Current behavior is to automatically disable metacopy if redirect_dir is
    not enabled and proceed with the mount.

    If "metacopy=on" mount option was given, then this behavior can confuse the
    user: no mount failure, yet metacopy is disabled.

    This patch makes metacopy=on imply redirect_dir=on.

    The converse is also true: turning off full redirect with redirect_dir=
    {off|follow|nofollow} will disable metacopy.

    If both metacopy=on and redirect_dir={off|follow|nofollow} is specified,
    then mount will fail, since there's no way to correctly resolve the
    conflict.

    Reported-by: Daniel Walsh
    Fixes: d5791044d2e5 ("ovl: Provide a mount option metacopy=on/off...")
    Cc: # v4.19
    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     

31 Oct, 2018

1 commit

  • Kaixuxia repors that it's possible to crash overlayfs by removing the
    whiteout on the upper layer before creating a directory over it. This is a
    reproducer:

    mkdir lower upper work merge
    touch lower/file
    mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merge
    rm merge/file
    ls -al merge/file
    rm upper/file
    ls -al merge/
    mkdir merge/file

    Before commencing with a vfs_rename(..., RENAME_EXCHANGE) verify that the
    lookup of "upper" is positive and is a whiteout, and return ESTALE
    otherwise.

    Reported by: kaixuxia
    Signed-off-by: Miklos Szeredi
    Fixes: e9be9d5e76e3 ("overlay filesystem")
    Cc: # v3.18

    Miklos Szeredi
     

30 Oct, 2018

4 commits

  • Plumb a remap_flags argument through the vfs_dedupe_file_range_one
    functions so that dedupe can take advantage of it.

    Signed-off-by: Darrick J. Wong
    Reviewed-by: Amir Goldstein
    Signed-off-by: Dave Chinner

    Darrick J. Wong
     
  • Plumb a remap_flags argument through the {do,vfs}_clone_file_range
    functions so that clone can take advantage of it.

    Signed-off-by: Darrick J. Wong
    Reviewed-by: Amir Goldstein
    Signed-off-by: Dave Chinner

    Darrick J. Wong
     
  • Change the remap_file_range functions to take a number of bytes to
    operate upon and return the number of bytes they operated on. This is a
    requirement for allowing fs implementations to return short clone/dedupe
    results to the user, which will enable us to obey resource limits in a
    graceful manner.

    A subsequent patch will enable copy_file_range to signal to the
    ->clone_file_range implementation that it can handle a short length,
    which will be returned in the function's return value. For now the
    short return is not implemented anywhere so the behavior won't change --
    either copy_file_range manages to clone the entire range or it tries an
    alternative.

    Neither clone ioctl can take advantage of this, alas.

    Signed-off-by: Darrick J. Wong
    Reviewed-by: Amir Goldstein
    Signed-off-by: Dave Chinner

    Darrick J. Wong
     
  • Combine the clone_file_range and dedupe_file_range operations into a
    single remap_file_range file operation dispatch since they're
    fundamentally the same operation. The differences between the two can
    be made in the prep functions.

    Signed-off-by: Darrick J. Wong
    Reviewed-by: Amir Goldstein
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Dave Chinner

    Darrick J. Wong
     

27 Oct, 2018

10 commits

  • There is no functional change but it seems better to get size by calling
    posix_acl_xattr_size() instead of calling posix_acl_to_xattr() with
    NULL buffer argument. Additionally, remove unnecessary assignments.

    Signed-off-by: Chengguang Xu
    Signed-off-by: Miklos Szeredi

    Chengguang Xu
     
  • The abstraction improves code readabilty (to some).

    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • It just makes the interface strange without adding any significant value.
    The only case where locked is false and return value is 0 is in
    ovl_rename() when new is negative, so handle that case explicitly in
    ovl_rename().

    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • We use uuid to associate an overlay lower file handle with a lower layer,
    so we can accept lower fs with null uuid as long as all lower layers with
    null uuid are on the same fs.

    This change allows enabling index and nfs_export features for the setup of
    single lower fs of type squashfs - squashfs supports file handles, but has
    a null uuid. This change also allows enabling index and nfs_export features
    for nested overlayfs, where the lower overlay has nfs_export enabled.

    Enabling the index feature with single lower squashfs fixes the
    unionmount-testsuite test:
    ./run --ov --squashfs --verify

    As a by-product, if, like the lower squashfs, upper fs also uses the
    generic export_encode_fh() implementation to export 32bit inode file
    handles (e.g. ext4), then the xino_auto config/module/mount option will
    enable unique overlay inode numbers.

    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • Now that the workdir and tmpfile copy up modes have been untagled, the
    functions become simple enough that the helpers can be folded into the
    callers.

    Add new helpers where there is any duplication remaining: preparing creds
    for creating the object.

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • In an attempt to dedup ~100 LOC, we ended up creating a tangled call chain,
    whose branches merge and diverge in several points according to the
    immutable c->tmpfile copy up mode.

    This call chain was hard to analyse for locking correctness because the
    locking requirements for the c->tmpfile flow were very different from the
    locking requirements for the !c->tmpfile flow (i.e. directory vs. regulare
    file copy up).

    Split the copy up helpers of the c->tmpfile flow from those of the
    !c->tmpfile (i.e. workdir) flow and remove the c->tmpfile mode from copy up
    context.

    Suggested-by: Al Viro
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • Make permission checking more consistent:

    - special files don't need any access check on underling fs

    - exec permission check doesn't need to be performed on underlying fs

    Reported-by: "J. Bruce Fields"
    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • linking a non-copied-up file into a non-copied-up parent results in a
    nested call to mutex_lock_interruptible(&oi->lock). Fix this by copying up
    target parent before ovl_nlink_start(), same as done in ovl_rename().

    ~/unionmount-testsuite$ ./run --ov -s
    ~/unionmount-testsuite$ ln /mnt/a/foo100 /mnt/a/dir100/

    WARNING: possible recursive locking detected
    --------------------------------------------
    ln/1545 is trying to acquire lock:
    00000000bcce7c4c (&ovl_i_lock_key[depth]){+.+.}, at:
    ovl_copy_up_start+0x28/0x7d
    but task is already holding lock:
    0000000026d73d5b (&ovl_i_lock_key[depth]){+.+.}, at:
    ovl_nlink_start+0x3c/0xc1

    [SzM: this seems to be a false positive, but doing the copy-up first is
    harmless and removes the lockdep splat]

    Reported-by: syzbot+3ef5c0d1a5cb0b21e6be@syzkaller.appspotmail.com
    Fixes: 5f8415d6b87e ("ovl: persistent overlay inode nlink for...")
    Cc: # v4.13
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • If security_inode_copy_up() fails, it should not set new_creds, so no need
    for the cleanup (which would've Oops-ed anyway, due to old_creds being
    NULL).

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • We hit a BUG on kfree of an ERR_PTR()...

    Reported-by: syzbot+ff03fe05c717b82502d0@syzkaller.appspotmail.com
    Fixes: 8b88a2e64036 ("ovl: verify upper root dir matches lower root dir")
    Cc: # v4.13
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     

04 Oct, 2018

2 commits

  • Format has a typo: it was meant to be "%.*s", not "%*s". But at some point
    callers grew nonprintable values as well, so use "%*pE" instead with a
    maximized length.

    Reported-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi
    Fixes: 3a1e819b4e80 ("ovl: store file handle of lower inode on copy up")
    Cc: # v4.12

    Miklos Szeredi
     
  • KASAN detected slab-out-of-bounds access in printk from overlayfs,
    because string format used %*s instead of %.*s.

    > BUG: KASAN: slab-out-of-bounds in string+0x298/0x2d0 lib/vsprintf.c:604
    > Read of size 1 at addr ffff8801c36c66ba by task syz-executor2/27811
    >
    > CPU: 0 PID: 27811 Comm: syz-executor2 Not tainted 4.19.0-rc5+ #36
    ...
    > printk+0xa7/0xcf kernel/printk/printk.c:1996
    > ovl_lookup_index.cold.15+0xe8/0x1f8 fs/overlayfs/namei.c:689

    Reported-by: syzbot+376cea2b0ef340db3dd4@syzkaller.appspotmail.com
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi
    Fixes: 359f392ca53e ("ovl: lookup index entry for copy up origin")
    Cc: # v4.13

    Amir Goldstein
     

26 Sep, 2018

1 commit

  • Fixes the following sparse warning:

    fs/overlayfs/inode.c:507:39: warning:
    symbol 'ovl_aops' was not declared. Should it be static?

    Fixes: 5b910bd615ba ("ovl: fix GPF in swapfile_activate of file from overlayfs over xfs")
    Signed-off-by: Wei Yongjun
    Signed-off-by: Miklos Szeredi

    Wei Yongjun
     

24 Sep, 2018

4 commits

  • Commit 031a072a0b8a ("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 8ede205541ff ("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: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    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: 8ede205541ff ("ovl: add reflink/copyfile/dedup support")
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    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: 2a92e07edc5e ("ovl: add ovl_write_iter()")
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     
  • The memory leak was detected by kmemleak when running xfstests
    overlay/051,053

    Fixes: caf70cb2ba5d ("ovl: cleanup orphan index entries")
    Cc: # v4.13
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein
     

10 Sep, 2018

1 commit

  • ovl_free_fs() dereferences ofs->workbasedir and ofs->upper_mnt in cases when
    those might not have been initialized yet.

    Fix the initialization order for these fields.

    Reported-by: syzbot+c75f181dc8429d2eb887@syzkaller.appspotmail.com
    Signed-off-by: Miklos Szeredi
    Cc: # v4.15
    Fixes: 95e6d4177cb7 ("ovl: grab reference to workbasedir early")
    Fixes: a9075cdb467d ("ovl: factor out ovl_free_fs() helper")

    Miklos Szeredi
     

03 Sep, 2018

1 commit

  • Implement stacked fadvise to fix syscalls readahead(2) and fadvise64(2)
    on an overlayfs file.

    Suggested-by: Miklos Szeredi
    Fixes: d1d04ef8572b ("ovl: stack file ops")
    Signed-off-by: Amir Goldstein
    Signed-off-by: Miklos Szeredi

    Amir Goldstein