* [PATCH] ovl: fix decode of dir file handle with multi lower layers
@ 2018-11-05 5:50 Amir Goldstein
2018-11-22 14:45 ` Miklos Szeredi
0 siblings, 1 reply; 4+ messages in thread
From: Amir Goldstein @ 2018-11-05 5:50 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: linux-unionfs
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: <stable@vger.kernel.org> # v4.17
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/export.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index 8fa37cd7818a..54e5d17d7f3e 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -754,9 +754,8 @@ static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
goto out;
}
- /* Otherwise, get a connected non-upper dir or disconnected non-dir */
- if (d_is_dir(origin.dentry) &&
- (origin.dentry->d_flags & DCACHE_DISCONNECTED)) {
+ /* Find origin.dentry again with ovl_acceptable() layer check */
+ if (d_is_dir(origin.dentry)) {
dput(origin.dentry);
origin.dentry = NULL;
err = ovl_check_origin_fh(ofs, fh, true, NULL, &stack);
@@ -769,6 +768,7 @@ static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
goto out_err;
}
+ /* Get a connected non-upper dir or disconnected non-dir */
dentry = ovl_get_dentry(sb, NULL, &origin, index);
out:
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ovl: fix decode of dir file handle with multi lower layers
2018-11-05 5:50 [PATCH] ovl: fix decode of dir file handle with multi lower layers Amir Goldstein
@ 2018-11-22 14:45 ` Miklos Szeredi
2018-11-22 14:50 ` Amir Goldstein
0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2018-11-22 14:45 UTC (permalink / raw)
To: Amir Goldstein; +Cc: overlayfs
On Mon, Nov 5, 2018 at 6:50 AM Amir Goldstein <amir73il@gmail.com> wrote:
>
> 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.
Hi Amir,
Does this have a testcase?
Thanks,
Miklos
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ovl: fix decode of dir file handle with multi lower layers
2018-11-22 14:45 ` Miklos Szeredi
@ 2018-11-22 14:50 ` Amir Goldstein
2018-11-22 15:32 ` Miklos Szeredi
0 siblings, 1 reply; 4+ messages in thread
From: Amir Goldstein @ 2018-11-22 14:50 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: overlayfs
On Thu, Nov 22, 2018 at 4:45 PM Miklos Szeredi <miklos@szeredi.hu> wrote:
>
> On Mon, Nov 5, 2018 at 6:50 AM Amir Goldstein <amir73il@gmail.com> wrote:
> >
> > 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.
>
> Hi Amir,
>
> Does this have a testcase?
>
xfstest overlay/062
already upstream.
Thanks,
Amir.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ovl: fix decode of dir file handle with multi lower layers
2018-11-22 14:50 ` Amir Goldstein
@ 2018-11-22 15:32 ` Miklos Szeredi
0 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2018-11-22 15:32 UTC (permalink / raw)
To: Amir Goldstein; +Cc: overlayfs
On Thu, Nov 22, 2018 at 3:50 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Thu, Nov 22, 2018 at 4:45 PM Miklos Szeredi <miklos@szeredi.hu> wrote:
> >
> > On Mon, Nov 5, 2018 at 6:50 AM Amir Goldstein <amir73il@gmail.com> wrote:
> > >
> > > 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.
> >
> > Hi Amir,
> >
> > Does this have a testcase?
> >
>
> xfstest overlay/062
> already upstream.
Good.
Thanks,
Miklos
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-11-23 1:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-05 5:50 [PATCH] ovl: fix decode of dir file handle with multi lower layers Amir Goldstein
2018-11-22 14:45 ` Miklos Szeredi
2018-11-22 14:50 ` Amir Goldstein
2018-11-22 15:32 ` Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox