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.

Input: sysrq: mv sysrq into drivers/tty/sysrq.c

Move both sysrq ctl_table and supported sysrq_sysctl_handler helper
function into drivers/tty/sysrq.c. Replaced the __do_proc_dointvec in
helper function with do_proc_dointvec_minmax as the former is local to
kernel/sysctl.c. Here we use the minmax version of do_proc_dointvec
because do_proc_dointvec is static and calling do_proc_dointvec_minmax
with a NULL min and max is the same as calling do_proc_dointvec.

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: Kees Cook <kees@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Joel Granados <joel.granados@kernel.org>

+41 -30
+41
drivers/tty/sysrq.c
··· 1120 1120 } 1121 1121 EXPORT_SYMBOL_GPL(sysrq_toggle_support); 1122 1122 1123 + static int sysrq_sysctl_handler(const struct ctl_table *table, int write, 1124 + void *buffer, size_t *lenp, loff_t *ppos) 1125 + { 1126 + int tmp, ret; 1127 + struct ctl_table t = *table; 1128 + 1129 + tmp = sysrq_mask(); 1130 + t.data = &tmp; 1131 + 1132 + /* 1133 + * Behaves like do_proc_dointvec as t does not have min nor max. 1134 + */ 1135 + ret = proc_dointvec_minmax(&t, write, buffer, lenp, ppos); 1136 + 1137 + if (ret || !write) 1138 + return ret; 1139 + 1140 + if (write) 1141 + sysrq_toggle_support(tmp); 1142 + 1143 + return 0; 1144 + } 1145 + 1146 + static const struct ctl_table sysrq_sysctl_table[] = { 1147 + { 1148 + .procname = "sysrq", 1149 + .data = NULL, 1150 + .maxlen = sizeof(int), 1151 + .mode = 0644, 1152 + .proc_handler = sysrq_sysctl_handler, 1153 + }, 1154 + }; 1155 + 1156 + static int __init init_sysrq_sysctl(void) 1157 + { 1158 + register_sysctl_init("kernel", sysrq_sysctl_table); 1159 + return 0; 1160 + } 1161 + 1162 + subsys_initcall(init_sysrq_sysctl); 1163 + 1123 1164 static int __sysrq_swap_key_ops(u8 key, const struct sysrq_key_op *insert_op_p, 1124 1165 const struct sysrq_key_op *remove_op_p) 1125 1166 {
-30
kernel/sysctl.c
··· 31 31 #include <linux/kernel.h> 32 32 #include <linux/kobject.h> 33 33 #include <linux/net.h> 34 - #include <linux/sysrq.h> 35 34 #include <linux/highuid.h> 36 35 #include <linux/writeback.h> 37 36 #include <linux/ratelimit.h> ··· 963 964 } 964 965 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax); 965 966 966 - #ifdef CONFIG_MAGIC_SYSRQ 967 - static int sysrq_sysctl_handler(const struct ctl_table *table, int write, 968 - void *buffer, size_t *lenp, loff_t *ppos) 969 - { 970 - int tmp, ret; 971 - 972 - tmp = sysrq_mask(); 973 - 974 - ret = __do_proc_dointvec(&tmp, table, write, buffer, 975 - lenp, ppos, NULL, NULL); 976 - if (ret || !write) 977 - return ret; 978 - 979 - if (write) 980 - sysrq_toggle_support(tmp); 981 - 982 - return 0; 983 - } 984 - #endif 985 - 986 967 static int __do_proc_doulongvec_minmax(void *data, 987 968 const struct ctl_table *table, int write, 988 969 void *buffer, size_t *lenp, loff_t *ppos, ··· 1589 1610 .maxlen = UEVENT_HELPER_PATH_LEN, 1590 1611 .mode = 0644, 1591 1612 .proc_handler = proc_dostring, 1592 - }, 1593 - #endif 1594 - #ifdef CONFIG_MAGIC_SYSRQ 1595 - { 1596 - .procname = "sysrq", 1597 - .data = NULL, 1598 - .maxlen = sizeof (int), 1599 - .mode = 0644, 1600 - .proc_handler = sysrq_sysctl_handler, 1601 1613 }, 1602 1614 #endif 1603 1615 #ifdef CONFIG_PROC_SYSCTL