linux_dsm_epyc7002/fs/overlayfs
Vivek Goyal d1fe96c0e4 ovl: redirect_dir=nofollow should not follow redirect for opaque lower
redirect_dir=nofollow should not follow a redirect. But in a specific
configuration it can still follow it.  For example try this.

$ mkdir -p lower0 lower1/foo upper work merged
$ touch lower1/foo/lower-file.txt
$ setfattr -n "trusted.overlay.opaque" -v "y" lower1/foo
$ mount -t overlay -o lowerdir=lower1:lower0,workdir=work,upperdir=upper,redirect_dir=on none merged
$ cd merged
$ mv foo foo-renamed
$ umount merged

# mount again. This time with redirect_dir=nofollow
$ mount -t overlay -o lowerdir=lower1:lower0,workdir=work,upperdir=upper,redirect_dir=nofollow none merged
$ ls merged/foo-renamed/
# This lists lower-file.txt, while it should not have.

Basically, we are doing redirect check after we check for d.stop. And
if this is not last lower, and we find an opaque lower, d.stop will be
set.

ovl_lookup_single()
        if (!d->last && ovl_is_opaquedir(this)) {
                d->stop = d->opaque = true;
                goto out;
        }

To fix this, first check redirect is allowed. And after that check if
d.stop has been set or not.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Fixes: 438c84c2f0 ("ovl: don't follow redirects if redirect_dir=off")
Cc: <stable@vger.kernel.org> #v4.15
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-02-26 16:55:51 +01:00
..
copy_up.c ovl: copy up of disconnected dentries 2018-01-24 11:25:58 +01:00
dir.c ovl: whiteout index when union nlink drops to zero 2018-01-24 11:25:56 +01:00
export.c ovl: fix ptr_ret.cocci warnings 2018-02-26 12:45:20 +01:00
inode.c ovl: hash non-dir by lower inode for fsnotify 2018-02-16 15:53:20 +01:00
Kconfig ovl: add support for "nfs_export" configuration 2018-01-24 11:25:37 +01:00
Makefile ovl: encode pure upper file handles 2018-01-24 11:25:59 +01:00
namei.c ovl: redirect_dir=nofollow should not follow redirect for opaque lower 2018-02-26 16:55:51 +01:00
overlayfs.h ovl: check lower ancestry on encode of lower dir file handle 2018-02-16 15:53:20 +01:00
ovl_entry.h ovl: store 'has_upper' and 'opaque' as bit flags 2018-01-24 11:25:58 +01:00
readdir.c ovl: whiteout orphan index entries on mount 2018-01-24 11:25:56 +01:00
super.c ovl: check lower ancestry on encode of lower dir file handle 2018-02-16 15:53:20 +01:00
util.c ovl: store 'has_upper' and 'opaque' as bit flags 2018-01-24 11:25:58 +01:00