From 2c3d73589adc6d3450890a6f793e5e8a1ae894e0 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Fri, 11 May 2018 11:49:31 -0400 Subject: [PATCH] ovl: Do not expose metacopy only dentry from d_real() Metacopy dentry/inode is internal to overlay and is never exposed outside of it. Exception is metacopy upper file used for fsync(). Modify d_real() to look for dentries/inode which have data, but also allow matching upper inode without data for the fsync case. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/super.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 6d22bbd5f27f..2e0fc93c2c06 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -95,10 +95,13 @@ static struct dentry *ovl_d_real(struct dentry *dentry, } real = ovl_dentry_upper(dentry); - if (real && (!inode || inode == d_inode(real))) + if (real && (inode == d_inode(real))) return real; - real = ovl_dentry_lower(dentry); + if (real && !inode && ovl_has_upperdata(d_inode(dentry))) + return real; + + real = ovl_dentry_lowerdata(dentry); if (!real) goto bug;