diff options
| author | Joel Granados <joel.granados@kernel.org> | 2025-05-05 21:47:47 +0200 |
|---|---|---|
| committer | Joel Granados <joel.granados@kernel.org> | 2025-07-23 11:52:48 +0200 |
| commit | e054bcbe7e7af2baad3752f1a4916a7fffc0457e (patch) | |
| tree | 276863096292fa93245ae805ccf50cdeae1361e4 /kernel/pid.c | |
| parent | sysctl: Move tainted ctl_table into kernel/panic.c (diff) | |
| download | linux-e054bcbe7e7af2baad3752f1a4916a7fffc0457e.tar.gz linux-e054bcbe7e7af2baad3752f1a4916a7fffc0457e.zip | |
sysctl: move cad_pid into kernel/pid.c
Move cad_pid as well as supporting function proc_do_cad_pid into
kernel/pic.c. Replaced call to __do_proc_dointvec with proc_dointvec
inside proc_do_cad_pid which requires the copy of the ctl_table to
handle the temp value.
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>
Diffstat (limited to 'kernel/pid.c')
| -rw-r--r-- | kernel/pid.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 8317bcbc7cf7..9ea0db2cdc29 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -713,6 +713,29 @@ static struct ctl_table_root pid_table_root = { .set_ownership = pid_table_root_set_ownership, }; +static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer, + size_t *lenp, loff_t *ppos) +{ + struct pid *new_pid; + pid_t tmp_pid; + int r; + struct ctl_table tmp_table = *table; + + tmp_pid = pid_vnr(cad_pid); + tmp_table.data = &tmp_pid; + + r = proc_dointvec(&tmp_table, write, buffer, lenp, ppos); + if (r || !write) + return r; + + new_pid = find_get_pid(tmp_pid); + if (!new_pid) + return -ESRCH; + + put_pid(xchg(&cad_pid, new_pid)); + return 0; +} + static const struct ctl_table pid_table[] = { { .procname = "pid_max", @@ -723,6 +746,14 @@ static const struct ctl_table pid_table[] = { .extra1 = &pid_max_min, .extra2 = &pid_max_max, }, +#ifdef CONFIG_PROC_SYSCTL + { + .procname = "cad_pid", + .maxlen = sizeof(int), + .mode = 0600, + .proc_handler = proc_do_cad_pid, + }, +#endif }; #endif |
