* [PATCH] tracefs, debugfs: fix refcount imbalance in start_creating
@ 2015-10-09 18:30 Daniel Borkmann
2015-11-02 19:07 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2015-10-09 18:30 UTC (permalink / raw)
To: viro; +Cc: linux-kernel, Daniel Borkmann, Steven Rostedt
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 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, after doing simple_pin_fs() when lookup_one_len()
fails there, we infact do simple_release_fs(). This seems necessary here
as well. The same also accounts for debugfs as the start_creating() code
was probably taken from there. Noticed during code review.
Fixes: 4282d60689d4 ("tracefs: Add new tracefs file system")
Fixes: 190afd81e4a5 ("debugfs: split the beginning and the end of __create_file() off")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
fs/debugfs/inode.c | 6 +++++-
fs/tracefs/inode.c | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index c711be8..9c8d233 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -271,8 +271,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(&d_inode(parent)->i_mutex);
+ simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ }
+
return dentry;
}
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index cbc8d5d..c66f242 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -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;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tracefs, debugfs: fix refcount imbalance in start_creating
2015-10-09 18:30 [PATCH] tracefs, debugfs: fix refcount imbalance in start_creating Daniel Borkmann
@ 2015-11-02 19:07 ` Steven Rostedt
2015-11-04 22:23 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2015-11-02 19:07 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: viro, linux-kernel
On Fri, 9 Oct 2015 20:30:10 +0200
Daniel Borkmann <daniel@iogearbox.net> wrote:
> 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 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, after doing simple_pin_fs() when lookup_one_len()
> fails there, we infact do simple_release_fs(). This seems necessary here
> as well. The same also accounts for debugfs as the start_creating() code
> was probably taken from there. Noticed during code review.
>
> Fixes: 4282d60689d4 ("tracefs: Add new tracefs file system")
> Fixes: 190afd81e4a5 ("debugfs: split the beginning and the end of __create_file() off")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> ---
> fs/debugfs/inode.c | 6 +++++-
> fs/tracefs/inode.c | 6 +++++-
> 2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> index c711be8..9c8d233 100644
> --- a/fs/debugfs/inode.c
> +++ b/fs/debugfs/inode.c
> @@ -271,8 +271,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(&d_inode(parent)->i_mutex);
> + simple_release_fs(&debugfs_mount, &debugfs_mount_count);
> + }
> +
> return dentry;
> }
>
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index cbc8d5d..c66f242 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -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);
> + }
> +
Acked-by: Steven Rostedt <rostedt@goodmis.org>
-- Steve
> return dentry;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tracefs, debugfs: fix refcount imbalance in start_creating
2015-11-02 19:07 ` Steven Rostedt
@ 2015-11-04 22:23 ` Daniel Borkmann
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2015-11-04 22:23 UTC (permalink / raw)
To: Steven Rostedt; +Cc: viro, linux-kernel
On 11/02/2015 08:07 PM, Steven Rostedt wrote:
> On Fri, 9 Oct 2015 20:30:10 +0200
> Daniel Borkmann <daniel@iogearbox.net> wrote:
>
[...]
>>
>> Fixes: 4282d60689d4 ("tracefs: Add new tracefs file system")
>> Fixes: 190afd81e4a5 ("debugfs: split the beginning and the end of __create_file() off")
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>> Cc: Steven Rostedt <rostedt@goodmis.org>
[...]
Fyi, I'll respin and split this one into two, so they can be routed through
their individual trees. (Keeping Steven's Acked-by on the tracefs one.)
Thanks & sorry for the noise,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-04 22:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-09 18:30 [PATCH] tracefs, debugfs: fix refcount imbalance in start_creating Daniel Borkmann
2015-11-02 19:07 ` Steven Rostedt
2015-11-04 22:23 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).