diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2024-02-06 15:09:33 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-02-23 11:25:21 +0300 |
commit | 29bb70cad6685839f4e5d0b97c4d7ffc8639cb9d (patch) | |
tree | 2b16daf7e5a681dce387c45f6ac9f830b2403b91 | |
parent | 43fbddf34c3cf4c13a4bba442db227dd6780f113 (diff) | |
download | linux-29bb70cad6685839f4e5d0b97c4d7ffc8639cb9d.tar.xz |
eventfs: Do not allow NULL parent to eventfs_start_creating()
commit fc4561226feaad5fcdcb55646c348d77b8ee69c5 upstream.
The eventfs directory is dynamically created via the meta data supplied by
the existing trace events. All files and directories in eventfs has a
parent. Do not allow NULL to be passed into eventfs_start_creating() as
the parent because that should never happen. Warn if it does.
Link: https://lkml.kernel.org/r/20231121231112.693841807@goodmis.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/tracefs/inode.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 34ffb2f8114e..b9ed8db4f6b9 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -509,20 +509,15 @@ struct dentry *eventfs_start_creating(const char *name, struct dentry *parent) struct dentry *dentry; int error; + /* Must always have a parent. */ + if (WARN_ON_ONCE(!parent)) + return ERR_PTR(-EINVAL); + error = simple_pin_fs(&trace_fs_type, &tracefs_mount, &tracefs_mount_count); if (error) return ERR_PTR(error); - /* - * If the parent is not specified, we create it in the root. - * We need the root dentry to do this, which is in the super - * block. A pointer to that is in the struct vfsmount that we - * have around. - */ - if (!parent) - parent = tracefs_mount->mnt_root; - if (unlikely(IS_DEADDIR(parent->d_inode))) dentry = ERR_PTR(-ENOENT); else |