Patch "ovl: redirect_dir=nofollow should not follow redirect for opaque lower" has been added to the 4.15-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
ovl: redirect_dir=nofollow should not follow redirect for opaque lower
to the 4.15-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ovl-redirect_dir-nofollow-should-not-follow-redirect-for-opaque-lower.patch
and it can be found in the queue-4.15 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
d1fe96c0e4de78ba0cd336ea3df3b850d06b9b9aMon Sep 17 00:00:00 2001
From: Vivek Goyal <[email protected]>
Date: Fri, 2 Feb 2018 10:23:24 -0500
Subject: ovl: redirect_dir=nofollow should not follow redirect for opaque lower
From: Vivek Goyal <[email protected]>
commit d1fe96c0e4de78ba0cd336ea3df3b850d06b9b9a upstream.
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.
--- fs/overlayfs/namei.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/overlayfs/namei.c +3 -3
@@ -678,9 +678,6 @@ struct dentry *ovl_lookup(struct inode * stack[ctr].layer = lower.layer; ctr++; -if (d.stop) -break ; -/* * Following redirects can have security consequences: it's like * a symlink into the lower layer without the permission checks.
@@ -697,6 +694,9 @@ struct dentry *ovl_lookup(struct inode * goto out_put; } +if (d.stop) +break ; +if (d.redirect && d.redirect[0 ] =='/' && poe != roe) { poe = roe;
Patches currently in stable-queue which might be from [email protected] are
queue-4.15/ovl-redirect_dir-nofollow-should-not-follow-redirect-for-opaque-lower.patch