diff options
author | Amir Goldstein <amir73il@gmail.com> | 2017-06-21 14:28:38 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-07-04 22:03:17 +0200 |
commit | 54fb347e836faadaed2a5617fb4dd4a4597d0490 (patch) | |
tree | 776d77e3848edf181ebeeda5bea8169c8937c6bc /fs/overlayfs/super.c | |
parent | ovl: verify upper root dir matches lower root dir (diff) | |
download | linux-54fb347e836faadaed2a5617fb4dd4a4597d0490.tar.xz linux-54fb347e836faadaed2a5617fb4dd4a4597d0490.zip |
ovl: verify index dir matches upper dir
An index dir contains persistent hardlinks to files in upper dir.
Therefore, we must never mount an existing index dir with a differnt
upper dir.
Store the upper root dir file handle in index dir inode when index
dir is created and verify the file handle before using an existing
index dir on mount.
Add an 'is_upper' flag to the overlay file handle encoding and set it
when encoding the upper root file handle. This is not critical for index
dir verification, but it is good practice towards a standard overlayfs
file handle format for NFS export.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to '')
-rw-r--r-- | fs/overlayfs/super.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index bfdcff0f3168..a313af25dac2 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1050,7 +1050,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) if (!(ovl_force_readonly(ufs)) && ufs->config.index) { /* Verify lower root is upper root origin */ err = ovl_verify_origin(upperpath.dentry, ufs->lower_mnt[0], - stack[0].dentry, true); + stack[0].dentry, false, true); if (err) { pr_err("overlayfs: failed to verify upper root origin\n"); goto out_put_lower_mnt; @@ -1062,8 +1062,17 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) if (IS_ERR(ufs->indexdir)) goto out_put_lower_mnt; - if (!ufs->indexdir) + if (ufs->indexdir) { + /* Verify upper root is index dir origin */ + err = ovl_verify_origin(ufs->indexdir, ufs->upper_mnt, + upperpath.dentry, true, true); + if (err) + pr_err("overlayfs: failed to verify index dir origin\n"); + } + if (err || !ufs->indexdir) pr_warn("overlayfs: try deleting index dir or mounting with '-o index=off' to disable inodes index.\n"); + if (err) + goto out_put_indexdir; } /* Show index=off/on in /proc/mounts for any of the reasons above */ |