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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220220060017.13285-1-tangmeng@uniontech.com>
Date:   Sun, 20 Feb 2022 14:00:17 +0800
From:   tangmeng <tangmeng@...ontech.com>
To:     rostedt@...dmis.org, mingo@...hat.com, mcgrof@...nel.org,
        keescook@...omium.org, yzaikin@...gle.com
Cc:     linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        nizhen@...ontech.com, zhanglianjie@...ontech.com,
        nixiaoming@...wei.com, tangmeng <tangmeng@...ontech.com>
Subject: [PATCH 02/11] kernel/trace: move stack_tracer_enabled sysctl to its own file

kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to places
where they actually belong.  The proc sysctl maintainers do not want to
know what sysctl knobs you wish to add for your own piece of code, we
just care about the core logic.

All filesystem syctls now get reviewed by fs folks. This commit
follows the commit of fs, move the stack_tracer_enabled sysctl to its
own file, kernel/trace/trace_stack.c.

Signed-off-by: tangmeng <tangmeng@...ontech.com>
---
 include/linux/ftrace.h     |  6 ------
 kernel/sysctl.c            |  9 ---------
 kernel/trace/trace_stack.c | 26 ++++++++++++++++++++++++--
 3 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 9999e29187de..cc6f7532e038 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -392,12 +392,6 @@ static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs,
 #endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */
 
 #ifdef CONFIG_STACK_TRACER
-
-extern int stack_tracer_enabled;
-
-int stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
-		       size_t *lenp, loff_t *ppos);
-
 /* DO NOT MODIFY THIS VARIABLE DIRECTLY! */
 DECLARE_PER_CPU(int, disable_stack_tracer);
 
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d11390634321..b41138d64e5e 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1755,15 +1755,6 @@ static struct ctl_table kern_table[] = {
 		.proc_handler	= ftrace_enable_sysctl,
 	},
 #endif
-#ifdef CONFIG_STACK_TRACER
-	{
-		.procname	= "stack_tracer_enabled",
-		.data		= &stack_tracer_enabled,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= stack_trace_sysctl,
-	},
-#endif
 #ifdef CONFIG_TRACING
 	{
 		.procname	= "ftrace_dump_on_oops",
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 5a48dba912ea..b871499cf7e6 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -32,7 +32,7 @@ static arch_spinlock_t stack_trace_max_lock =
 DEFINE_PER_CPU(int, disable_stack_tracer);
 static DEFINE_MUTEX(stack_sysctl_mutex);
 
-int stack_tracer_enabled;
+static int stack_tracer_enabled;
 
 static void print_max_stack(void)
 {
@@ -513,7 +513,8 @@ static const struct file_operations stack_trace_filter_fops = {
 
 #endif /* CONFIG_DYNAMIC_FTRACE */
 
-int
+#ifdef CONFIG_SYSCTL
+static int
 stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
 		   size_t *lenp, loff_t *ppos)
 {
@@ -537,6 +538,25 @@ stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
 	return ret;
 }
 
+static struct ctl_table kern_trace_stack_table[] = {
+	{
+		.procname       = "stack_tracer_enabled",
+		.data           = &stack_tracer_enabled,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = stack_trace_sysctl,
+	},
+	{ }
+};
+
+static void __init kernel_trace_stack_sysctls_init(void)
+{
+	register_sysctl_init("kernel", kern_trace_stack_table);
+}
+#else
+#define kernel_trace_stack_sysctls_init() do { } while (0)
+#endif /* CONFIG_SYSCTL */
+
 static char stack_trace_filter_buf[COMMAND_LINE_SIZE+1] __initdata;
 
 static __init int enable_stacktrace(char *str)
@@ -576,6 +596,8 @@ static __init int stack_trace_init(void)
 	if (stack_tracer_enabled)
 		register_ftrace_function(&trace_ops);
 
+	kernel_trace_stack_sysctls_init();
+
 	return 0;
 }
 
-- 
2.20.1



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ