public inbox for linux-unionfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ovl: fix lookup with middle layer opaque dir and absolute path redirects
@ 2018-03-08 21:31 Amir Goldstein
  2018-03-08 22:17 ` Vivek Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Amir Goldstein @ 2018-03-08 21:31 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Vivek Goyal, linux-unionfs

The only way to explain the problem is with an example.
Watch me make foo disappear:

 $ mkdir lower middle upper work work2 merged
 $ mkdir lower/origin
 $ touch lower/origin/foo
 $ mount -t overlay none merged/ \
         -olowerdir=lower,upperdir=middle,workdir=work2
 $ mkdir merged/pure
 $ mv merged/origin merged/pure/redirect
 $ umount merged
 $ mount -t overlay none merged/ \
         -olowerdir=middle:lower,upperdir=upper,workdir=work
 $ mv merged/pure/redirect merged/redirect

Now you see foo inside a twice redirected merged dir:

 $ ls merged/redirect
 foo
 $ umount merged
 $ mount -t overlay none merged/ \
         -olowerdir=middle:lower,upperdir=upper,workdir=work

After mount cycle you don't see foo inside the same dir:

 $ ls merged/redirect

During middle layer lookup, the opaqueness of middle/pure is left in
the lookup state and then middle/pure/redirect is wrongly treated as
opaque.

Fixes: 02b69b284cd7 ("ovl: lookup redirects")
Cc: <stable@vger.kernel.org> #v4.10
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Vivek,

This is the bug I was talking about in review of metacopy lookup.

Miklos,

This change seems a bit subtle... besides the reproducer I sanity tested
redirects with unionmount-testsuite ./run --ov=10 and the overlay/quick
xfstests. Neither would have hit this sort of corner case though.
I will add a test to cover this case later on.

Thanks,
Amir.

 fs/overlayfs/namei.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 70fcfcc684cc..31ca563b7666 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -51,6 +51,14 @@ static int ovl_check_redirect(struct dentry *dentry, struct ovl_lookup_data *d,
 	if (res == 0)
 		goto invalid;
 	if (buf[0] == '/') {
+		/*
+		 * One of the ancestor path elements in an absolute path
+		 * lookup in ovl_lookup_layer() could have been opaque, but it
+		 * possible for a decendant path element to reset opaqueness in
+		 * case this path element has an absolute redirect to a lower
+		 * layer.
+		 */
+		d->stop = d->opaque = false;
 		for (s = buf; *s++ == '/'; s = next) {
 			next = strchrnul(s, '/');
 			if (s == next)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-08 22:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-08 21:31 [PATCH] ovl: fix lookup with middle layer opaque dir and absolute path redirects Amir Goldstein
2018-03-08 22:17 ` Vivek Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox