Commit ea3dad18 authored by Amir Goldstein's avatar Amir Goldstein Committed by Miklos Szeredi

ovl: mark parent impure on ovl_link()

When linking a file with copy up origin into a new parent, mark the
new parent dir "impure".

Fixes: ee1d6d37 ("ovl: mark upper dir with type origin entries "impure"")
Cc: <stable@vger.kernel.org> # v4.12
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 8fc646b4
......@@ -481,17 +481,30 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
}
static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
struct cattr *attr, struct dentry *hardlink)
struct cattr *attr, struct dentry *hardlink,
bool origin)
{
int err;
const struct cred *old_cred;
struct cred *override_cred;
struct dentry *parent = dentry->d_parent;
err = ovl_copy_up(dentry->d_parent);
err = ovl_copy_up(parent);
if (err)
return err;
old_cred = ovl_override_creds(dentry->d_sb);
/*
* When linking a file with copy up origin into a new parent, mark the
* new parent dir "impure".
*/
if (origin) {
err = ovl_set_impure(parent, ovl_dentry_upper(parent));
if (err)
goto out_revert_creds;
}
err = -ENOMEM;
override_cred = prepare_creds();
if (override_cred) {
......@@ -550,7 +563,7 @@ static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev,
inode_init_owner(inode, dentry->d_parent->d_inode, mode);
attr.mode = inode->i_mode;
err = ovl_create_or_link(dentry, inode, &attr, NULL);
err = ovl_create_or_link(dentry, inode, &attr, NULL, false);
if (err)
iput(inode);
......@@ -609,7 +622,8 @@ static int ovl_link(struct dentry *old, struct inode *newdir,
inode = d_inode(old);
ihold(inode);
err = ovl_create_or_link(new, inode, NULL, ovl_dentry_upper(old));
err = ovl_create_or_link(new, inode, NULL, ovl_dentry_upper(old),
ovl_type_origin(old));
if (err)
iput(inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment