aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c60
1 files changed, 26 insertions, 34 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ae5cbb1e3ced..51054fea5d99 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -24,6 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/sysctl.h> 25#include <linux/sysctl.h>
26#include <linux/signal.h> 26#include <linux/signal.h>
27#include <linux/printk.h>
27#include <linux/proc_fs.h> 28#include <linux/proc_fs.h>
28#include <linux/security.h> 29#include <linux/security.h>
29#include <linux/ctype.h> 30#include <linux/ctype.h>
@@ -169,7 +170,8 @@ static int proc_taint(struct ctl_table *table, int write,
169#endif 170#endif
170 171
171#ifdef CONFIG_MAGIC_SYSRQ 172#ifdef CONFIG_MAGIC_SYSRQ
172static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */ 173/* Note: sysrq code uses it's own private copy */
174static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
173 175
174static int sysrq_sysctl_handler(ctl_table *table, int write, 176static int sysrq_sysctl_handler(ctl_table *table, int write,
175 void __user *buffer, size_t *lenp, 177 void __user *buffer, size_t *lenp,
@@ -192,9 +194,9 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
192static struct ctl_table root_table[]; 194static struct ctl_table root_table[];
193static struct ctl_table_root sysctl_table_root; 195static struct ctl_table_root sysctl_table_root;
194static struct ctl_table_header root_table_header = { 196static struct ctl_table_header root_table_header = {
195 .count = 1, 197 {{.count = 1,
196 .ctl_table = root_table, 198 .ctl_table = root_table,
197 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 199 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}},
198 .root = &sysctl_table_root, 200 .root = &sysctl_table_root,
199 .set = &sysctl_table_root.default_set, 201 .set = &sysctl_table_root.default_set,
200}; 202};
@@ -245,10 +247,6 @@ static struct ctl_table root_table[] = {
245 .mode = 0555, 247 .mode = 0555,
246 .child = dev_table, 248 .child = dev_table,
247 }, 249 },
248/*
249 * NOTE: do not add new entries to this table unless you have read
250 * Documentation/sysctl/ctl_unnumbered.txt
251 */
252 { } 250 { }
253}; 251};
254 252
@@ -363,20 +361,13 @@ static struct ctl_table kern_table[] = {
363 .mode = 0644, 361 .mode = 0644,
364 .proc_handler = sched_rt_handler, 362 .proc_handler = sched_rt_handler,
365 }, 363 },
366 {
367 .procname = "sched_compat_yield",
368 .data = &sysctl_sched_compat_yield,
369 .maxlen = sizeof(unsigned int),
370 .mode = 0644,
371 .proc_handler = proc_dointvec,
372 },
373#ifdef CONFIG_SCHED_AUTOGROUP 364#ifdef CONFIG_SCHED_AUTOGROUP
374 { 365 {
375 .procname = "sched_autogroup_enabled", 366 .procname = "sched_autogroup_enabled",
376 .data = &sysctl_sched_autogroup_enabled, 367 .data = &sysctl_sched_autogroup_enabled,
377 .maxlen = sizeof(unsigned int), 368 .maxlen = sizeof(unsigned int),
378 .mode = 0644, 369 .mode = 0644,
379 .proc_handler = proc_dointvec, 370 .proc_handler = proc_dointvec_minmax,
380 .extra1 = &zero, 371 .extra1 = &zero,
381 .extra2 = &one, 372 .extra2 = &one,
382 }, 373 },
@@ -710,6 +701,15 @@ static struct ctl_table kern_table[] = {
710 .extra1 = &zero, 701 .extra1 = &zero,
711 .extra2 = &one, 702 .extra2 = &one,
712 }, 703 },
704 {
705 .procname = "kptr_restrict",
706 .data = &kptr_restrict,
707 .maxlen = sizeof(int),
708 .mode = 0644,
709 .proc_handler = proc_dointvec_minmax,
710 .extra1 = &zero,
711 .extra2 = &two,
712 },
713#endif 713#endif
714 { 714 {
715 .procname = "ngroups_max", 715 .procname = "ngroups_max",
@@ -941,7 +941,7 @@ static struct ctl_table kern_table[] = {
941 .data = &sysctl_perf_event_sample_rate, 941 .data = &sysctl_perf_event_sample_rate,
942 .maxlen = sizeof(sysctl_perf_event_sample_rate), 942 .maxlen = sizeof(sysctl_perf_event_sample_rate),
943 .mode = 0644, 943 .mode = 0644,
944 .proc_handler = proc_dointvec, 944 .proc_handler = perf_proc_update_handler,
945 }, 945 },
946#endif 946#endif
947#ifdef CONFIG_KMEMCHECK 947#ifdef CONFIG_KMEMCHECK
@@ -962,10 +962,6 @@ static struct ctl_table kern_table[] = {
962 .proc_handler = proc_dointvec, 962 .proc_handler = proc_dointvec,
963 }, 963 },
964#endif 964#endif
965/*
966 * NOTE: do not add new entries to this table unless you have read
967 * Documentation/sysctl/ctl_unnumbered.txt
968 */
969 { } 965 { }
970}; 966};
971 967
@@ -1326,11 +1322,6 @@ static struct ctl_table vm_table[] = {
1326 .extra2 = &one, 1322 .extra2 = &one,
1327 }, 1323 },
1328#endif 1324#endif
1329
1330/*
1331 * NOTE: do not add new entries to this table unless you have read
1332 * Documentation/sysctl/ctl_unnumbered.txt
1333 */
1334 { } 1325 { }
1335}; 1326};
1336 1327
@@ -1486,10 +1477,6 @@ static struct ctl_table fs_table[] = {
1486 .proc_handler = &pipe_proc_fn, 1477 .proc_handler = &pipe_proc_fn,
1487 .extra1 = &pipe_min_size, 1478 .extra1 = &pipe_min_size,
1488 }, 1479 },
1489/*
1490 * NOTE: do not add new entries to this table unless you have read
1491 * Documentation/sysctl/ctl_unnumbered.txt
1492 */
1493 { } 1480 { }
1494}; 1481};
1495 1482
@@ -1573,11 +1560,16 @@ void sysctl_head_get(struct ctl_table_header *head)
1573 spin_unlock(&sysctl_lock); 1560 spin_unlock(&sysctl_lock);
1574} 1561}
1575 1562
1563static void free_head(struct rcu_head *rcu)
1564{
1565 kfree(container_of(rcu, struct ctl_table_header, rcu));
1566}
1567
1576void sysctl_head_put(struct ctl_table_header *head) 1568void sysctl_head_put(struct ctl_table_header *head)
1577{ 1569{
1578 spin_lock(&sysctl_lock); 1570 spin_lock(&sysctl_lock);
1579 if (!--head->count) 1571 if (!--head->count)
1580 kfree(head); 1572 call_rcu(&head->rcu, free_head);
1581 spin_unlock(&sysctl_lock); 1573 spin_unlock(&sysctl_lock);
1582} 1574}
1583 1575
@@ -1954,10 +1946,10 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1954 start_unregistering(header); 1946 start_unregistering(header);
1955 if (!--header->parent->count) { 1947 if (!--header->parent->count) {
1956 WARN_ON(1); 1948 WARN_ON(1);
1957 kfree(header->parent); 1949 call_rcu(&header->parent->rcu, free_head);
1958 } 1950 }
1959 if (!--header->count) 1951 if (!--header->count)
1960 kfree(header); 1952 call_rcu(&header->rcu, free_head);
1961 spin_unlock(&sysctl_lock); 1953 spin_unlock(&sysctl_lock);
1962} 1954}
1963 1955
@@ -2899,7 +2891,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
2899 } 2891 }
2900} 2892}
2901 2893
2902#else /* CONFIG_PROC_FS */ 2894#else /* CONFIG_PROC_SYSCTL */
2903 2895
2904int proc_dostring(struct ctl_table *table, int write, 2896int proc_dostring(struct ctl_table *table, int write,
2905 void __user *buffer, size_t *lenp, loff_t *ppos) 2897 void __user *buffer, size_t *lenp, loff_t *ppos)
@@ -2951,7 +2943,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2951} 2943}
2952 2944
2953 2945
2954#endif /* CONFIG_PROC_FS */ 2946#endif /* CONFIG_PROC_SYSCTL */
2955 2947
2956/* 2948/*
2957 * No sense putting this after each symbol definition, twice, 2949 * No sense putting this after each symbol definition, twice,