diff options
author | Amir Goldstein <amir73il@gmail.com> | 2017-09-25 15:39:55 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-10-05 15:53:18 +0200 |
commit | 5820dc0888d302ac05f8b91ffdf7e4e53b4fbf53 (patch) | |
tree | e22ae933b338fe9a51f34cef6658d82484aaff91 /fs/overlayfs/util.c | |
parent | ovl: fix dentry leak in ovl_indexdir_cleanup() (diff) | |
download | linux-5820dc0888d302ac05f8b91ffdf7e4e53b4fbf53.tar.xz linux-5820dc0888d302ac05f8b91ffdf7e4e53b4fbf53.zip |
ovl: fix missing unlock_rename() in ovl_do_copy_up()
Use the ovl_lock_rename_workdir() helper which requires
unlock_rename() only on lock success.
Fixes: ("fd210b7d67ee ovl: move copy up lock out")
Cc: <stable@vger.kernel.org> # v4.13
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to '')
-rw-r--r-- | fs/overlayfs/util.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 7ae33d225a67..b9b239fa5cfd 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -560,3 +560,22 @@ void ovl_nlink_end(struct dentry *dentry, bool locked) mutex_unlock(&OVL_I(d_inode(dentry))->lock); } } + +int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir) +{ + /* Workdir should not be the same as upperdir */ + if (workdir == upperdir) + goto err; + + /* Workdir should not be subdir of upperdir and vice versa */ + if (lock_rename(workdir, upperdir) != NULL) + goto err_unlock; + + return 0; + +err_unlock: + unlock_rename(workdir, upperdir); +err: + pr_err("overlayfs: failed to lock workdir+upperdir\n"); + return -EIO; +} |