tracefs/eventfs: Add missing lockdown checks

All the eventfs external functions do not check if TRACEFS_LOCKDOWN was
set or not. This can caused some functions to return success while others
fail, which can trigger unexpected errors.

Add the missing lockdown checks.

Link: https://lkml.kernel.org/r/20230905182711.899724045@goodmis.org
Link: https://lore.kernel.org/all/202309050916.58201dc6-oliver.sang@intel.com/

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ajay Kaher <akaher@vmware.com>
Cc: Ching-lin Yu <chinglinyu@google.com>
Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 51aab5ff
...@@ -491,6 +491,9 @@ struct dentry *eventfs_create_events_dir(const char *name, ...@@ -491,6 +491,9 @@ struct dentry *eventfs_create_events_dir(const char *name,
struct tracefs_inode *ti; struct tracefs_inode *ti;
struct inode *inode; struct inode *inode;
if (security_locked_down(LOCKDOWN_TRACEFS))
return NULL;
if (IS_ERR(dentry)) if (IS_ERR(dentry))
return dentry; return dentry;
...@@ -538,6 +541,9 @@ struct eventfs_file *eventfs_add_subsystem_dir(const char *name, ...@@ -538,6 +541,9 @@ struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
struct eventfs_inode *ei_parent; struct eventfs_inode *ei_parent;
struct eventfs_file *ef; struct eventfs_file *ef;
if (security_locked_down(LOCKDOWN_TRACEFS))
return NULL;
if (!parent) if (!parent)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -569,6 +575,9 @@ struct eventfs_file *eventfs_add_dir(const char *name, ...@@ -569,6 +575,9 @@ struct eventfs_file *eventfs_add_dir(const char *name,
{ {
struct eventfs_file *ef; struct eventfs_file *ef;
if (security_locked_down(LOCKDOWN_TRACEFS))
return NULL;
if (!ef_parent) if (!ef_parent)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -606,6 +615,9 @@ int eventfs_add_events_file(const char *name, umode_t mode, ...@@ -606,6 +615,9 @@ int eventfs_add_events_file(const char *name, umode_t mode,
struct eventfs_inode *ei; struct eventfs_inode *ei;
struct eventfs_file *ef; struct eventfs_file *ef;
if (security_locked_down(LOCKDOWN_TRACEFS))
return -ENODEV;
if (!parent) if (!parent)
return -EINVAL; return -EINVAL;
...@@ -654,6 +666,9 @@ int eventfs_add_file(const char *name, umode_t mode, ...@@ -654,6 +666,9 @@ int eventfs_add_file(const char *name, umode_t mode,
{ {
struct eventfs_file *ef; struct eventfs_file *ef;
if (security_locked_down(LOCKDOWN_TRACEFS))
return -ENODEV;
if (!ef_parent) if (!ef_parent)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment