Skip to content

Commit e247094

Browse files
committed
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/[email protected] Link: https://lore.kernel.org/all/[email protected]/ Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Ajay Kaher <[email protected]> Cc: Ching-lin Yu <[email protected]> Reported-by: kernel test robot <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 51aab5f commit e247094

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fs/tracefs/event_inode.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ struct dentry *eventfs_create_events_dir(const char *name,
491491
struct tracefs_inode *ti;
492492
struct inode *inode;
493493

494+
if (security_locked_down(LOCKDOWN_TRACEFS))
495+
return NULL;
496+
494497
if (IS_ERR(dentry))
495498
return dentry;
496499

@@ -538,6 +541,9 @@ struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
538541
struct eventfs_inode *ei_parent;
539542
struct eventfs_file *ef;
540543

544+
if (security_locked_down(LOCKDOWN_TRACEFS))
545+
return NULL;
546+
541547
if (!parent)
542548
return ERR_PTR(-EINVAL);
543549

@@ -569,6 +575,9 @@ struct eventfs_file *eventfs_add_dir(const char *name,
569575
{
570576
struct eventfs_file *ef;
571577

578+
if (security_locked_down(LOCKDOWN_TRACEFS))
579+
return NULL;
580+
572581
if (!ef_parent)
573582
return ERR_PTR(-EINVAL);
574583

@@ -606,6 +615,9 @@ int eventfs_add_events_file(const char *name, umode_t mode,
606615
struct eventfs_inode *ei;
607616
struct eventfs_file *ef;
608617

618+
if (security_locked_down(LOCKDOWN_TRACEFS))
619+
return -ENODEV;
620+
609621
if (!parent)
610622
return -EINVAL;
611623

@@ -654,6 +666,9 @@ int eventfs_add_file(const char *name, umode_t mode,
654666
{
655667
struct eventfs_file *ef;
656668

669+
if (security_locked_down(LOCKDOWN_TRACEFS))
670+
return -ENODEV;
671+
657672
if (!ef_parent)
658673
return -EINVAL;
659674

0 commit comments

Comments
 (0)