diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2018-05-11 18:49:28 +0300 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-07-20 10:56:09 +0300 |
commit | 9d3dfea3d35a3235f0f1e2ce719bb4f0b696caa2 (patch) | |
tree | 56966008a8fdbf3bd44f27d4e6008a6ff1dd8e33 /fs/overlayfs/inode.c | |
parent | 027065b726434d2a95a5cc516129be765e27ecf8 (diff) | |
download | linux-9d3dfea3d35a3235f0f1e2ce719bb4f0b696caa2.tar.xz |
ovl: Modify ovl_lookup() and friends to lookup metacopy dentry
This patch modifies ovl_lookup() and friends to lookup metacopy dentries.
It also allows for presence of metacopy dentries in lower layer.
During lookup, check for presence of OVL_XATTR_METACOPY and if not present,
set OVL_UPPERDATA bit in flags.
We don't support metacopy feature with nfs_export. So in nfs_export code,
we set OVL_UPPERDATA flag set unconditionally if upper inode exists.
Do not follow metacopy origin if we find a metacopy only inode and metacopy
feature is not enabled for that mount. Like redirect, this can have
security implications where an attacker could hand craft upper and try to
gain access to file on lower which it should not have to begin with.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/inode.c')
-rw-r--r-- | fs/overlayfs/inode.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index e46f26ee6e21..d3e65d2a1b83 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -780,7 +780,7 @@ struct inode *ovl_get_inode(struct super_block *sb, bool bylower = ovl_hash_bylower(sb, upperdentry, lowerdentry, oip->index); int fsid = bylower ? oip->lowerpath->layer->fsid : 0; - bool is_dir; + bool is_dir, metacopy = false; unsigned long ino = 0; int err = -ENOMEM; @@ -839,6 +839,15 @@ struct inode *ovl_get_inode(struct super_block *sb, if (oip->index) ovl_set_flag(OVL_INDEX, inode); + if (upperdentry) { + err = ovl_check_metacopy_xattr(upperdentry); + if (err < 0) + goto out_err; + metacopy = err; + if (!metacopy) + ovl_set_flag(OVL_UPPERDATA, inode); + } + OVL_I(inode)->redirect = oip->redirect; /* Check for non-merge dir that may have whiteouts */ |