Skip to content

Commit f1975e4

Browse files
committed
Merge tag 'sysctl-6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl
Pull sysctl updates from Joel Granados: - Move kern_table members out of kernel/sysctl.c Moved a subset (tracing, panic, signal, stack_tracer and sparc) out of the kern_table array. The goal is for kern_table to only have sysctl elements. All this increases modularity by placing the ctl_tables closer to where they are used while reducing the chances of merge conflicts in kernel/sysctl.c. - Fixed sysctl unit test panic by relocating it to selftests * tag 'sysctl-6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl: sysctl: Close test ctl_headers with a for loop sysctl: call sysctl tests with a for loop sysctl: Add 0012 to test the u8 range check sysctl: move u8 register test to lib/test_sysctl.c sparc: mv sparc sysctls into their own file under arch/sparc/kernel stack_tracer: move sysctl registration to kernel/trace/trace_stack.c tracing: Move trace sysctls into trace.c signal: Move signal ctl tables into signal.c panic: Move panic ctl tables into panic.c
2 parents c353286 + 23b8bac commit f1975e4

File tree

11 files changed

+265
-208
lines changed

11 files changed

+265
-208
lines changed

arch/sparc/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ obj-y += process.o
3535
obj-y += signal_$(BITS).o
3636
obj-y += sigutil_$(BITS).o
3737
obj-$(CONFIG_SPARC32) += ioport.o
38+
obj-y += setup.o
3839
obj-y += setup_$(BITS).o
3940
obj-y += idprom.o
4041
obj-y += sys_sparc_$(BITS).o

arch/sparc/kernel/setup.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <asm/setup.h>
4+
#include <linux/sysctl.h>
5+
6+
static const struct ctl_table sparc_sysctl_table[] = {
7+
{
8+
.procname = "reboot-cmd",
9+
.data = reboot_command,
10+
.maxlen = 256,
11+
.mode = 0644,
12+
.proc_handler = proc_dostring,
13+
},
14+
{
15+
.procname = "stop-a",
16+
.data = &stop_a_enabled,
17+
.maxlen = sizeof(int),
18+
.mode = 0644,
19+
.proc_handler = proc_dointvec,
20+
},
21+
{
22+
.procname = "scons-poweroff",
23+
.data = &scons_pwroff,
24+
.maxlen = sizeof(int),
25+
.mode = 0644,
26+
.proc_handler = proc_dointvec,
27+
},
28+
#ifdef CONFIG_SPARC64
29+
{
30+
.procname = "tsb-ratio",
31+
.data = &sysctl_tsb_ratio,
32+
.maxlen = sizeof(int),
33+
.mode = 0644,
34+
.proc_handler = proc_dointvec,
35+
},
36+
#endif
37+
};
38+
39+
40+
static int __init init_sparc_sysctls(void)
41+
{
42+
register_sysctl_init("kernel", sparc_sysctl_table);
43+
return 0;
44+
}
45+
46+
arch_initcall(init_sparc_sysctls);

include/linux/ftrace.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,6 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs,
569569

570570
#ifdef CONFIG_STACK_TRACER
571571

572-
extern int stack_tracer_enabled;
573-
574572
int stack_trace_sysctl(const struct ctl_table *table, int write, void *buffer,
575573
size_t *lenp, loff_t *ppos);
576574

@@ -1298,16 +1296,9 @@ static inline void unpause_graph_tracing(void) { }
12981296
#ifdef CONFIG_TRACING
12991297
enum ftrace_dump_mode;
13001298

1301-
#define MAX_TRACER_SIZE 100
1302-
extern char ftrace_dump_on_oops[];
13031299
extern int ftrace_dump_on_oops_enabled(void);
1304-
extern int tracepoint_printk;
13051300

13061301
extern void disable_trace_on_warning(void);
1307-
extern int __disable_trace_on_warning;
1308-
1309-
int tracepoint_printk_sysctl(const struct ctl_table *table, int write,
1310-
void *buffer, size_t *lenp, loff_t *ppos);
13111302

13121303
#else /* CONFIG_TRACING */
13131304
static inline void disable_trace_on_warning(void) { }

kernel/panic.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,36 @@ static const struct ctl_table kern_panic_table[] = {
9696
.extra2 = SYSCTL_ONE,
9797
},
9898
#endif
99+
{
100+
.procname = "panic",
101+
.data = &panic_timeout,
102+
.maxlen = sizeof(int),
103+
.mode = 0644,
104+
.proc_handler = proc_dointvec,
105+
},
106+
{
107+
.procname = "panic_on_oops",
108+
.data = &panic_on_oops,
109+
.maxlen = sizeof(int),
110+
.mode = 0644,
111+
.proc_handler = proc_dointvec,
112+
},
113+
{
114+
.procname = "panic_print",
115+
.data = &panic_print,
116+
.maxlen = sizeof(unsigned long),
117+
.mode = 0644,
118+
.proc_handler = proc_doulongvec_minmax,
119+
},
120+
{
121+
.procname = "panic_on_warn",
122+
.data = &panic_on_warn,
123+
.maxlen = sizeof(int),
124+
.mode = 0644,
125+
.proc_handler = proc_dointvec_minmax,
126+
.extra1 = SYSCTL_ZERO,
127+
.extra2 = SYSCTL_ONE,
128+
},
99129
{
100130
.procname = "warn_limit",
101131
.data = &warn_limit,

kernel/signal.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4981,9 +4981,20 @@ static const struct ctl_table signal_debug_table[] = {
49814981
#endif
49824982
};
49834983

4984+
static const struct ctl_table signal_table[] = {
4985+
{
4986+
.procname = "print-fatal-signals",
4987+
.data = &print_fatal_signals,
4988+
.maxlen = sizeof(int),
4989+
.mode = 0644,
4990+
.proc_handler = proc_dointvec,
4991+
},
4992+
};
4993+
49844994
static int __init init_signal_sysctls(void)
49854995
{
49864996
register_sysctl_init("debug", signal_debug_table);
4997+
register_sysctl_init("kernel", signal_table);
49874998
return 0;
49884999
}
49895000
early_initcall(init_signal_sysctls);

kernel/sysctl-test.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -367,54 +367,6 @@ static void sysctl_test_api_dointvec_write_single_greater_int_max(
367367
KUNIT_EXPECT_EQ(test, 0, *((int *)table.data));
368368
}
369369

370-
/*
371-
* Test that registering an invalid extra value is not allowed.
372-
*/
373-
static void sysctl_test_register_sysctl_sz_invalid_extra_value(
374-
struct kunit *test)
375-
{
376-
unsigned char data = 0;
377-
const struct ctl_table table_foo[] = {
378-
{
379-
.procname = "foo",
380-
.data = &data,
381-
.maxlen = sizeof(u8),
382-
.mode = 0644,
383-
.proc_handler = proc_dou8vec_minmax,
384-
.extra1 = SYSCTL_FOUR,
385-
.extra2 = SYSCTL_ONE_THOUSAND,
386-
},
387-
};
388-
389-
const struct ctl_table table_bar[] = {
390-
{
391-
.procname = "bar",
392-
.data = &data,
393-
.maxlen = sizeof(u8),
394-
.mode = 0644,
395-
.proc_handler = proc_dou8vec_minmax,
396-
.extra1 = SYSCTL_NEG_ONE,
397-
.extra2 = SYSCTL_ONE_HUNDRED,
398-
},
399-
};
400-
401-
const struct ctl_table table_qux[] = {
402-
{
403-
.procname = "qux",
404-
.data = &data,
405-
.maxlen = sizeof(u8),
406-
.mode = 0644,
407-
.proc_handler = proc_dou8vec_minmax,
408-
.extra1 = SYSCTL_ZERO,
409-
.extra2 = SYSCTL_TWO_HUNDRED,
410-
},
411-
};
412-
413-
KUNIT_EXPECT_NULL(test, register_sysctl("foo", table_foo));
414-
KUNIT_EXPECT_NULL(test, register_sysctl("foo", table_bar));
415-
KUNIT_EXPECT_NOT_NULL(test, register_sysctl("foo", table_qux));
416-
}
417-
418370
static struct kunit_case sysctl_test_cases[] = {
419371
KUNIT_CASE(sysctl_test_api_dointvec_null_tbl_data),
420372
KUNIT_CASE(sysctl_test_api_dointvec_table_maxlen_unset),
@@ -426,7 +378,6 @@ static struct kunit_case sysctl_test_cases[] = {
426378
KUNIT_CASE(sysctl_test_dointvec_write_happy_single_negative),
427379
KUNIT_CASE(sysctl_test_api_dointvec_write_single_less_int_min),
428380
KUNIT_CASE(sysctl_test_api_dointvec_write_single_greater_int_max),
429-
KUNIT_CASE(sysctl_test_register_sysctl_sz_invalid_extra_value),
430381
{}
431382
};
432383

kernel/sysctl.c

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include <linux/module.h>
2323
#include <linux/sysctl.h>
2424
#include <linux/bitmap.h>
25-
#include <linux/signal.h>
26-
#include <linux/panic.h>
2725
#include <linux/printk.h>
2826
#include <linux/proc_fs.h>
2927
#include <linux/security.h>
@@ -46,7 +44,6 @@
4644
#include <linux/nfs_fs.h>
4745
#include <linux/acpi.h>
4846
#include <linux/reboot.h>
49-
#include <linux/ftrace.h>
5047
#include <linux/kmod.h>
5148
#include <linux/capability.h>
5249
#include <linux/binfmts.h>
@@ -61,12 +58,8 @@
6158

6259
#ifdef CONFIG_X86
6360
#include <asm/nmi.h>
64-
#include <asm/stacktrace.h>
6561
#include <asm/io.h>
6662
#endif
67-
#ifdef CONFIG_SPARC
68-
#include <asm/setup.h>
69-
#endif
7063
#ifdef CONFIG_RT_MUTEXES
7164
#include <linux/rtmutex.h>
7265
#endif
@@ -1588,13 +1581,6 @@ int proc_do_static_key(const struct ctl_table *table, int write,
15881581
}
15891582

15901583
static const struct ctl_table kern_table[] = {
1591-
{
1592-
.procname = "panic",
1593-
.data = &panic_timeout,
1594-
.maxlen = sizeof(int),
1595-
.mode = 0644,
1596-
.proc_handler = proc_dointvec,
1597-
},
15981584
#ifdef CONFIG_PROC_SYSCTL
15991585
{
16001586
.procname = "tainted",
@@ -1611,45 +1597,6 @@ static const struct ctl_table kern_table[] = {
16111597
.extra1 = SYSCTL_NEG_ONE,
16121598
.extra2 = SYSCTL_ONE,
16131599
},
1614-
#endif
1615-
{
1616-
.procname = "print-fatal-signals",
1617-
.data = &print_fatal_signals,
1618-
.maxlen = sizeof(int),
1619-
.mode = 0644,
1620-
.proc_handler = proc_dointvec,
1621-
},
1622-
#ifdef CONFIG_SPARC
1623-
{
1624-
.procname = "reboot-cmd",
1625-
.data = reboot_command,
1626-
.maxlen = 256,
1627-
.mode = 0644,
1628-
.proc_handler = proc_dostring,
1629-
},
1630-
{
1631-
.procname = "stop-a",
1632-
.data = &stop_a_enabled,
1633-
.maxlen = sizeof (int),
1634-
.mode = 0644,
1635-
.proc_handler = proc_dointvec,
1636-
},
1637-
{
1638-
.procname = "scons-poweroff",
1639-
.data = &scons_pwroff,
1640-
.maxlen = sizeof (int),
1641-
.mode = 0644,
1642-
.proc_handler = proc_dointvec,
1643-
},
1644-
#endif
1645-
#ifdef CONFIG_SPARC64
1646-
{
1647-
.procname = "tsb-ratio",
1648-
.data = &sysctl_tsb_ratio,
1649-
.maxlen = sizeof (int),
1650-
.mode = 0644,
1651-
.proc_handler = proc_dointvec,
1652-
},
16531600
#endif
16541601
#ifdef CONFIG_PARISC
16551602
{
@@ -1669,38 +1616,6 @@ static const struct ctl_table kern_table[] = {
16691616
.proc_handler = proc_dointvec,
16701617
},
16711618
#endif
1672-
#ifdef CONFIG_STACK_TRACER
1673-
{
1674-
.procname = "stack_tracer_enabled",
1675-
.data = &stack_tracer_enabled,
1676-
.maxlen = sizeof(int),
1677-
.mode = 0644,
1678-
.proc_handler = stack_trace_sysctl,
1679-
},
1680-
#endif
1681-
#ifdef CONFIG_TRACING
1682-
{
1683-
.procname = "ftrace_dump_on_oops",
1684-
.data = &ftrace_dump_on_oops,
1685-
.maxlen = MAX_TRACER_SIZE,
1686-
.mode = 0644,
1687-
.proc_handler = proc_dostring,
1688-
},
1689-
{
1690-
.procname = "traceoff_on_warning",
1691-
.data = &__disable_trace_on_warning,
1692-
.maxlen = sizeof(__disable_trace_on_warning),
1693-
.mode = 0644,
1694-
.proc_handler = proc_dointvec,
1695-
},
1696-
{
1697-
.procname = "tracepoint_printk",
1698-
.data = &tracepoint_printk,
1699-
.maxlen = sizeof(tracepoint_printk),
1700-
.mode = 0644,
1701-
.proc_handler = tracepoint_printk_sysctl,
1702-
},
1703-
#endif
17041619
#ifdef CONFIG_MODULES
17051620
{
17061621
.procname = "modprobe",
@@ -1772,20 +1687,6 @@ static const struct ctl_table kern_table[] = {
17721687
.extra1 = SYSCTL_ZERO,
17731688
.extra2 = SYSCTL_MAXOLDUID,
17741689
},
1775-
{
1776-
.procname = "panic_on_oops",
1777-
.data = &panic_on_oops,
1778-
.maxlen = sizeof(int),
1779-
.mode = 0644,
1780-
.proc_handler = proc_dointvec,
1781-
},
1782-
{
1783-
.procname = "panic_print",
1784-
.data = &panic_print,
1785-
.maxlen = sizeof(unsigned long),
1786-
.mode = 0644,
1787-
.proc_handler = proc_doulongvec_minmax,
1788-
},
17891690
{
17901691
.procname = "ngroups_max",
17911692
.data = (void *)&ngroups_max,
@@ -1837,15 +1738,6 @@ static const struct ctl_table kern_table[] = {
18371738
.proc_handler = proc_dointvec,
18381739
},
18391740
#endif
1840-
{
1841-
.procname = "panic_on_warn",
1842-
.data = &panic_on_warn,
1843-
.maxlen = sizeof(int),
1844-
.mode = 0644,
1845-
.proc_handler = proc_dointvec_minmax,
1846-
.extra1 = SYSCTL_ZERO,
1847-
.extra2 = SYSCTL_ONE,
1848-
},
18491741
#ifdef CONFIG_TREE_RCU
18501742
{
18511743
.procname = "panic_on_rcu_stall",

0 commit comments

Comments
 (0)