lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221027085343.2388485-1-suagrfillet@gmail.com>
Date:   Thu, 27 Oct 2022 16:53:43 +0800
From:   Song Shuai <suagrfillet@...il.com>
To:     rostedt@...dmis.org, mingo@...hat.com
Cc:     linux-kernel@...r.kernel.org, Song Shuai <suagrfillet@...il.com>
Subject: [PATCH] ftrace: fix static function tracer not working

Setting kernel command line parameter ftrace=function shows
nothing on the kernel built with static ftrace.

In static ftrace, ftrace_nodyn_init should be executed before
initializing tracers. While this commit `dbeafd0d6131` brings
the initialization of function tracer forward from core_initcall
where ftrace_nodyn_init still remains.

This patch puts ftrace_nodyn_init and ftrace_init together and
makes function tracer works in static ftrace.

Fixes: dbeafd0d6131 ("ftrace: Have function tracing start in early boot up")
Signed-off-by: Song Shuai <suagrfillet@...il.com>
---
 include/linux/ftrace.h | 6 ++++++
 init/main.c            | 1 +
 kernel/trace/ftrace.c  | 4 +---
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 0b61371e287b..4bdab0461b10 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -978,6 +978,12 @@ extern void ftrace_init(void);
 static inline void ftrace_init(void) { }
 #endif
 
+
+#ifndef CONFIG_FTRACE_MCOUNT_RECORD
+extern void ftrace_nodyn_init(void);
+#else
+static inline void ftrace_nodyn_init(void) { }
+#endif
 /*
  * Structure that defines an entry function trace.
  * It's already packed but the attribute "packed" is needed
diff --git a/init/main.c b/init/main.c
index 91642a4e69be..ebf8136e828a 100644
--- a/init/main.c
+++ b/init/main.c
@@ -986,6 +986,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
 	trap_init();
 	mm_init();
 
+	ftrace_nodyn_init();
 	ftrace_init();
 
 	/* trace_printk can be enabled here */
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 56b1a42e1937..40325ae575a5 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -7454,12 +7454,10 @@ struct ftrace_ops global_ops = {
 				  FTRACE_OPS_FL_PID,
 };
 
-static int __init ftrace_nodyn_init(void)
+void __init ftrace_nodyn_init(void)
 {
 	ftrace_enabled = 1;
-	return 0;
 }
-core_initcall(ftrace_nodyn_init);
 
 static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; }
 static inline void ftrace_startup_all(int command) { }
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ