Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+31 -31
+31
kernel/pid.c
··· 713 713 .set_ownership = pid_table_root_set_ownership, 714 714 }; 715 715 716 + static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer, 717 + size_t *lenp, loff_t *ppos) 718 + { 719 + struct pid *new_pid; 720 + pid_t tmp_pid; 721 + int r; 722 + struct ctl_table tmp_table = *table; 723 + 724 + tmp_pid = pid_vnr(cad_pid); 725 + tmp_table.data = &tmp_pid; 726 + 727 + r = proc_dointvec(&tmp_table, write, buffer, lenp, ppos); 728 + if (r || !write) 729 + return r; 730 + 731 + new_pid = find_get_pid(tmp_pid); 732 + if (!new_pid) 733 + return -ESRCH; 734 + 735 + put_pid(xchg(&cad_pid, new_pid)); 736 + return 0; 737 + } 738 + 716 739 static const struct ctl_table pid_table[] = { 717 740 { 718 741 .procname = "pid_max", ··· 746 723 .extra1 = &pid_max_min, 747 724 .extra2 = &pid_max_max, 748 725 }, 726 + #ifdef CONFIG_PROC_SYSCTL 727 + { 728 + .procname = "cad_pid", 729 + .maxlen = sizeof(int), 730 + .mode = 0600, 731 + .proc_handler = proc_do_cad_pid, 732 + }, 733 + #endif 749 734 }; 750 735 #endif 751 736
-31
kernel/sysctl.c
··· 1224 1224 do_proc_dointvec_ms_jiffies_conv, NULL); 1225 1225 } 1226 1226 1227 - static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer, 1228 - size_t *lenp, loff_t *ppos) 1229 - { 1230 - struct pid *new_pid; 1231 - pid_t tmp; 1232 - int r; 1233 - 1234 - tmp = pid_vnr(cad_pid); 1235 - 1236 - r = __do_proc_dointvec(&tmp, table, write, buffer, 1237 - lenp, ppos, NULL, NULL); 1238 - if (r || !write) 1239 - return r; 1240 - 1241 - new_pid = find_get_pid(tmp); 1242 - if (!new_pid) 1243 - return -ESRCH; 1244 - 1245 - put_pid(xchg(&cad_pid, new_pid)); 1246 - return 0; 1247 - } 1248 - 1249 1227 /** 1250 1228 * proc_do_large_bitmap - read/write from/to a large bitmap 1251 1229 * @table: the sysctl table ··· 1518 1540 .maxlen = UEVENT_HELPER_PATH_LEN, 1519 1541 .mode = 0644, 1520 1542 .proc_handler = proc_dostring, 1521 - }, 1522 - #endif 1523 - #ifdef CONFIG_PROC_SYSCTL 1524 - { 1525 - .procname = "cad_pid", 1526 - .data = NULL, 1527 - .maxlen = sizeof (int), 1528 - .mode = 0600, 1529 - .proc_handler = proc_do_cad_pid, 1530 1543 }, 1531 1544 #endif 1532 1545 {