1
0
Fork 0
alistair23-linux/fs/overlayfs
Miklos Szeredi c4fcfc1619 ovl: fix d_real() for stacked fs
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: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 2d902671ce ("vfs: merge .d_select_inode() into .d_real()")
Cc: <stable@vger.kernel.org> # v4.8+
2016-11-29 10:20:24 +01:00
..
Kconfig ovl: rename filesystem type to "overlay" 2014-11-20 16:39:59 +01:00
Makefile ovl: rename filesystem type to "overlay" 2014-11-20 16:39:59 +01:00
copy_up.c ovl: fsync after copy-up 2016-10-31 14:42:14 +01:00
dir.c Merge branch 'overlayfs-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs 2016-10-14 17:23:33 -07:00
inode.c ovl: fix get_acl() on tmpfs 2016-10-31 14:42:14 +01:00
overlayfs.h fs: rename "rename2" i_op to "rename" 2016-09-27 11:03:58 +02:00
readdir.c ovl: proper cleanup of workdir 2016-09-01 11:11:59 +02:00
super.c ovl: fix d_real() for stacked fs 2016-11-29 10:20:24 +01:00