Patch "ovl: fix missing unlock_rename() in ovl_do_copy_up()" has been added to the 4.13-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
ovl: fix missing unlock_rename() in ovl_do_copy_up()
to the 4.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ovl-fix-missing-unlock_rename-in-ovl_do_copy_up.patch
and it can be found in the queue-4.13 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
5820dc0888d302ac05f8b91ffdf7e4e53b4fbf53Mon Sep 17 00:00:00 2001
From: Amir Goldstein <[email protected]>
Date: Mon, 25 Sep 2017 16:39:55 +0300
Subject: ovl: fix missing unlock_rename() in ovl_do_copy_up()
From: Amir Goldstein <[email protected]>
commit 5820dc0888d302ac05f8b91ffdf7e4e53b4fbf53 upstream.
Use the ovl_lock_rename_workdir() helper which requires unlock_rename() only on lock success.
--- fs/overlayfs/copy_up.c | 6 ++---- fs/overlayfs/dir.c | 20 -------------------- fs/overlayfs/overlayfs.h | 1 + fs/overlayfs/util.c | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 24 deletions(-)
fs/overlayfs/copy_up.c +2 -4
@@ -561,10 +561,8 @@ static int ovl_do_copy_up(struct ovl_cop c->tmpfile = true; err =ovl_copy_up_locked (c); }else { - err = -EIO ; -if (lock_rename (c->workdir, c->destdir) !=NULL ) { -pr_err ("overlayfs: failed to lock workdir+upperdir\n" ); - }else { + err =ovl_lock_rename_workdir (c->workdir, c->destdir); +if (!err) { err =ovl_copy_up_locked (c);unlock_rename (c->workdir, c->destdir); }
fs/overlayfs/dir.c +0 -20
@@ -216,26 +216,6 @@ out_unlock:return err; } -static 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 ; -} -static struct dentry *ovl_clear_empty (struct dentry *dentry,struct list_head *list) {
fs/overlayfs/overlayfs.h +1 -0
@@ -234,6 +234,7 @@ bool ovl_inuse_trylock(struct dentry *devoid ovl_inuse_unlock (struct dentry *dentry);int ovl_nlink_start (struct dentry *dentry,bool *locked);void ovl_nlink_end (struct dentry *dentry,bool locked); +int ovl_lock_rename_workdir (struct dentry *workdir,struct dentry *upperdir);static inline bool ovl_is_impuredir (struct dentry *dentry) {
fs/overlayfs/util.c +19 -0
@@ -548,3 +548,22 @@ void ovl_nlink_end(struct dentry *dentrymutex_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 ; +}
Patches currently in stable-queue which might be from [email protected] are
queue-4.13/ovl-fix-missing-unlock_rename-in-ovl_do_copy_up.patch queue-4.13/ovl-fix-error-value-printed-in-ovl_lookup_index.patch queue-4.13/ovl-fix-dput-of-err_ptr-in-ovl_cleanup_index.patch queue-4.13/ovl-fix-regression-caused-by-exclusive-upper-work-dir-protection.patch queue-4.13/ovl-fix-dentry-leak-in-ovl_indexdir_cleanup.patch