diff options
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r-- | kernel/sysctl.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 40245d697602..c0bb32414b17 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -117,6 +117,7 @@ static int neg_one = -1; | |||
117 | static int zero; | 117 | static int zero; |
118 | static int __maybe_unused one = 1; | 118 | static int __maybe_unused one = 1; |
119 | static int __maybe_unused two = 2; | 119 | static int __maybe_unused two = 2; |
120 | static int __maybe_unused three = 3; | ||
120 | static unsigned long one_ul = 1; | 121 | static unsigned long one_ul = 1; |
121 | static int one_hundred = 100; | 122 | static int one_hundred = 100; |
122 | #ifdef CONFIG_PRINTK | 123 | #ifdef CONFIG_PRINTK |
@@ -169,6 +170,11 @@ static int proc_taint(struct ctl_table *table, int write, | |||
169 | void __user *buffer, size_t *lenp, loff_t *ppos); | 170 | void __user *buffer, size_t *lenp, loff_t *ppos); |
170 | #endif | 171 | #endif |
171 | 172 | ||
173 | #ifdef CONFIG_PRINTK | ||
174 | static int proc_dmesg_restrict(struct ctl_table *table, int write, | ||
175 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
176 | #endif | ||
177 | |||
172 | #ifdef CONFIG_MAGIC_SYSRQ | 178 | #ifdef CONFIG_MAGIC_SYSRQ |
173 | /* Note: sysrq code uses it's own private copy */ | 179 | /* Note: sysrq code uses it's own private copy */ |
174 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; | 180 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; |
@@ -706,7 +712,7 @@ static struct ctl_table kern_table[] = { | |||
706 | .data = &kptr_restrict, | 712 | .data = &kptr_restrict, |
707 | .maxlen = sizeof(int), | 713 | .maxlen = sizeof(int), |
708 | .mode = 0644, | 714 | .mode = 0644, |
709 | .proc_handler = proc_dointvec_minmax, | 715 | .proc_handler = proc_dmesg_restrict, |
710 | .extra1 = &zero, | 716 | .extra1 = &zero, |
711 | .extra2 = &two, | 717 | .extra2 = &two, |
712 | }, | 718 | }, |
@@ -971,14 +977,18 @@ static struct ctl_table vm_table[] = { | |||
971 | .data = &sysctl_overcommit_memory, | 977 | .data = &sysctl_overcommit_memory, |
972 | .maxlen = sizeof(sysctl_overcommit_memory), | 978 | .maxlen = sizeof(sysctl_overcommit_memory), |
973 | .mode = 0644, | 979 | .mode = 0644, |
974 | .proc_handler = proc_dointvec, | 980 | .proc_handler = proc_dointvec_minmax, |
981 | .extra1 = &zero, | ||
982 | .extra2 = &two, | ||
975 | }, | 983 | }, |
976 | { | 984 | { |
977 | .procname = "panic_on_oom", | 985 | .procname = "panic_on_oom", |
978 | .data = &sysctl_panic_on_oom, | 986 | .data = &sysctl_panic_on_oom, |
979 | .maxlen = sizeof(sysctl_panic_on_oom), | 987 | .maxlen = sizeof(sysctl_panic_on_oom), |
980 | .mode = 0644, | 988 | .mode = 0644, |
981 | .proc_handler = proc_dointvec, | 989 | .proc_handler = proc_dointvec_minmax, |
990 | .extra1 = &zero, | ||
991 | .extra2 = &two, | ||
982 | }, | 992 | }, |
983 | { | 993 | { |
984 | .procname = "oom_kill_allocating_task", | 994 | .procname = "oom_kill_allocating_task", |
@@ -1006,7 +1016,8 @@ static struct ctl_table vm_table[] = { | |||
1006 | .data = &page_cluster, | 1016 | .data = &page_cluster, |
1007 | .maxlen = sizeof(int), | 1017 | .maxlen = sizeof(int), |
1008 | .mode = 0644, | 1018 | .mode = 0644, |
1009 | .proc_handler = proc_dointvec, | 1019 | .proc_handler = proc_dointvec_minmax, |
1020 | .extra1 = &zero, | ||
1010 | }, | 1021 | }, |
1011 | { | 1022 | { |
1012 | .procname = "dirty_background_ratio", | 1023 | .procname = "dirty_background_ratio", |
@@ -1054,7 +1065,8 @@ static struct ctl_table vm_table[] = { | |||
1054 | .data = &dirty_expire_interval, | 1065 | .data = &dirty_expire_interval, |
1055 | .maxlen = sizeof(dirty_expire_interval), | 1066 | .maxlen = sizeof(dirty_expire_interval), |
1056 | .mode = 0644, | 1067 | .mode = 0644, |
1057 | .proc_handler = proc_dointvec, | 1068 | .proc_handler = proc_dointvec_minmax, |
1069 | .extra1 = &zero, | ||
1058 | }, | 1070 | }, |
1059 | { | 1071 | { |
1060 | .procname = "nr_pdflush_threads", | 1072 | .procname = "nr_pdflush_threads", |
@@ -1130,6 +1142,8 @@ static struct ctl_table vm_table[] = { | |||
1130 | .maxlen = sizeof(int), | 1142 | .maxlen = sizeof(int), |
1131 | .mode = 0644, | 1143 | .mode = 0644, |
1132 | .proc_handler = drop_caches_sysctl_handler, | 1144 | .proc_handler = drop_caches_sysctl_handler, |
1145 | .extra1 = &one, | ||
1146 | .extra2 = &three, | ||
1133 | }, | 1147 | }, |
1134 | #ifdef CONFIG_COMPACTION | 1148 | #ifdef CONFIG_COMPACTION |
1135 | { | 1149 | { |
@@ -2385,6 +2399,17 @@ static int proc_taint(struct ctl_table *table, int write, | |||
2385 | return err; | 2399 | return err; |
2386 | } | 2400 | } |
2387 | 2401 | ||
2402 | #ifdef CONFIG_PRINTK | ||
2403 | static int proc_dmesg_restrict(struct ctl_table *table, int write, | ||
2404 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
2405 | { | ||
2406 | if (write && !capable(CAP_SYS_ADMIN)) | ||
2407 | return -EPERM; | ||
2408 | |||
2409 | return proc_dointvec_minmax(table, write, buffer, lenp, ppos); | ||
2410 | } | ||
2411 | #endif | ||
2412 | |||
2388 | struct do_proc_dointvec_minmax_conv_param { | 2413 | struct do_proc_dointvec_minmax_conv_param { |
2389 | int *min; | 2414 | int *min; |
2390 | int *max; | 2415 | int *max; |