tracefs: Fix refcount imbalance in start_creating()
Steven Rostedt
maintainerPATCH 1/1 tracefs: Fix refcount imbalance in start_creating()
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: d227c3ae4e94e5eb11dd780a811f59e1a7b74ccd
Daniel Borkmann (1):
tracefs: Fix refcount imbalance in start_creating()
----
fs/tracefs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --------------------------- commit d227c3ae4e94e5eb11dd780a811f59e1a7b74ccd Author: Daniel Borkmann <[email protected]> Date: Wed Nov 4 23:33:17 2015 +0100
tracefs: Fix refcount imbalance in start_creating()
In tracefs' start_creating(), we pin the file system to safely access its root. When we failed to create a file, we unpin the file system via failed_creating() to release the mount count and eventually the reference of the singleton vfsmount.
However, when we run into an error during lookup_one_len() when still in start_creating(), we only release the parent's mutex but not so the reference on the mount.
F.e., in securityfs_create_file(), after doing simple_pin_fs() when lookup_one_len() fails there, we infact do simple_release_fs(). This seems necessary here as well.
Same issue seen in debugfs due to 190afd81e4a5 ("debugfs: split the beginning and the end of __create_file() off"), which seemed to got carried over into tracefs, too. Noticed during code review.
fs/tracefs/inode.c +5 -1
@@ -340,8 +340,12 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)dput (dentry); dentry =ERR_PTR (-EEXIST ); } -if (IS_ERR (dentry)) + +if (IS_ERR (dentry)) {mutex_unlock (&parent->d_inode->i_mutex); +simple_release_fs (&tracefs_mount, &tracefs_mount_count); + } +return dentry; }
Steven Rostedt
maintainerForgot to Cc Daniel.
-- Steve
Quoted 61 lines · On Thu, 5 Nov 2015 08:29:33 -0500 Steven Rostedt <[email protected]> wrote:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-nextHead SHA1:
d227c3ae4e94e5eb11dd780a811f59e1a7b74ccdDaniel Borkmann (1):
tracefs: Fix refcount imbalance instart_creating()----
fs/tracefs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --------------------------- commit d227c3ae4e94e5eb11dd780a811f59e1a7b74ccd Author: Daniel Borkmann <[email protected]> Date: Wed Nov 4 23:33:17 2015 +0100tracefs: Fix refcount imbalance in
start_creating()In tracefs'
start_creating(), we pin the file system to safely access its root. When we failed to create a file, we unpin the file system viafailed_creating()to release the mount count and eventually the reference of the singleton vfsmount.However, when we run into an error during
lookup_one_len()when still instart_creating(), we only release the parent's mutex but not so the reference on the mount.F.e., in
securityfs_create_file(), after doingsimple_pin_fs()whenlookup_one_len()fails there, we infact dosimple_release_fs(). This seems necessary here as well.Same issue seen in debugfs due to
190afd81e4a5("debugfs: split the beginning and the end of__create_file()off"), which seemed to got carried over into tracefs, too. Noticed during code review.Fixes 4282d60689d4 ("tracefs: Add new tracefs file system")Cc [email protected] # 4.1+Signed-off-by Daniel Borkmann <[email protected]>Signed-off-by Steven Rostedt <[email protected]>fs/tracefs/inode.c +5
-1@@ -340,8 +340,12 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)dput (dentry); dentry =ERR_PTR (-EEXIST ); } -if (IS_ERR (dentry)) + +if (IS_ERR (dentry)) {mutex_unlock (&parent->d_inode->i_mutex); +simple_release_fs (&tracefs_mount, &tracefs_mount_count); + } +return dentry; }