diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2017-07-04 22:03:16 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-07-04 22:03:16 +0200 |
commit | 9020df37207867272e590a416c2fb3da0e5383c6 (patch) | |
tree | 03739a777b0bc549b11c9a6a8d41aabbbc7ea909 /fs/overlayfs/dir.c | |
parent | 25b7713afe50963e70f98c1c964f60baf1e7e373 (diff) |
ovl: compare inodes
When checking for consistency in directory operations (unlink, rename,
etc.) match inodes not dentries.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/dir.c')
-rw-r--r-- | fs/overlayfs/dir.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index fcfa7de12ad5..59e0dc9897fb 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -611,6 +611,11 @@ out: return err; } +static bool ovl_matches_upper(struct dentry *dentry, struct dentry *upper) +{ + return d_inode(ovl_dentry_upper(dentry)) == d_inode(upper); +} + static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir) { struct dentry *workdir = ovl_workdir(dentry); @@ -646,7 +651,7 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir) err = -ESTALE; if ((opaquedir && upper != opaquedir) || (!opaquedir && ovl_dentry_upper(dentry) && - upper != ovl_dentry_upper(dentry))) { + !ovl_matches_upper(dentry, upper))) { goto out_dput_upper; } @@ -707,7 +712,7 @@ static int ovl_remove_upper(struct dentry *dentry, bool is_dir) err = -ESTALE; if ((opaquedir && upper != opaquedir) || - (!opaquedir && upper != ovl_dentry_upper(dentry))) + (!opaquedir && !ovl_matches_upper(dentry, upper))) goto out_dput_upper; if (is_dir) @@ -985,7 +990,7 @@ static int ovl_rename(struct inode *olddir, struct dentry *old, goto out_unlock; err = -ESTALE; - if (olddentry != ovl_dentry_upper(old)) + if (!ovl_matches_upper(old, olddentry)) goto out_dput_old; newdentry = lookup_one_len(new->d_name.name, new_upperdir, @@ -1003,7 +1008,7 @@ static int ovl_rename(struct inode *olddir, struct dentry *old, if (newdentry != opaquedir) goto out_dput; } else { - if (newdentry != ovl_dentry_upper(new)) + if (!ovl_matches_upper(new, newdentry)) goto out_dput; } } else { |