tracefs: Add missing lockdown check to tracefs_create_dir()
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 5 Sep 2023 18:26:08 +0000 (14:26 -0400)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 6 Sep 2023 01:13:48 +0000 (21:13 -0400)
The function tracefs_create_dir() was missing a lockdown check and was
called by the RV code. This gave an inconsistent behavior of this function
returning success while other tracefs functions failed. This caused the
inode being freed by the wrong kmem_cache.

Link: https://lkml.kernel.org/r/20230905182711.692687042@goodmis.org
Link: https://lore.kernel.org/all/202309050916.58201dc6-oliver.sang@intel.com/
Cc: stable@vger.kernel.org
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>
Fixes: bf8e602186ec4 ("tracing: Do not create tracefs files if tracefs lockdown is in effect")
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
fs/tracefs/inode.c

index de5b72216b1a706bc825a1cea3471079f73631ca..3b8dd938b1c8f304894fd25a9b430a56a960b33b 100644 (file)
@@ -673,6 +673,9 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
  */
 struct dentry *tracefs_create_dir(const char *name, struct dentry *parent)
 {
+       if (security_locked_down(LOCKDOWN_TRACEFS))
+               return NULL;
+
        return __create_dir(name, parent, &simple_dir_inode_operations);
 }