summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Granados <joel.granados@kernel.org>2025-05-02 22:27:38 +0200
committerJoel Granados <joel.granados@kernel.org>2025-07-23 11:52:48 +0200
commit8e5f04b0d58c734c69a0b6e26317561919299638 (patch)
treefe215a210b01f1946015d57a04cbffbcbdf950ea
parent9e2f403dd8c2b07aff012e72c1fe5455538d72d2 (diff)
fork: mv threads-max into kernel/fork.c
make sysctl_max_threads static as it no longer needs to be exported into sysctl.c. This is part of a greater effort to move ctl tables into their respective subsystems which will reduce the merge conflicts in kernel/sysctl.c. Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Reviewed-by: Kees Cook <kees@kernel.org> Signed-off-by: Joel Granados <joel.granados@kernel.org>
-rw-r--r--include/linux/sysctl.h3
-rw-r--r--kernel/fork.c20
-rw-r--r--kernel/sysctl.c7
3 files changed, 19 insertions, 11 deletions
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index ae762eabb7c9..30bcbc59d12d 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -284,7 +284,4 @@ static inline bool sysctl_is_alias(char *param)
}
#endif /* CONFIG_SYSCTL */
-int sysctl_max_threads(const struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos);
-
#endif /* _LINUX_SYSCTL_H */
diff --git a/kernel/fork.c b/kernel/fork.c
index 1ee8eb11f38b..dea8e7740ad2 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -3216,7 +3216,7 @@ int unshare_files(void)
return 0;
}
-int sysctl_max_threads(const struct ctl_table *table, int write,
+static int sysctl_max_threads(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
struct ctl_table t;
@@ -3238,3 +3238,21 @@ int sysctl_max_threads(const struct ctl_table *table, int write,
return 0;
}
+
+static const struct ctl_table fork_sysctl_table[] = {
+ {
+ .procname = "threads-max",
+ .data = NULL,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = sysctl_max_threads,
+ },
+};
+
+static int __init init_fork_sysctl(void)
+{
+ register_sysctl_init("kernel", fork_sysctl_table);
+ return 0;
+}
+
+subsys_initcall(init_fork_sysctl);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 718140251972..febf328054aa 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1631,13 +1631,6 @@ static const struct ctl_table kern_table[] = {
},
#endif
{
- .procname = "threads-max",
- .data = NULL,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = sysctl_max_threads,
- },
- {
.procname = "overflowuid",
.data = &overflowuid,
.maxlen = sizeof(int),