Commit 9aa06b85e000ef2fcba2b8dfa3e57eb809e99026
Committed by
Greg Kroah-Hartman
1 parent
9fb1fd7880
sysctl: fix write access to dmesg_restrict/kptr_restrict
commit 620f6e8e855d6d447688a5f67a4e176944a084e8 upstream. Commit bfdc0b4 adds code to restrict access to dmesg_restrict, however, it incorrectly alters kptr_restrict rather than dmesg_restrict. The original patch from Richard Weinberger (https://lkml.org/lkml/2011/3/14/362) alters dmesg_restrict as expected, and so the patch seems to have been misapplied. This adds the CAP_SYS_ADMIN check to both dmesg_restrict and kptr_restrict, since both are sensitive. Reported-by: Phillip Lougher <plougher@redhat.com> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: James Morris <james.l.morris@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 4 additions and 4 deletions Inline Diff
kernel/sysctl.c
1 | /* | 1 | /* |
2 | * sysctl.c: General linux system control interface | 2 | * sysctl.c: General linux system control interface |
3 | * | 3 | * |
4 | * Begun 24 March 1995, Stephen Tweedie | 4 | * Begun 24 March 1995, Stephen Tweedie |
5 | * Added /proc support, Dec 1995 | 5 | * Added /proc support, Dec 1995 |
6 | * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. | 6 | * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. |
7 | * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. | 7 | * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. |
8 | * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. | 8 | * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. |
9 | * Dynamic registration fixes, Stephen Tweedie. | 9 | * Dynamic registration fixes, Stephen Tweedie. |
10 | * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. | 10 | * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. |
11 | * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris | 11 | * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris |
12 | * Horn. | 12 | * Horn. |
13 | * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. | 13 | * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. |
14 | * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. | 14 | * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. |
15 | * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill | 15 | * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill |
16 | * Wendling. | 16 | * Wendling. |
17 | * The list_for_each() macro wasn't appropriate for the sysctl loop. | 17 | * The list_for_each() macro wasn't appropriate for the sysctl loop. |
18 | * Removed it and replaced it with older style, 03/23/00, Bill Wendling | 18 | * Removed it and replaced it with older style, 03/23/00, Bill Wendling |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/swap.h> | 23 | #include <linux/swap.h> |
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/printk.h> |
28 | #include <linux/proc_fs.h> | 28 | #include <linux/proc_fs.h> |
29 | #include <linux/security.h> | 29 | #include <linux/security.h> |
30 | #include <linux/ctype.h> | 30 | #include <linux/ctype.h> |
31 | #include <linux/kmemcheck.h> | 31 | #include <linux/kmemcheck.h> |
32 | #include <linux/fs.h> | 32 | #include <linux/fs.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
35 | #include <linux/kobject.h> | 35 | #include <linux/kobject.h> |
36 | #include <linux/net.h> | 36 | #include <linux/net.h> |
37 | #include <linux/sysrq.h> | 37 | #include <linux/sysrq.h> |
38 | #include <linux/highuid.h> | 38 | #include <linux/highuid.h> |
39 | #include <linux/writeback.h> | 39 | #include <linux/writeback.h> |
40 | #include <linux/ratelimit.h> | 40 | #include <linux/ratelimit.h> |
41 | #include <linux/compaction.h> | 41 | #include <linux/compaction.h> |
42 | #include <linux/hugetlb.h> | 42 | #include <linux/hugetlb.h> |
43 | #include <linux/initrd.h> | 43 | #include <linux/initrd.h> |
44 | #include <linux/key.h> | 44 | #include <linux/key.h> |
45 | #include <linux/times.h> | 45 | #include <linux/times.h> |
46 | #include <linux/limits.h> | 46 | #include <linux/limits.h> |
47 | #include <linux/dcache.h> | 47 | #include <linux/dcache.h> |
48 | #include <linux/dnotify.h> | 48 | #include <linux/dnotify.h> |
49 | #include <linux/syscalls.h> | 49 | #include <linux/syscalls.h> |
50 | #include <linux/vmstat.h> | 50 | #include <linux/vmstat.h> |
51 | #include <linux/nfs_fs.h> | 51 | #include <linux/nfs_fs.h> |
52 | #include <linux/acpi.h> | 52 | #include <linux/acpi.h> |
53 | #include <linux/reboot.h> | 53 | #include <linux/reboot.h> |
54 | #include <linux/ftrace.h> | 54 | #include <linux/ftrace.h> |
55 | #include <linux/perf_event.h> | 55 | #include <linux/perf_event.h> |
56 | #include <linux/kprobes.h> | 56 | #include <linux/kprobes.h> |
57 | #include <linux/pipe_fs_i.h> | 57 | #include <linux/pipe_fs_i.h> |
58 | #include <linux/oom.h> | 58 | #include <linux/oom.h> |
59 | #include <linux/kmod.h> | 59 | #include <linux/kmod.h> |
60 | #include <linux/capability.h> | 60 | #include <linux/capability.h> |
61 | 61 | ||
62 | #include <asm/uaccess.h> | 62 | #include <asm/uaccess.h> |
63 | #include <asm/processor.h> | 63 | #include <asm/processor.h> |
64 | 64 | ||
65 | #ifdef CONFIG_X86 | 65 | #ifdef CONFIG_X86 |
66 | #include <asm/nmi.h> | 66 | #include <asm/nmi.h> |
67 | #include <asm/stacktrace.h> | 67 | #include <asm/stacktrace.h> |
68 | #include <asm/io.h> | 68 | #include <asm/io.h> |
69 | #endif | 69 | #endif |
70 | #ifdef CONFIG_BSD_PROCESS_ACCT | 70 | #ifdef CONFIG_BSD_PROCESS_ACCT |
71 | #include <linux/acct.h> | 71 | #include <linux/acct.h> |
72 | #endif | 72 | #endif |
73 | #ifdef CONFIG_RT_MUTEXES | 73 | #ifdef CONFIG_RT_MUTEXES |
74 | #include <linux/rtmutex.h> | 74 | #include <linux/rtmutex.h> |
75 | #endif | 75 | #endif |
76 | #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) | 76 | #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) |
77 | #include <linux/lockdep.h> | 77 | #include <linux/lockdep.h> |
78 | #endif | 78 | #endif |
79 | #ifdef CONFIG_CHR_DEV_SG | 79 | #ifdef CONFIG_CHR_DEV_SG |
80 | #include <scsi/sg.h> | 80 | #include <scsi/sg.h> |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | #ifdef CONFIG_LOCKUP_DETECTOR | 83 | #ifdef CONFIG_LOCKUP_DETECTOR |
84 | #include <linux/nmi.h> | 84 | #include <linux/nmi.h> |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | 87 | ||
88 | #if defined(CONFIG_SYSCTL) | 88 | #if defined(CONFIG_SYSCTL) |
89 | 89 | ||
90 | /* External variables not in a header file. */ | 90 | /* External variables not in a header file. */ |
91 | extern int sysctl_overcommit_memory; | 91 | extern int sysctl_overcommit_memory; |
92 | extern int sysctl_overcommit_ratio; | 92 | extern int sysctl_overcommit_ratio; |
93 | extern int max_threads; | 93 | extern int max_threads; |
94 | extern int core_uses_pid; | 94 | extern int core_uses_pid; |
95 | extern int suid_dumpable; | 95 | extern int suid_dumpable; |
96 | extern char core_pattern[]; | 96 | extern char core_pattern[]; |
97 | extern unsigned int core_pipe_limit; | 97 | extern unsigned int core_pipe_limit; |
98 | extern int pid_max; | 98 | extern int pid_max; |
99 | extern int min_free_kbytes; | 99 | extern int min_free_kbytes; |
100 | extern int pid_max_min, pid_max_max; | 100 | extern int pid_max_min, pid_max_max; |
101 | extern int sysctl_drop_caches; | 101 | extern int sysctl_drop_caches; |
102 | extern int percpu_pagelist_fraction; | 102 | extern int percpu_pagelist_fraction; |
103 | extern int compat_log; | 103 | extern int compat_log; |
104 | extern int latencytop_enabled; | 104 | extern int latencytop_enabled; |
105 | extern int sysctl_nr_open_min, sysctl_nr_open_max; | 105 | extern int sysctl_nr_open_min, sysctl_nr_open_max; |
106 | #ifndef CONFIG_MMU | 106 | #ifndef CONFIG_MMU |
107 | extern int sysctl_nr_trim_pages; | 107 | extern int sysctl_nr_trim_pages; |
108 | #endif | 108 | #endif |
109 | #ifdef CONFIG_BLOCK | 109 | #ifdef CONFIG_BLOCK |
110 | extern int blk_iopoll_enabled; | 110 | extern int blk_iopoll_enabled; |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | /* Constants used for minimum and maximum */ | 113 | /* Constants used for minimum and maximum */ |
114 | #ifdef CONFIG_LOCKUP_DETECTOR | 114 | #ifdef CONFIG_LOCKUP_DETECTOR |
115 | static int sixty = 60; | 115 | static int sixty = 60; |
116 | static int neg_one = -1; | 116 | static int neg_one = -1; |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | static int zero; | 119 | static int zero; |
120 | static int __maybe_unused one = 1; | 120 | static int __maybe_unused one = 1; |
121 | static int __maybe_unused two = 2; | 121 | static int __maybe_unused two = 2; |
122 | static int __maybe_unused three = 3; | 122 | static int __maybe_unused three = 3; |
123 | static unsigned long one_ul = 1; | 123 | static unsigned long one_ul = 1; |
124 | static int one_hundred = 100; | 124 | static int one_hundred = 100; |
125 | #ifdef CONFIG_PRINTK | 125 | #ifdef CONFIG_PRINTK |
126 | static int ten_thousand = 10000; | 126 | static int ten_thousand = 10000; |
127 | #endif | 127 | #endif |
128 | 128 | ||
129 | /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ | 129 | /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ |
130 | static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; | 130 | static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; |
131 | 131 | ||
132 | /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ | 132 | /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ |
133 | static int maxolduid = 65535; | 133 | static int maxolduid = 65535; |
134 | static int minolduid; | 134 | static int minolduid; |
135 | static int min_percpu_pagelist_fract = 8; | 135 | static int min_percpu_pagelist_fract = 8; |
136 | 136 | ||
137 | static int ngroups_max = NGROUPS_MAX; | 137 | static int ngroups_max = NGROUPS_MAX; |
138 | static const int cap_last_cap = CAP_LAST_CAP; | 138 | static const int cap_last_cap = CAP_LAST_CAP; |
139 | 139 | ||
140 | #ifdef CONFIG_INOTIFY_USER | 140 | #ifdef CONFIG_INOTIFY_USER |
141 | #include <linux/inotify.h> | 141 | #include <linux/inotify.h> |
142 | #endif | 142 | #endif |
143 | #ifdef CONFIG_SPARC | 143 | #ifdef CONFIG_SPARC |
144 | #include <asm/system.h> | 144 | #include <asm/system.h> |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | #ifdef CONFIG_SPARC64 | 147 | #ifdef CONFIG_SPARC64 |
148 | extern int sysctl_tsb_ratio; | 148 | extern int sysctl_tsb_ratio; |
149 | #endif | 149 | #endif |
150 | 150 | ||
151 | #ifdef __hppa__ | 151 | #ifdef __hppa__ |
152 | extern int pwrsw_enabled; | 152 | extern int pwrsw_enabled; |
153 | extern int unaligned_enabled; | 153 | extern int unaligned_enabled; |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | #ifdef CONFIG_IA64 | 156 | #ifdef CONFIG_IA64 |
157 | extern int no_unaligned_warning; | 157 | extern int no_unaligned_warning; |
158 | extern int unaligned_dump_stack; | 158 | extern int unaligned_dump_stack; |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | #ifdef CONFIG_PROC_SYSCTL | 161 | #ifdef CONFIG_PROC_SYSCTL |
162 | static int proc_do_cad_pid(struct ctl_table *table, int write, | 162 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
163 | void __user *buffer, size_t *lenp, loff_t *ppos); | 163 | void __user *buffer, size_t *lenp, loff_t *ppos); |
164 | static int proc_taint(struct ctl_table *table, int write, | 164 | static int proc_taint(struct ctl_table *table, int write, |
165 | void __user *buffer, size_t *lenp, loff_t *ppos); | 165 | void __user *buffer, size_t *lenp, loff_t *ppos); |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | #ifdef CONFIG_PRINTK | 168 | #ifdef CONFIG_PRINTK |
169 | static int proc_dmesg_restrict(struct ctl_table *table, int write, | 169 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, |
170 | void __user *buffer, size_t *lenp, loff_t *ppos); | 170 | void __user *buffer, size_t *lenp, loff_t *ppos); |
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | #ifdef CONFIG_MAGIC_SYSRQ | 173 | #ifdef CONFIG_MAGIC_SYSRQ |
174 | /* Note: sysrq code uses it's own private copy */ | 174 | /* Note: sysrq code uses it's own private copy */ |
175 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; | 175 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; |
176 | 176 | ||
177 | static int sysrq_sysctl_handler(ctl_table *table, int write, | 177 | static int sysrq_sysctl_handler(ctl_table *table, int write, |
178 | void __user *buffer, size_t *lenp, | 178 | void __user *buffer, size_t *lenp, |
179 | loff_t *ppos) | 179 | loff_t *ppos) |
180 | { | 180 | { |
181 | int error; | 181 | int error; |
182 | 182 | ||
183 | error = proc_dointvec(table, write, buffer, lenp, ppos); | 183 | error = proc_dointvec(table, write, buffer, lenp, ppos); |
184 | if (error) | 184 | if (error) |
185 | return error; | 185 | return error; |
186 | 186 | ||
187 | if (write) | 187 | if (write) |
188 | sysrq_toggle_support(__sysrq_enabled); | 188 | sysrq_toggle_support(__sysrq_enabled); |
189 | 189 | ||
190 | return 0; | 190 | return 0; |
191 | } | 191 | } |
192 | 192 | ||
193 | #endif | 193 | #endif |
194 | 194 | ||
195 | static struct ctl_table root_table[]; | 195 | static struct ctl_table root_table[]; |
196 | static struct ctl_table_root sysctl_table_root; | 196 | static struct ctl_table_root sysctl_table_root; |
197 | static struct ctl_table_header root_table_header = { | 197 | static struct ctl_table_header root_table_header = { |
198 | {{.count = 1, | 198 | {{.count = 1, |
199 | .ctl_table = root_table, | 199 | .ctl_table = root_table, |
200 | .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}}, | 200 | .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}}, |
201 | .root = &sysctl_table_root, | 201 | .root = &sysctl_table_root, |
202 | .set = &sysctl_table_root.default_set, | 202 | .set = &sysctl_table_root.default_set, |
203 | }; | 203 | }; |
204 | static struct ctl_table_root sysctl_table_root = { | 204 | static struct ctl_table_root sysctl_table_root = { |
205 | .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), | 205 | .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), |
206 | .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), | 206 | .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static struct ctl_table kern_table[]; | 209 | static struct ctl_table kern_table[]; |
210 | static struct ctl_table vm_table[]; | 210 | static struct ctl_table vm_table[]; |
211 | static struct ctl_table fs_table[]; | 211 | static struct ctl_table fs_table[]; |
212 | static struct ctl_table debug_table[]; | 212 | static struct ctl_table debug_table[]; |
213 | static struct ctl_table dev_table[]; | 213 | static struct ctl_table dev_table[]; |
214 | extern struct ctl_table random_table[]; | 214 | extern struct ctl_table random_table[]; |
215 | #ifdef CONFIG_EPOLL | 215 | #ifdef CONFIG_EPOLL |
216 | extern struct ctl_table epoll_table[]; | 216 | extern struct ctl_table epoll_table[]; |
217 | #endif | 217 | #endif |
218 | 218 | ||
219 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT | 219 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
220 | int sysctl_legacy_va_layout; | 220 | int sysctl_legacy_va_layout; |
221 | #endif | 221 | #endif |
222 | 222 | ||
223 | /* The default sysctl tables: */ | 223 | /* The default sysctl tables: */ |
224 | 224 | ||
225 | static struct ctl_table root_table[] = { | 225 | static struct ctl_table root_table[] = { |
226 | { | 226 | { |
227 | .procname = "kernel", | 227 | .procname = "kernel", |
228 | .mode = 0555, | 228 | .mode = 0555, |
229 | .child = kern_table, | 229 | .child = kern_table, |
230 | }, | 230 | }, |
231 | { | 231 | { |
232 | .procname = "vm", | 232 | .procname = "vm", |
233 | .mode = 0555, | 233 | .mode = 0555, |
234 | .child = vm_table, | 234 | .child = vm_table, |
235 | }, | 235 | }, |
236 | { | 236 | { |
237 | .procname = "fs", | 237 | .procname = "fs", |
238 | .mode = 0555, | 238 | .mode = 0555, |
239 | .child = fs_table, | 239 | .child = fs_table, |
240 | }, | 240 | }, |
241 | { | 241 | { |
242 | .procname = "debug", | 242 | .procname = "debug", |
243 | .mode = 0555, | 243 | .mode = 0555, |
244 | .child = debug_table, | 244 | .child = debug_table, |
245 | }, | 245 | }, |
246 | { | 246 | { |
247 | .procname = "dev", | 247 | .procname = "dev", |
248 | .mode = 0555, | 248 | .mode = 0555, |
249 | .child = dev_table, | 249 | .child = dev_table, |
250 | }, | 250 | }, |
251 | { } | 251 | { } |
252 | }; | 252 | }; |
253 | 253 | ||
254 | #ifdef CONFIG_SCHED_DEBUG | 254 | #ifdef CONFIG_SCHED_DEBUG |
255 | static int min_sched_granularity_ns = 100000; /* 100 usecs */ | 255 | static int min_sched_granularity_ns = 100000; /* 100 usecs */ |
256 | static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ | 256 | static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ |
257 | static int min_wakeup_granularity_ns; /* 0 usecs */ | 257 | static int min_wakeup_granularity_ns; /* 0 usecs */ |
258 | static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ | 258 | static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ |
259 | static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; | 259 | static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; |
260 | static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; | 260 | static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; |
261 | #endif | 261 | #endif |
262 | 262 | ||
263 | #ifdef CONFIG_COMPACTION | 263 | #ifdef CONFIG_COMPACTION |
264 | static int min_extfrag_threshold; | 264 | static int min_extfrag_threshold; |
265 | static int max_extfrag_threshold = 1000; | 265 | static int max_extfrag_threshold = 1000; |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | static struct ctl_table kern_table[] = { | 268 | static struct ctl_table kern_table[] = { |
269 | { | 269 | { |
270 | .procname = "sched_child_runs_first", | 270 | .procname = "sched_child_runs_first", |
271 | .data = &sysctl_sched_child_runs_first, | 271 | .data = &sysctl_sched_child_runs_first, |
272 | .maxlen = sizeof(unsigned int), | 272 | .maxlen = sizeof(unsigned int), |
273 | .mode = 0644, | 273 | .mode = 0644, |
274 | .proc_handler = proc_dointvec, | 274 | .proc_handler = proc_dointvec, |
275 | }, | 275 | }, |
276 | #ifdef CONFIG_SCHED_DEBUG | 276 | #ifdef CONFIG_SCHED_DEBUG |
277 | { | 277 | { |
278 | .procname = "sched_min_granularity_ns", | 278 | .procname = "sched_min_granularity_ns", |
279 | .data = &sysctl_sched_min_granularity, | 279 | .data = &sysctl_sched_min_granularity, |
280 | .maxlen = sizeof(unsigned int), | 280 | .maxlen = sizeof(unsigned int), |
281 | .mode = 0644, | 281 | .mode = 0644, |
282 | .proc_handler = sched_proc_update_handler, | 282 | .proc_handler = sched_proc_update_handler, |
283 | .extra1 = &min_sched_granularity_ns, | 283 | .extra1 = &min_sched_granularity_ns, |
284 | .extra2 = &max_sched_granularity_ns, | 284 | .extra2 = &max_sched_granularity_ns, |
285 | }, | 285 | }, |
286 | { | 286 | { |
287 | .procname = "sched_latency_ns", | 287 | .procname = "sched_latency_ns", |
288 | .data = &sysctl_sched_latency, | 288 | .data = &sysctl_sched_latency, |
289 | .maxlen = sizeof(unsigned int), | 289 | .maxlen = sizeof(unsigned int), |
290 | .mode = 0644, | 290 | .mode = 0644, |
291 | .proc_handler = sched_proc_update_handler, | 291 | .proc_handler = sched_proc_update_handler, |
292 | .extra1 = &min_sched_granularity_ns, | 292 | .extra1 = &min_sched_granularity_ns, |
293 | .extra2 = &max_sched_granularity_ns, | 293 | .extra2 = &max_sched_granularity_ns, |
294 | }, | 294 | }, |
295 | { | 295 | { |
296 | .procname = "sched_wakeup_granularity_ns", | 296 | .procname = "sched_wakeup_granularity_ns", |
297 | .data = &sysctl_sched_wakeup_granularity, | 297 | .data = &sysctl_sched_wakeup_granularity, |
298 | .maxlen = sizeof(unsigned int), | 298 | .maxlen = sizeof(unsigned int), |
299 | .mode = 0644, | 299 | .mode = 0644, |
300 | .proc_handler = sched_proc_update_handler, | 300 | .proc_handler = sched_proc_update_handler, |
301 | .extra1 = &min_wakeup_granularity_ns, | 301 | .extra1 = &min_wakeup_granularity_ns, |
302 | .extra2 = &max_wakeup_granularity_ns, | 302 | .extra2 = &max_wakeup_granularity_ns, |
303 | }, | 303 | }, |
304 | { | 304 | { |
305 | .procname = "sched_tunable_scaling", | 305 | .procname = "sched_tunable_scaling", |
306 | .data = &sysctl_sched_tunable_scaling, | 306 | .data = &sysctl_sched_tunable_scaling, |
307 | .maxlen = sizeof(enum sched_tunable_scaling), | 307 | .maxlen = sizeof(enum sched_tunable_scaling), |
308 | .mode = 0644, | 308 | .mode = 0644, |
309 | .proc_handler = sched_proc_update_handler, | 309 | .proc_handler = sched_proc_update_handler, |
310 | .extra1 = &min_sched_tunable_scaling, | 310 | .extra1 = &min_sched_tunable_scaling, |
311 | .extra2 = &max_sched_tunable_scaling, | 311 | .extra2 = &max_sched_tunable_scaling, |
312 | }, | 312 | }, |
313 | { | 313 | { |
314 | .procname = "sched_migration_cost", | 314 | .procname = "sched_migration_cost", |
315 | .data = &sysctl_sched_migration_cost, | 315 | .data = &sysctl_sched_migration_cost, |
316 | .maxlen = sizeof(unsigned int), | 316 | .maxlen = sizeof(unsigned int), |
317 | .mode = 0644, | 317 | .mode = 0644, |
318 | .proc_handler = proc_dointvec, | 318 | .proc_handler = proc_dointvec, |
319 | }, | 319 | }, |
320 | { | 320 | { |
321 | .procname = "sched_nr_migrate", | 321 | .procname = "sched_nr_migrate", |
322 | .data = &sysctl_sched_nr_migrate, | 322 | .data = &sysctl_sched_nr_migrate, |
323 | .maxlen = sizeof(unsigned int), | 323 | .maxlen = sizeof(unsigned int), |
324 | .mode = 0644, | 324 | .mode = 0644, |
325 | .proc_handler = proc_dointvec, | 325 | .proc_handler = proc_dointvec, |
326 | }, | 326 | }, |
327 | { | 327 | { |
328 | .procname = "sched_time_avg", | 328 | .procname = "sched_time_avg", |
329 | .data = &sysctl_sched_time_avg, | 329 | .data = &sysctl_sched_time_avg, |
330 | .maxlen = sizeof(unsigned int), | 330 | .maxlen = sizeof(unsigned int), |
331 | .mode = 0644, | 331 | .mode = 0644, |
332 | .proc_handler = proc_dointvec, | 332 | .proc_handler = proc_dointvec, |
333 | }, | 333 | }, |
334 | { | 334 | { |
335 | .procname = "sched_shares_window", | 335 | .procname = "sched_shares_window", |
336 | .data = &sysctl_sched_shares_window, | 336 | .data = &sysctl_sched_shares_window, |
337 | .maxlen = sizeof(unsigned int), | 337 | .maxlen = sizeof(unsigned int), |
338 | .mode = 0644, | 338 | .mode = 0644, |
339 | .proc_handler = proc_dointvec, | 339 | .proc_handler = proc_dointvec, |
340 | }, | 340 | }, |
341 | { | 341 | { |
342 | .procname = "timer_migration", | 342 | .procname = "timer_migration", |
343 | .data = &sysctl_timer_migration, | 343 | .data = &sysctl_timer_migration, |
344 | .maxlen = sizeof(unsigned int), | 344 | .maxlen = sizeof(unsigned int), |
345 | .mode = 0644, | 345 | .mode = 0644, |
346 | .proc_handler = proc_dointvec_minmax, | 346 | .proc_handler = proc_dointvec_minmax, |
347 | .extra1 = &zero, | 347 | .extra1 = &zero, |
348 | .extra2 = &one, | 348 | .extra2 = &one, |
349 | }, | 349 | }, |
350 | #endif | 350 | #endif |
351 | { | 351 | { |
352 | .procname = "sched_rt_period_us", | 352 | .procname = "sched_rt_period_us", |
353 | .data = &sysctl_sched_rt_period, | 353 | .data = &sysctl_sched_rt_period, |
354 | .maxlen = sizeof(unsigned int), | 354 | .maxlen = sizeof(unsigned int), |
355 | .mode = 0644, | 355 | .mode = 0644, |
356 | .proc_handler = sched_rt_handler, | 356 | .proc_handler = sched_rt_handler, |
357 | }, | 357 | }, |
358 | { | 358 | { |
359 | .procname = "sched_rt_runtime_us", | 359 | .procname = "sched_rt_runtime_us", |
360 | .data = &sysctl_sched_rt_runtime, | 360 | .data = &sysctl_sched_rt_runtime, |
361 | .maxlen = sizeof(int), | 361 | .maxlen = sizeof(int), |
362 | .mode = 0644, | 362 | .mode = 0644, |
363 | .proc_handler = sched_rt_handler, | 363 | .proc_handler = sched_rt_handler, |
364 | }, | 364 | }, |
365 | #ifdef CONFIG_SCHED_AUTOGROUP | 365 | #ifdef CONFIG_SCHED_AUTOGROUP |
366 | { | 366 | { |
367 | .procname = "sched_autogroup_enabled", | 367 | .procname = "sched_autogroup_enabled", |
368 | .data = &sysctl_sched_autogroup_enabled, | 368 | .data = &sysctl_sched_autogroup_enabled, |
369 | .maxlen = sizeof(unsigned int), | 369 | .maxlen = sizeof(unsigned int), |
370 | .mode = 0644, | 370 | .mode = 0644, |
371 | .proc_handler = proc_dointvec_minmax, | 371 | .proc_handler = proc_dointvec_minmax, |
372 | .extra1 = &zero, | 372 | .extra1 = &zero, |
373 | .extra2 = &one, | 373 | .extra2 = &one, |
374 | }, | 374 | }, |
375 | #endif | 375 | #endif |
376 | #ifdef CONFIG_CFS_BANDWIDTH | 376 | #ifdef CONFIG_CFS_BANDWIDTH |
377 | { | 377 | { |
378 | .procname = "sched_cfs_bandwidth_slice_us", | 378 | .procname = "sched_cfs_bandwidth_slice_us", |
379 | .data = &sysctl_sched_cfs_bandwidth_slice, | 379 | .data = &sysctl_sched_cfs_bandwidth_slice, |
380 | .maxlen = sizeof(unsigned int), | 380 | .maxlen = sizeof(unsigned int), |
381 | .mode = 0644, | 381 | .mode = 0644, |
382 | .proc_handler = proc_dointvec_minmax, | 382 | .proc_handler = proc_dointvec_minmax, |
383 | .extra1 = &one, | 383 | .extra1 = &one, |
384 | }, | 384 | }, |
385 | #endif | 385 | #endif |
386 | #ifdef CONFIG_PROVE_LOCKING | 386 | #ifdef CONFIG_PROVE_LOCKING |
387 | { | 387 | { |
388 | .procname = "prove_locking", | 388 | .procname = "prove_locking", |
389 | .data = &prove_locking, | 389 | .data = &prove_locking, |
390 | .maxlen = sizeof(int), | 390 | .maxlen = sizeof(int), |
391 | .mode = 0644, | 391 | .mode = 0644, |
392 | .proc_handler = proc_dointvec, | 392 | .proc_handler = proc_dointvec, |
393 | }, | 393 | }, |
394 | #endif | 394 | #endif |
395 | #ifdef CONFIG_LOCK_STAT | 395 | #ifdef CONFIG_LOCK_STAT |
396 | { | 396 | { |
397 | .procname = "lock_stat", | 397 | .procname = "lock_stat", |
398 | .data = &lock_stat, | 398 | .data = &lock_stat, |
399 | .maxlen = sizeof(int), | 399 | .maxlen = sizeof(int), |
400 | .mode = 0644, | 400 | .mode = 0644, |
401 | .proc_handler = proc_dointvec, | 401 | .proc_handler = proc_dointvec, |
402 | }, | 402 | }, |
403 | #endif | 403 | #endif |
404 | { | 404 | { |
405 | .procname = "panic", | 405 | .procname = "panic", |
406 | .data = &panic_timeout, | 406 | .data = &panic_timeout, |
407 | .maxlen = sizeof(int), | 407 | .maxlen = sizeof(int), |
408 | .mode = 0644, | 408 | .mode = 0644, |
409 | .proc_handler = proc_dointvec, | 409 | .proc_handler = proc_dointvec, |
410 | }, | 410 | }, |
411 | { | 411 | { |
412 | .procname = "core_uses_pid", | 412 | .procname = "core_uses_pid", |
413 | .data = &core_uses_pid, | 413 | .data = &core_uses_pid, |
414 | .maxlen = sizeof(int), | 414 | .maxlen = sizeof(int), |
415 | .mode = 0644, | 415 | .mode = 0644, |
416 | .proc_handler = proc_dointvec, | 416 | .proc_handler = proc_dointvec, |
417 | }, | 417 | }, |
418 | { | 418 | { |
419 | .procname = "core_pattern", | 419 | .procname = "core_pattern", |
420 | .data = core_pattern, | 420 | .data = core_pattern, |
421 | .maxlen = CORENAME_MAX_SIZE, | 421 | .maxlen = CORENAME_MAX_SIZE, |
422 | .mode = 0644, | 422 | .mode = 0644, |
423 | .proc_handler = proc_dostring, | 423 | .proc_handler = proc_dostring, |
424 | }, | 424 | }, |
425 | { | 425 | { |
426 | .procname = "core_pipe_limit", | 426 | .procname = "core_pipe_limit", |
427 | .data = &core_pipe_limit, | 427 | .data = &core_pipe_limit, |
428 | .maxlen = sizeof(unsigned int), | 428 | .maxlen = sizeof(unsigned int), |
429 | .mode = 0644, | 429 | .mode = 0644, |
430 | .proc_handler = proc_dointvec, | 430 | .proc_handler = proc_dointvec, |
431 | }, | 431 | }, |
432 | #ifdef CONFIG_PROC_SYSCTL | 432 | #ifdef CONFIG_PROC_SYSCTL |
433 | { | 433 | { |
434 | .procname = "tainted", | 434 | .procname = "tainted", |
435 | .maxlen = sizeof(long), | 435 | .maxlen = sizeof(long), |
436 | .mode = 0644, | 436 | .mode = 0644, |
437 | .proc_handler = proc_taint, | 437 | .proc_handler = proc_taint, |
438 | }, | 438 | }, |
439 | #endif | 439 | #endif |
440 | #ifdef CONFIG_LATENCYTOP | 440 | #ifdef CONFIG_LATENCYTOP |
441 | { | 441 | { |
442 | .procname = "latencytop", | 442 | .procname = "latencytop", |
443 | .data = &latencytop_enabled, | 443 | .data = &latencytop_enabled, |
444 | .maxlen = sizeof(int), | 444 | .maxlen = sizeof(int), |
445 | .mode = 0644, | 445 | .mode = 0644, |
446 | .proc_handler = proc_dointvec, | 446 | .proc_handler = proc_dointvec, |
447 | }, | 447 | }, |
448 | #endif | 448 | #endif |
449 | #ifdef CONFIG_BLK_DEV_INITRD | 449 | #ifdef CONFIG_BLK_DEV_INITRD |
450 | { | 450 | { |
451 | .procname = "real-root-dev", | 451 | .procname = "real-root-dev", |
452 | .data = &real_root_dev, | 452 | .data = &real_root_dev, |
453 | .maxlen = sizeof(int), | 453 | .maxlen = sizeof(int), |
454 | .mode = 0644, | 454 | .mode = 0644, |
455 | .proc_handler = proc_dointvec, | 455 | .proc_handler = proc_dointvec, |
456 | }, | 456 | }, |
457 | #endif | 457 | #endif |
458 | { | 458 | { |
459 | .procname = "print-fatal-signals", | 459 | .procname = "print-fatal-signals", |
460 | .data = &print_fatal_signals, | 460 | .data = &print_fatal_signals, |
461 | .maxlen = sizeof(int), | 461 | .maxlen = sizeof(int), |
462 | .mode = 0644, | 462 | .mode = 0644, |
463 | .proc_handler = proc_dointvec, | 463 | .proc_handler = proc_dointvec, |
464 | }, | 464 | }, |
465 | #ifdef CONFIG_SPARC | 465 | #ifdef CONFIG_SPARC |
466 | { | 466 | { |
467 | .procname = "reboot-cmd", | 467 | .procname = "reboot-cmd", |
468 | .data = reboot_command, | 468 | .data = reboot_command, |
469 | .maxlen = 256, | 469 | .maxlen = 256, |
470 | .mode = 0644, | 470 | .mode = 0644, |
471 | .proc_handler = proc_dostring, | 471 | .proc_handler = proc_dostring, |
472 | }, | 472 | }, |
473 | { | 473 | { |
474 | .procname = "stop-a", | 474 | .procname = "stop-a", |
475 | .data = &stop_a_enabled, | 475 | .data = &stop_a_enabled, |
476 | .maxlen = sizeof (int), | 476 | .maxlen = sizeof (int), |
477 | .mode = 0644, | 477 | .mode = 0644, |
478 | .proc_handler = proc_dointvec, | 478 | .proc_handler = proc_dointvec, |
479 | }, | 479 | }, |
480 | { | 480 | { |
481 | .procname = "scons-poweroff", | 481 | .procname = "scons-poweroff", |
482 | .data = &scons_pwroff, | 482 | .data = &scons_pwroff, |
483 | .maxlen = sizeof (int), | 483 | .maxlen = sizeof (int), |
484 | .mode = 0644, | 484 | .mode = 0644, |
485 | .proc_handler = proc_dointvec, | 485 | .proc_handler = proc_dointvec, |
486 | }, | 486 | }, |
487 | #endif | 487 | #endif |
488 | #ifdef CONFIG_SPARC64 | 488 | #ifdef CONFIG_SPARC64 |
489 | { | 489 | { |
490 | .procname = "tsb-ratio", | 490 | .procname = "tsb-ratio", |
491 | .data = &sysctl_tsb_ratio, | 491 | .data = &sysctl_tsb_ratio, |
492 | .maxlen = sizeof (int), | 492 | .maxlen = sizeof (int), |
493 | .mode = 0644, | 493 | .mode = 0644, |
494 | .proc_handler = proc_dointvec, | 494 | .proc_handler = proc_dointvec, |
495 | }, | 495 | }, |
496 | #endif | 496 | #endif |
497 | #ifdef __hppa__ | 497 | #ifdef __hppa__ |
498 | { | 498 | { |
499 | .procname = "soft-power", | 499 | .procname = "soft-power", |
500 | .data = &pwrsw_enabled, | 500 | .data = &pwrsw_enabled, |
501 | .maxlen = sizeof (int), | 501 | .maxlen = sizeof (int), |
502 | .mode = 0644, | 502 | .mode = 0644, |
503 | .proc_handler = proc_dointvec, | 503 | .proc_handler = proc_dointvec, |
504 | }, | 504 | }, |
505 | { | 505 | { |
506 | .procname = "unaligned-trap", | 506 | .procname = "unaligned-trap", |
507 | .data = &unaligned_enabled, | 507 | .data = &unaligned_enabled, |
508 | .maxlen = sizeof (int), | 508 | .maxlen = sizeof (int), |
509 | .mode = 0644, | 509 | .mode = 0644, |
510 | .proc_handler = proc_dointvec, | 510 | .proc_handler = proc_dointvec, |
511 | }, | 511 | }, |
512 | #endif | 512 | #endif |
513 | { | 513 | { |
514 | .procname = "ctrl-alt-del", | 514 | .procname = "ctrl-alt-del", |
515 | .data = &C_A_D, | 515 | .data = &C_A_D, |
516 | .maxlen = sizeof(int), | 516 | .maxlen = sizeof(int), |
517 | .mode = 0644, | 517 | .mode = 0644, |
518 | .proc_handler = proc_dointvec, | 518 | .proc_handler = proc_dointvec, |
519 | }, | 519 | }, |
520 | #ifdef CONFIG_FUNCTION_TRACER | 520 | #ifdef CONFIG_FUNCTION_TRACER |
521 | { | 521 | { |
522 | .procname = "ftrace_enabled", | 522 | .procname = "ftrace_enabled", |
523 | .data = &ftrace_enabled, | 523 | .data = &ftrace_enabled, |
524 | .maxlen = sizeof(int), | 524 | .maxlen = sizeof(int), |
525 | .mode = 0644, | 525 | .mode = 0644, |
526 | .proc_handler = ftrace_enable_sysctl, | 526 | .proc_handler = ftrace_enable_sysctl, |
527 | }, | 527 | }, |
528 | #endif | 528 | #endif |
529 | #ifdef CONFIG_STACK_TRACER | 529 | #ifdef CONFIG_STACK_TRACER |
530 | { | 530 | { |
531 | .procname = "stack_tracer_enabled", | 531 | .procname = "stack_tracer_enabled", |
532 | .data = &stack_tracer_enabled, | 532 | .data = &stack_tracer_enabled, |
533 | .maxlen = sizeof(int), | 533 | .maxlen = sizeof(int), |
534 | .mode = 0644, | 534 | .mode = 0644, |
535 | .proc_handler = stack_trace_sysctl, | 535 | .proc_handler = stack_trace_sysctl, |
536 | }, | 536 | }, |
537 | #endif | 537 | #endif |
538 | #ifdef CONFIG_TRACING | 538 | #ifdef CONFIG_TRACING |
539 | { | 539 | { |
540 | .procname = "ftrace_dump_on_oops", | 540 | .procname = "ftrace_dump_on_oops", |
541 | .data = &ftrace_dump_on_oops, | 541 | .data = &ftrace_dump_on_oops, |
542 | .maxlen = sizeof(int), | 542 | .maxlen = sizeof(int), |
543 | .mode = 0644, | 543 | .mode = 0644, |
544 | .proc_handler = proc_dointvec, | 544 | .proc_handler = proc_dointvec, |
545 | }, | 545 | }, |
546 | #endif | 546 | #endif |
547 | #ifdef CONFIG_MODULES | 547 | #ifdef CONFIG_MODULES |
548 | { | 548 | { |
549 | .procname = "modprobe", | 549 | .procname = "modprobe", |
550 | .data = &modprobe_path, | 550 | .data = &modprobe_path, |
551 | .maxlen = KMOD_PATH_LEN, | 551 | .maxlen = KMOD_PATH_LEN, |
552 | .mode = 0644, | 552 | .mode = 0644, |
553 | .proc_handler = proc_dostring, | 553 | .proc_handler = proc_dostring, |
554 | }, | 554 | }, |
555 | { | 555 | { |
556 | .procname = "modules_disabled", | 556 | .procname = "modules_disabled", |
557 | .data = &modules_disabled, | 557 | .data = &modules_disabled, |
558 | .maxlen = sizeof(int), | 558 | .maxlen = sizeof(int), |
559 | .mode = 0644, | 559 | .mode = 0644, |
560 | /* only handle a transition from default "0" to "1" */ | 560 | /* only handle a transition from default "0" to "1" */ |
561 | .proc_handler = proc_dointvec_minmax, | 561 | .proc_handler = proc_dointvec_minmax, |
562 | .extra1 = &one, | 562 | .extra1 = &one, |
563 | .extra2 = &one, | 563 | .extra2 = &one, |
564 | }, | 564 | }, |
565 | #endif | 565 | #endif |
566 | #ifdef CONFIG_HOTPLUG | 566 | #ifdef CONFIG_HOTPLUG |
567 | { | 567 | { |
568 | .procname = "hotplug", | 568 | .procname = "hotplug", |
569 | .data = &uevent_helper, | 569 | .data = &uevent_helper, |
570 | .maxlen = UEVENT_HELPER_PATH_LEN, | 570 | .maxlen = UEVENT_HELPER_PATH_LEN, |
571 | .mode = 0644, | 571 | .mode = 0644, |
572 | .proc_handler = proc_dostring, | 572 | .proc_handler = proc_dostring, |
573 | }, | 573 | }, |
574 | #endif | 574 | #endif |
575 | #ifdef CONFIG_CHR_DEV_SG | 575 | #ifdef CONFIG_CHR_DEV_SG |
576 | { | 576 | { |
577 | .procname = "sg-big-buff", | 577 | .procname = "sg-big-buff", |
578 | .data = &sg_big_buff, | 578 | .data = &sg_big_buff, |
579 | .maxlen = sizeof (int), | 579 | .maxlen = sizeof (int), |
580 | .mode = 0444, | 580 | .mode = 0444, |
581 | .proc_handler = proc_dointvec, | 581 | .proc_handler = proc_dointvec, |
582 | }, | 582 | }, |
583 | #endif | 583 | #endif |
584 | #ifdef CONFIG_BSD_PROCESS_ACCT | 584 | #ifdef CONFIG_BSD_PROCESS_ACCT |
585 | { | 585 | { |
586 | .procname = "acct", | 586 | .procname = "acct", |
587 | .data = &acct_parm, | 587 | .data = &acct_parm, |
588 | .maxlen = 3*sizeof(int), | 588 | .maxlen = 3*sizeof(int), |
589 | .mode = 0644, | 589 | .mode = 0644, |
590 | .proc_handler = proc_dointvec, | 590 | .proc_handler = proc_dointvec, |
591 | }, | 591 | }, |
592 | #endif | 592 | #endif |
593 | #ifdef CONFIG_MAGIC_SYSRQ | 593 | #ifdef CONFIG_MAGIC_SYSRQ |
594 | { | 594 | { |
595 | .procname = "sysrq", | 595 | .procname = "sysrq", |
596 | .data = &__sysrq_enabled, | 596 | .data = &__sysrq_enabled, |
597 | .maxlen = sizeof (int), | 597 | .maxlen = sizeof (int), |
598 | .mode = 0644, | 598 | .mode = 0644, |
599 | .proc_handler = sysrq_sysctl_handler, | 599 | .proc_handler = sysrq_sysctl_handler, |
600 | }, | 600 | }, |
601 | #endif | 601 | #endif |
602 | #ifdef CONFIG_PROC_SYSCTL | 602 | #ifdef CONFIG_PROC_SYSCTL |
603 | { | 603 | { |
604 | .procname = "cad_pid", | 604 | .procname = "cad_pid", |
605 | .data = NULL, | 605 | .data = NULL, |
606 | .maxlen = sizeof (int), | 606 | .maxlen = sizeof (int), |
607 | .mode = 0600, | 607 | .mode = 0600, |
608 | .proc_handler = proc_do_cad_pid, | 608 | .proc_handler = proc_do_cad_pid, |
609 | }, | 609 | }, |
610 | #endif | 610 | #endif |
611 | { | 611 | { |
612 | .procname = "threads-max", | 612 | .procname = "threads-max", |
613 | .data = &max_threads, | 613 | .data = &max_threads, |
614 | .maxlen = sizeof(int), | 614 | .maxlen = sizeof(int), |
615 | .mode = 0644, | 615 | .mode = 0644, |
616 | .proc_handler = proc_dointvec, | 616 | .proc_handler = proc_dointvec, |
617 | }, | 617 | }, |
618 | { | 618 | { |
619 | .procname = "random", | 619 | .procname = "random", |
620 | .mode = 0555, | 620 | .mode = 0555, |
621 | .child = random_table, | 621 | .child = random_table, |
622 | }, | 622 | }, |
623 | { | 623 | { |
624 | .procname = "usermodehelper", | 624 | .procname = "usermodehelper", |
625 | .mode = 0555, | 625 | .mode = 0555, |
626 | .child = usermodehelper_table, | 626 | .child = usermodehelper_table, |
627 | }, | 627 | }, |
628 | { | 628 | { |
629 | .procname = "overflowuid", | 629 | .procname = "overflowuid", |
630 | .data = &overflowuid, | 630 | .data = &overflowuid, |
631 | .maxlen = sizeof(int), | 631 | .maxlen = sizeof(int), |
632 | .mode = 0644, | 632 | .mode = 0644, |
633 | .proc_handler = proc_dointvec_minmax, | 633 | .proc_handler = proc_dointvec_minmax, |
634 | .extra1 = &minolduid, | 634 | .extra1 = &minolduid, |
635 | .extra2 = &maxolduid, | 635 | .extra2 = &maxolduid, |
636 | }, | 636 | }, |
637 | { | 637 | { |
638 | .procname = "overflowgid", | 638 | .procname = "overflowgid", |
639 | .data = &overflowgid, | 639 | .data = &overflowgid, |
640 | .maxlen = sizeof(int), | 640 | .maxlen = sizeof(int), |
641 | .mode = 0644, | 641 | .mode = 0644, |
642 | .proc_handler = proc_dointvec_minmax, | 642 | .proc_handler = proc_dointvec_minmax, |
643 | .extra1 = &minolduid, | 643 | .extra1 = &minolduid, |
644 | .extra2 = &maxolduid, | 644 | .extra2 = &maxolduid, |
645 | }, | 645 | }, |
646 | #ifdef CONFIG_S390 | 646 | #ifdef CONFIG_S390 |
647 | #ifdef CONFIG_MATHEMU | 647 | #ifdef CONFIG_MATHEMU |
648 | { | 648 | { |
649 | .procname = "ieee_emulation_warnings", | 649 | .procname = "ieee_emulation_warnings", |
650 | .data = &sysctl_ieee_emulation_warnings, | 650 | .data = &sysctl_ieee_emulation_warnings, |
651 | .maxlen = sizeof(int), | 651 | .maxlen = sizeof(int), |
652 | .mode = 0644, | 652 | .mode = 0644, |
653 | .proc_handler = proc_dointvec, | 653 | .proc_handler = proc_dointvec, |
654 | }, | 654 | }, |
655 | #endif | 655 | #endif |
656 | { | 656 | { |
657 | .procname = "userprocess_debug", | 657 | .procname = "userprocess_debug", |
658 | .data = &show_unhandled_signals, | 658 | .data = &show_unhandled_signals, |
659 | .maxlen = sizeof(int), | 659 | .maxlen = sizeof(int), |
660 | .mode = 0644, | 660 | .mode = 0644, |
661 | .proc_handler = proc_dointvec, | 661 | .proc_handler = proc_dointvec, |
662 | }, | 662 | }, |
663 | #endif | 663 | #endif |
664 | { | 664 | { |
665 | .procname = "pid_max", | 665 | .procname = "pid_max", |
666 | .data = &pid_max, | 666 | .data = &pid_max, |
667 | .maxlen = sizeof (int), | 667 | .maxlen = sizeof (int), |
668 | .mode = 0644, | 668 | .mode = 0644, |
669 | .proc_handler = proc_dointvec_minmax, | 669 | .proc_handler = proc_dointvec_minmax, |
670 | .extra1 = &pid_max_min, | 670 | .extra1 = &pid_max_min, |
671 | .extra2 = &pid_max_max, | 671 | .extra2 = &pid_max_max, |
672 | }, | 672 | }, |
673 | { | 673 | { |
674 | .procname = "panic_on_oops", | 674 | .procname = "panic_on_oops", |
675 | .data = &panic_on_oops, | 675 | .data = &panic_on_oops, |
676 | .maxlen = sizeof(int), | 676 | .maxlen = sizeof(int), |
677 | .mode = 0644, | 677 | .mode = 0644, |
678 | .proc_handler = proc_dointvec, | 678 | .proc_handler = proc_dointvec, |
679 | }, | 679 | }, |
680 | #if defined CONFIG_PRINTK | 680 | #if defined CONFIG_PRINTK |
681 | { | 681 | { |
682 | .procname = "printk", | 682 | .procname = "printk", |
683 | .data = &console_loglevel, | 683 | .data = &console_loglevel, |
684 | .maxlen = 4*sizeof(int), | 684 | .maxlen = 4*sizeof(int), |
685 | .mode = 0644, | 685 | .mode = 0644, |
686 | .proc_handler = proc_dointvec, | 686 | .proc_handler = proc_dointvec, |
687 | }, | 687 | }, |
688 | { | 688 | { |
689 | .procname = "printk_ratelimit", | 689 | .procname = "printk_ratelimit", |
690 | .data = &printk_ratelimit_state.interval, | 690 | .data = &printk_ratelimit_state.interval, |
691 | .maxlen = sizeof(int), | 691 | .maxlen = sizeof(int), |
692 | .mode = 0644, | 692 | .mode = 0644, |
693 | .proc_handler = proc_dointvec_jiffies, | 693 | .proc_handler = proc_dointvec_jiffies, |
694 | }, | 694 | }, |
695 | { | 695 | { |
696 | .procname = "printk_ratelimit_burst", | 696 | .procname = "printk_ratelimit_burst", |
697 | .data = &printk_ratelimit_state.burst, | 697 | .data = &printk_ratelimit_state.burst, |
698 | .maxlen = sizeof(int), | 698 | .maxlen = sizeof(int), |
699 | .mode = 0644, | 699 | .mode = 0644, |
700 | .proc_handler = proc_dointvec, | 700 | .proc_handler = proc_dointvec, |
701 | }, | 701 | }, |
702 | { | 702 | { |
703 | .procname = "printk_delay", | 703 | .procname = "printk_delay", |
704 | .data = &printk_delay_msec, | 704 | .data = &printk_delay_msec, |
705 | .maxlen = sizeof(int), | 705 | .maxlen = sizeof(int), |
706 | .mode = 0644, | 706 | .mode = 0644, |
707 | .proc_handler = proc_dointvec_minmax, | 707 | .proc_handler = proc_dointvec_minmax, |
708 | .extra1 = &zero, | 708 | .extra1 = &zero, |
709 | .extra2 = &ten_thousand, | 709 | .extra2 = &ten_thousand, |
710 | }, | 710 | }, |
711 | { | 711 | { |
712 | .procname = "dmesg_restrict", | 712 | .procname = "dmesg_restrict", |
713 | .data = &dmesg_restrict, | 713 | .data = &dmesg_restrict, |
714 | .maxlen = sizeof(int), | 714 | .maxlen = sizeof(int), |
715 | .mode = 0644, | 715 | .mode = 0644, |
716 | .proc_handler = proc_dointvec_minmax, | 716 | .proc_handler = proc_dointvec_minmax_sysadmin, |
717 | .extra1 = &zero, | 717 | .extra1 = &zero, |
718 | .extra2 = &one, | 718 | .extra2 = &one, |
719 | }, | 719 | }, |
720 | { | 720 | { |
721 | .procname = "kptr_restrict", | 721 | .procname = "kptr_restrict", |
722 | .data = &kptr_restrict, | 722 | .data = &kptr_restrict, |
723 | .maxlen = sizeof(int), | 723 | .maxlen = sizeof(int), |
724 | .mode = 0644, | 724 | .mode = 0644, |
725 | .proc_handler = proc_dmesg_restrict, | 725 | .proc_handler = proc_dointvec_minmax_sysadmin, |
726 | .extra1 = &zero, | 726 | .extra1 = &zero, |
727 | .extra2 = &two, | 727 | .extra2 = &two, |
728 | }, | 728 | }, |
729 | #endif | 729 | #endif |
730 | { | 730 | { |
731 | .procname = "ngroups_max", | 731 | .procname = "ngroups_max", |
732 | .data = &ngroups_max, | 732 | .data = &ngroups_max, |
733 | .maxlen = sizeof (int), | 733 | .maxlen = sizeof (int), |
734 | .mode = 0444, | 734 | .mode = 0444, |
735 | .proc_handler = proc_dointvec, | 735 | .proc_handler = proc_dointvec, |
736 | }, | 736 | }, |
737 | { | 737 | { |
738 | .procname = "cap_last_cap", | 738 | .procname = "cap_last_cap", |
739 | .data = (void *)&cap_last_cap, | 739 | .data = (void *)&cap_last_cap, |
740 | .maxlen = sizeof(int), | 740 | .maxlen = sizeof(int), |
741 | .mode = 0444, | 741 | .mode = 0444, |
742 | .proc_handler = proc_dointvec, | 742 | .proc_handler = proc_dointvec, |
743 | }, | 743 | }, |
744 | #if defined(CONFIG_LOCKUP_DETECTOR) | 744 | #if defined(CONFIG_LOCKUP_DETECTOR) |
745 | { | 745 | { |
746 | .procname = "watchdog", | 746 | .procname = "watchdog", |
747 | .data = &watchdog_enabled, | 747 | .data = &watchdog_enabled, |
748 | .maxlen = sizeof (int), | 748 | .maxlen = sizeof (int), |
749 | .mode = 0644, | 749 | .mode = 0644, |
750 | .proc_handler = proc_dowatchdog, | 750 | .proc_handler = proc_dowatchdog, |
751 | .extra1 = &zero, | 751 | .extra1 = &zero, |
752 | .extra2 = &one, | 752 | .extra2 = &one, |
753 | }, | 753 | }, |
754 | { | 754 | { |
755 | .procname = "watchdog_thresh", | 755 | .procname = "watchdog_thresh", |
756 | .data = &watchdog_thresh, | 756 | .data = &watchdog_thresh, |
757 | .maxlen = sizeof(int), | 757 | .maxlen = sizeof(int), |
758 | .mode = 0644, | 758 | .mode = 0644, |
759 | .proc_handler = proc_dowatchdog, | 759 | .proc_handler = proc_dowatchdog, |
760 | .extra1 = &neg_one, | 760 | .extra1 = &neg_one, |
761 | .extra2 = &sixty, | 761 | .extra2 = &sixty, |
762 | }, | 762 | }, |
763 | { | 763 | { |
764 | .procname = "softlockup_panic", | 764 | .procname = "softlockup_panic", |
765 | .data = &softlockup_panic, | 765 | .data = &softlockup_panic, |
766 | .maxlen = sizeof(int), | 766 | .maxlen = sizeof(int), |
767 | .mode = 0644, | 767 | .mode = 0644, |
768 | .proc_handler = proc_dointvec_minmax, | 768 | .proc_handler = proc_dointvec_minmax, |
769 | .extra1 = &zero, | 769 | .extra1 = &zero, |
770 | .extra2 = &one, | 770 | .extra2 = &one, |
771 | }, | 771 | }, |
772 | { | 772 | { |
773 | .procname = "nmi_watchdog", | 773 | .procname = "nmi_watchdog", |
774 | .data = &watchdog_enabled, | 774 | .data = &watchdog_enabled, |
775 | .maxlen = sizeof (int), | 775 | .maxlen = sizeof (int), |
776 | .mode = 0644, | 776 | .mode = 0644, |
777 | .proc_handler = proc_dowatchdog, | 777 | .proc_handler = proc_dowatchdog, |
778 | .extra1 = &zero, | 778 | .extra1 = &zero, |
779 | .extra2 = &one, | 779 | .extra2 = &one, |
780 | }, | 780 | }, |
781 | #endif | 781 | #endif |
782 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) | 782 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) |
783 | { | 783 | { |
784 | .procname = "unknown_nmi_panic", | 784 | .procname = "unknown_nmi_panic", |
785 | .data = &unknown_nmi_panic, | 785 | .data = &unknown_nmi_panic, |
786 | .maxlen = sizeof (int), | 786 | .maxlen = sizeof (int), |
787 | .mode = 0644, | 787 | .mode = 0644, |
788 | .proc_handler = proc_dointvec, | 788 | .proc_handler = proc_dointvec, |
789 | }, | 789 | }, |
790 | #endif | 790 | #endif |
791 | #if defined(CONFIG_X86) | 791 | #if defined(CONFIG_X86) |
792 | { | 792 | { |
793 | .procname = "panic_on_unrecovered_nmi", | 793 | .procname = "panic_on_unrecovered_nmi", |
794 | .data = &panic_on_unrecovered_nmi, | 794 | .data = &panic_on_unrecovered_nmi, |
795 | .maxlen = sizeof(int), | 795 | .maxlen = sizeof(int), |
796 | .mode = 0644, | 796 | .mode = 0644, |
797 | .proc_handler = proc_dointvec, | 797 | .proc_handler = proc_dointvec, |
798 | }, | 798 | }, |
799 | { | 799 | { |
800 | .procname = "panic_on_io_nmi", | 800 | .procname = "panic_on_io_nmi", |
801 | .data = &panic_on_io_nmi, | 801 | .data = &panic_on_io_nmi, |
802 | .maxlen = sizeof(int), | 802 | .maxlen = sizeof(int), |
803 | .mode = 0644, | 803 | .mode = 0644, |
804 | .proc_handler = proc_dointvec, | 804 | .proc_handler = proc_dointvec, |
805 | }, | 805 | }, |
806 | #ifdef CONFIG_DEBUG_STACKOVERFLOW | 806 | #ifdef CONFIG_DEBUG_STACKOVERFLOW |
807 | { | 807 | { |
808 | .procname = "panic_on_stackoverflow", | 808 | .procname = "panic_on_stackoverflow", |
809 | .data = &sysctl_panic_on_stackoverflow, | 809 | .data = &sysctl_panic_on_stackoverflow, |
810 | .maxlen = sizeof(int), | 810 | .maxlen = sizeof(int), |
811 | .mode = 0644, | 811 | .mode = 0644, |
812 | .proc_handler = proc_dointvec, | 812 | .proc_handler = proc_dointvec, |
813 | }, | 813 | }, |
814 | #endif | 814 | #endif |
815 | { | 815 | { |
816 | .procname = "bootloader_type", | 816 | .procname = "bootloader_type", |
817 | .data = &bootloader_type, | 817 | .data = &bootloader_type, |
818 | .maxlen = sizeof (int), | 818 | .maxlen = sizeof (int), |
819 | .mode = 0444, | 819 | .mode = 0444, |
820 | .proc_handler = proc_dointvec, | 820 | .proc_handler = proc_dointvec, |
821 | }, | 821 | }, |
822 | { | 822 | { |
823 | .procname = "bootloader_version", | 823 | .procname = "bootloader_version", |
824 | .data = &bootloader_version, | 824 | .data = &bootloader_version, |
825 | .maxlen = sizeof (int), | 825 | .maxlen = sizeof (int), |
826 | .mode = 0444, | 826 | .mode = 0444, |
827 | .proc_handler = proc_dointvec, | 827 | .proc_handler = proc_dointvec, |
828 | }, | 828 | }, |
829 | { | 829 | { |
830 | .procname = "kstack_depth_to_print", | 830 | .procname = "kstack_depth_to_print", |
831 | .data = &kstack_depth_to_print, | 831 | .data = &kstack_depth_to_print, |
832 | .maxlen = sizeof(int), | 832 | .maxlen = sizeof(int), |
833 | .mode = 0644, | 833 | .mode = 0644, |
834 | .proc_handler = proc_dointvec, | 834 | .proc_handler = proc_dointvec, |
835 | }, | 835 | }, |
836 | { | 836 | { |
837 | .procname = "io_delay_type", | 837 | .procname = "io_delay_type", |
838 | .data = &io_delay_type, | 838 | .data = &io_delay_type, |
839 | .maxlen = sizeof(int), | 839 | .maxlen = sizeof(int), |
840 | .mode = 0644, | 840 | .mode = 0644, |
841 | .proc_handler = proc_dointvec, | 841 | .proc_handler = proc_dointvec, |
842 | }, | 842 | }, |
843 | #endif | 843 | #endif |
844 | #if defined(CONFIG_MMU) | 844 | #if defined(CONFIG_MMU) |
845 | { | 845 | { |
846 | .procname = "randomize_va_space", | 846 | .procname = "randomize_va_space", |
847 | .data = &randomize_va_space, | 847 | .data = &randomize_va_space, |
848 | .maxlen = sizeof(int), | 848 | .maxlen = sizeof(int), |
849 | .mode = 0644, | 849 | .mode = 0644, |
850 | .proc_handler = proc_dointvec, | 850 | .proc_handler = proc_dointvec, |
851 | }, | 851 | }, |
852 | #endif | 852 | #endif |
853 | #if defined(CONFIG_S390) && defined(CONFIG_SMP) | 853 | #if defined(CONFIG_S390) && defined(CONFIG_SMP) |
854 | { | 854 | { |
855 | .procname = "spin_retry", | 855 | .procname = "spin_retry", |
856 | .data = &spin_retry, | 856 | .data = &spin_retry, |
857 | .maxlen = sizeof (int), | 857 | .maxlen = sizeof (int), |
858 | .mode = 0644, | 858 | .mode = 0644, |
859 | .proc_handler = proc_dointvec, | 859 | .proc_handler = proc_dointvec, |
860 | }, | 860 | }, |
861 | #endif | 861 | #endif |
862 | #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) | 862 | #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) |
863 | { | 863 | { |
864 | .procname = "acpi_video_flags", | 864 | .procname = "acpi_video_flags", |
865 | .data = &acpi_realmode_flags, | 865 | .data = &acpi_realmode_flags, |
866 | .maxlen = sizeof (unsigned long), | 866 | .maxlen = sizeof (unsigned long), |
867 | .mode = 0644, | 867 | .mode = 0644, |
868 | .proc_handler = proc_doulongvec_minmax, | 868 | .proc_handler = proc_doulongvec_minmax, |
869 | }, | 869 | }, |
870 | #endif | 870 | #endif |
871 | #ifdef CONFIG_IA64 | 871 | #ifdef CONFIG_IA64 |
872 | { | 872 | { |
873 | .procname = "ignore-unaligned-usertrap", | 873 | .procname = "ignore-unaligned-usertrap", |
874 | .data = &no_unaligned_warning, | 874 | .data = &no_unaligned_warning, |
875 | .maxlen = sizeof (int), | 875 | .maxlen = sizeof (int), |
876 | .mode = 0644, | 876 | .mode = 0644, |
877 | .proc_handler = proc_dointvec, | 877 | .proc_handler = proc_dointvec, |
878 | }, | 878 | }, |
879 | { | 879 | { |
880 | .procname = "unaligned-dump-stack", | 880 | .procname = "unaligned-dump-stack", |
881 | .data = &unaligned_dump_stack, | 881 | .data = &unaligned_dump_stack, |
882 | .maxlen = sizeof (int), | 882 | .maxlen = sizeof (int), |
883 | .mode = 0644, | 883 | .mode = 0644, |
884 | .proc_handler = proc_dointvec, | 884 | .proc_handler = proc_dointvec, |
885 | }, | 885 | }, |
886 | #endif | 886 | #endif |
887 | #ifdef CONFIG_DETECT_HUNG_TASK | 887 | #ifdef CONFIG_DETECT_HUNG_TASK |
888 | { | 888 | { |
889 | .procname = "hung_task_panic", | 889 | .procname = "hung_task_panic", |
890 | .data = &sysctl_hung_task_panic, | 890 | .data = &sysctl_hung_task_panic, |
891 | .maxlen = sizeof(int), | 891 | .maxlen = sizeof(int), |
892 | .mode = 0644, | 892 | .mode = 0644, |
893 | .proc_handler = proc_dointvec_minmax, | 893 | .proc_handler = proc_dointvec_minmax, |
894 | .extra1 = &zero, | 894 | .extra1 = &zero, |
895 | .extra2 = &one, | 895 | .extra2 = &one, |
896 | }, | 896 | }, |
897 | { | 897 | { |
898 | .procname = "hung_task_check_count", | 898 | .procname = "hung_task_check_count", |
899 | .data = &sysctl_hung_task_check_count, | 899 | .data = &sysctl_hung_task_check_count, |
900 | .maxlen = sizeof(unsigned long), | 900 | .maxlen = sizeof(unsigned long), |
901 | .mode = 0644, | 901 | .mode = 0644, |
902 | .proc_handler = proc_doulongvec_minmax, | 902 | .proc_handler = proc_doulongvec_minmax, |
903 | }, | 903 | }, |
904 | { | 904 | { |
905 | .procname = "hung_task_timeout_secs", | 905 | .procname = "hung_task_timeout_secs", |
906 | .data = &sysctl_hung_task_timeout_secs, | 906 | .data = &sysctl_hung_task_timeout_secs, |
907 | .maxlen = sizeof(unsigned long), | 907 | .maxlen = sizeof(unsigned long), |
908 | .mode = 0644, | 908 | .mode = 0644, |
909 | .proc_handler = proc_dohung_task_timeout_secs, | 909 | .proc_handler = proc_dohung_task_timeout_secs, |
910 | }, | 910 | }, |
911 | { | 911 | { |
912 | .procname = "hung_task_warnings", | 912 | .procname = "hung_task_warnings", |
913 | .data = &sysctl_hung_task_warnings, | 913 | .data = &sysctl_hung_task_warnings, |
914 | .maxlen = sizeof(unsigned long), | 914 | .maxlen = sizeof(unsigned long), |
915 | .mode = 0644, | 915 | .mode = 0644, |
916 | .proc_handler = proc_doulongvec_minmax, | 916 | .proc_handler = proc_doulongvec_minmax, |
917 | }, | 917 | }, |
918 | #endif | 918 | #endif |
919 | #ifdef CONFIG_COMPAT | 919 | #ifdef CONFIG_COMPAT |
920 | { | 920 | { |
921 | .procname = "compat-log", | 921 | .procname = "compat-log", |
922 | .data = &compat_log, | 922 | .data = &compat_log, |
923 | .maxlen = sizeof (int), | 923 | .maxlen = sizeof (int), |
924 | .mode = 0644, | 924 | .mode = 0644, |
925 | .proc_handler = proc_dointvec, | 925 | .proc_handler = proc_dointvec, |
926 | }, | 926 | }, |
927 | #endif | 927 | #endif |
928 | #ifdef CONFIG_RT_MUTEXES | 928 | #ifdef CONFIG_RT_MUTEXES |
929 | { | 929 | { |
930 | .procname = "max_lock_depth", | 930 | .procname = "max_lock_depth", |
931 | .data = &max_lock_depth, | 931 | .data = &max_lock_depth, |
932 | .maxlen = sizeof(int), | 932 | .maxlen = sizeof(int), |
933 | .mode = 0644, | 933 | .mode = 0644, |
934 | .proc_handler = proc_dointvec, | 934 | .proc_handler = proc_dointvec, |
935 | }, | 935 | }, |
936 | #endif | 936 | #endif |
937 | { | 937 | { |
938 | .procname = "poweroff_cmd", | 938 | .procname = "poweroff_cmd", |
939 | .data = &poweroff_cmd, | 939 | .data = &poweroff_cmd, |
940 | .maxlen = POWEROFF_CMD_PATH_LEN, | 940 | .maxlen = POWEROFF_CMD_PATH_LEN, |
941 | .mode = 0644, | 941 | .mode = 0644, |
942 | .proc_handler = proc_dostring, | 942 | .proc_handler = proc_dostring, |
943 | }, | 943 | }, |
944 | #ifdef CONFIG_KEYS | 944 | #ifdef CONFIG_KEYS |
945 | { | 945 | { |
946 | .procname = "keys", | 946 | .procname = "keys", |
947 | .mode = 0555, | 947 | .mode = 0555, |
948 | .child = key_sysctls, | 948 | .child = key_sysctls, |
949 | }, | 949 | }, |
950 | #endif | 950 | #endif |
951 | #ifdef CONFIG_RCU_TORTURE_TEST | 951 | #ifdef CONFIG_RCU_TORTURE_TEST |
952 | { | 952 | { |
953 | .procname = "rcutorture_runnable", | 953 | .procname = "rcutorture_runnable", |
954 | .data = &rcutorture_runnable, | 954 | .data = &rcutorture_runnable, |
955 | .maxlen = sizeof(int), | 955 | .maxlen = sizeof(int), |
956 | .mode = 0644, | 956 | .mode = 0644, |
957 | .proc_handler = proc_dointvec, | 957 | .proc_handler = proc_dointvec, |
958 | }, | 958 | }, |
959 | #endif | 959 | #endif |
960 | #ifdef CONFIG_PERF_EVENTS | 960 | #ifdef CONFIG_PERF_EVENTS |
961 | /* | 961 | /* |
962 | * User-space scripts rely on the existence of this file | 962 | * User-space scripts rely on the existence of this file |
963 | * as a feature check for perf_events being enabled. | 963 | * as a feature check for perf_events being enabled. |
964 | * | 964 | * |
965 | * So it's an ABI, do not remove! | 965 | * So it's an ABI, do not remove! |
966 | */ | 966 | */ |
967 | { | 967 | { |
968 | .procname = "perf_event_paranoid", | 968 | .procname = "perf_event_paranoid", |
969 | .data = &sysctl_perf_event_paranoid, | 969 | .data = &sysctl_perf_event_paranoid, |
970 | .maxlen = sizeof(sysctl_perf_event_paranoid), | 970 | .maxlen = sizeof(sysctl_perf_event_paranoid), |
971 | .mode = 0644, | 971 | .mode = 0644, |
972 | .proc_handler = proc_dointvec, | 972 | .proc_handler = proc_dointvec, |
973 | }, | 973 | }, |
974 | { | 974 | { |
975 | .procname = "perf_event_mlock_kb", | 975 | .procname = "perf_event_mlock_kb", |
976 | .data = &sysctl_perf_event_mlock, | 976 | .data = &sysctl_perf_event_mlock, |
977 | .maxlen = sizeof(sysctl_perf_event_mlock), | 977 | .maxlen = sizeof(sysctl_perf_event_mlock), |
978 | .mode = 0644, | 978 | .mode = 0644, |
979 | .proc_handler = proc_dointvec, | 979 | .proc_handler = proc_dointvec, |
980 | }, | 980 | }, |
981 | { | 981 | { |
982 | .procname = "perf_event_max_sample_rate", | 982 | .procname = "perf_event_max_sample_rate", |
983 | .data = &sysctl_perf_event_sample_rate, | 983 | .data = &sysctl_perf_event_sample_rate, |
984 | .maxlen = sizeof(sysctl_perf_event_sample_rate), | 984 | .maxlen = sizeof(sysctl_perf_event_sample_rate), |
985 | .mode = 0644, | 985 | .mode = 0644, |
986 | .proc_handler = perf_proc_update_handler, | 986 | .proc_handler = perf_proc_update_handler, |
987 | }, | 987 | }, |
988 | #endif | 988 | #endif |
989 | #ifdef CONFIG_KMEMCHECK | 989 | #ifdef CONFIG_KMEMCHECK |
990 | { | 990 | { |
991 | .procname = "kmemcheck", | 991 | .procname = "kmemcheck", |
992 | .data = &kmemcheck_enabled, | 992 | .data = &kmemcheck_enabled, |
993 | .maxlen = sizeof(int), | 993 | .maxlen = sizeof(int), |
994 | .mode = 0644, | 994 | .mode = 0644, |
995 | .proc_handler = proc_dointvec, | 995 | .proc_handler = proc_dointvec, |
996 | }, | 996 | }, |
997 | #endif | 997 | #endif |
998 | #ifdef CONFIG_BLOCK | 998 | #ifdef CONFIG_BLOCK |
999 | { | 999 | { |
1000 | .procname = "blk_iopoll", | 1000 | .procname = "blk_iopoll", |
1001 | .data = &blk_iopoll_enabled, | 1001 | .data = &blk_iopoll_enabled, |
1002 | .maxlen = sizeof(int), | 1002 | .maxlen = sizeof(int), |
1003 | .mode = 0644, | 1003 | .mode = 0644, |
1004 | .proc_handler = proc_dointvec, | 1004 | .proc_handler = proc_dointvec, |
1005 | }, | 1005 | }, |
1006 | #endif | 1006 | #endif |
1007 | { } | 1007 | { } |
1008 | }; | 1008 | }; |
1009 | 1009 | ||
1010 | static struct ctl_table vm_table[] = { | 1010 | static struct ctl_table vm_table[] = { |
1011 | { | 1011 | { |
1012 | .procname = "overcommit_memory", | 1012 | .procname = "overcommit_memory", |
1013 | .data = &sysctl_overcommit_memory, | 1013 | .data = &sysctl_overcommit_memory, |
1014 | .maxlen = sizeof(sysctl_overcommit_memory), | 1014 | .maxlen = sizeof(sysctl_overcommit_memory), |
1015 | .mode = 0644, | 1015 | .mode = 0644, |
1016 | .proc_handler = proc_dointvec_minmax, | 1016 | .proc_handler = proc_dointvec_minmax, |
1017 | .extra1 = &zero, | 1017 | .extra1 = &zero, |
1018 | .extra2 = &two, | 1018 | .extra2 = &two, |
1019 | }, | 1019 | }, |
1020 | { | 1020 | { |
1021 | .procname = "panic_on_oom", | 1021 | .procname = "panic_on_oom", |
1022 | .data = &sysctl_panic_on_oom, | 1022 | .data = &sysctl_panic_on_oom, |
1023 | .maxlen = sizeof(sysctl_panic_on_oom), | 1023 | .maxlen = sizeof(sysctl_panic_on_oom), |
1024 | .mode = 0644, | 1024 | .mode = 0644, |
1025 | .proc_handler = proc_dointvec_minmax, | 1025 | .proc_handler = proc_dointvec_minmax, |
1026 | .extra1 = &zero, | 1026 | .extra1 = &zero, |
1027 | .extra2 = &two, | 1027 | .extra2 = &two, |
1028 | }, | 1028 | }, |
1029 | { | 1029 | { |
1030 | .procname = "oom_kill_allocating_task", | 1030 | .procname = "oom_kill_allocating_task", |
1031 | .data = &sysctl_oom_kill_allocating_task, | 1031 | .data = &sysctl_oom_kill_allocating_task, |
1032 | .maxlen = sizeof(sysctl_oom_kill_allocating_task), | 1032 | .maxlen = sizeof(sysctl_oom_kill_allocating_task), |
1033 | .mode = 0644, | 1033 | .mode = 0644, |
1034 | .proc_handler = proc_dointvec, | 1034 | .proc_handler = proc_dointvec, |
1035 | }, | 1035 | }, |
1036 | { | 1036 | { |
1037 | .procname = "oom_dump_tasks", | 1037 | .procname = "oom_dump_tasks", |
1038 | .data = &sysctl_oom_dump_tasks, | 1038 | .data = &sysctl_oom_dump_tasks, |
1039 | .maxlen = sizeof(sysctl_oom_dump_tasks), | 1039 | .maxlen = sizeof(sysctl_oom_dump_tasks), |
1040 | .mode = 0644, | 1040 | .mode = 0644, |
1041 | .proc_handler = proc_dointvec, | 1041 | .proc_handler = proc_dointvec, |
1042 | }, | 1042 | }, |
1043 | { | 1043 | { |
1044 | .procname = "overcommit_ratio", | 1044 | .procname = "overcommit_ratio", |
1045 | .data = &sysctl_overcommit_ratio, | 1045 | .data = &sysctl_overcommit_ratio, |
1046 | .maxlen = sizeof(sysctl_overcommit_ratio), | 1046 | .maxlen = sizeof(sysctl_overcommit_ratio), |
1047 | .mode = 0644, | 1047 | .mode = 0644, |
1048 | .proc_handler = proc_dointvec, | 1048 | .proc_handler = proc_dointvec, |
1049 | }, | 1049 | }, |
1050 | { | 1050 | { |
1051 | .procname = "page-cluster", | 1051 | .procname = "page-cluster", |
1052 | .data = &page_cluster, | 1052 | .data = &page_cluster, |
1053 | .maxlen = sizeof(int), | 1053 | .maxlen = sizeof(int), |
1054 | .mode = 0644, | 1054 | .mode = 0644, |
1055 | .proc_handler = proc_dointvec_minmax, | 1055 | .proc_handler = proc_dointvec_minmax, |
1056 | .extra1 = &zero, | 1056 | .extra1 = &zero, |
1057 | }, | 1057 | }, |
1058 | { | 1058 | { |
1059 | .procname = "dirty_background_ratio", | 1059 | .procname = "dirty_background_ratio", |
1060 | .data = &dirty_background_ratio, | 1060 | .data = &dirty_background_ratio, |
1061 | .maxlen = sizeof(dirty_background_ratio), | 1061 | .maxlen = sizeof(dirty_background_ratio), |
1062 | .mode = 0644, | 1062 | .mode = 0644, |
1063 | .proc_handler = dirty_background_ratio_handler, | 1063 | .proc_handler = dirty_background_ratio_handler, |
1064 | .extra1 = &zero, | 1064 | .extra1 = &zero, |
1065 | .extra2 = &one_hundred, | 1065 | .extra2 = &one_hundred, |
1066 | }, | 1066 | }, |
1067 | { | 1067 | { |
1068 | .procname = "dirty_background_bytes", | 1068 | .procname = "dirty_background_bytes", |
1069 | .data = &dirty_background_bytes, | 1069 | .data = &dirty_background_bytes, |
1070 | .maxlen = sizeof(dirty_background_bytes), | 1070 | .maxlen = sizeof(dirty_background_bytes), |
1071 | .mode = 0644, | 1071 | .mode = 0644, |
1072 | .proc_handler = dirty_background_bytes_handler, | 1072 | .proc_handler = dirty_background_bytes_handler, |
1073 | .extra1 = &one_ul, | 1073 | .extra1 = &one_ul, |
1074 | }, | 1074 | }, |
1075 | { | 1075 | { |
1076 | .procname = "dirty_ratio", | 1076 | .procname = "dirty_ratio", |
1077 | .data = &vm_dirty_ratio, | 1077 | .data = &vm_dirty_ratio, |
1078 | .maxlen = sizeof(vm_dirty_ratio), | 1078 | .maxlen = sizeof(vm_dirty_ratio), |
1079 | .mode = 0644, | 1079 | .mode = 0644, |
1080 | .proc_handler = dirty_ratio_handler, | 1080 | .proc_handler = dirty_ratio_handler, |
1081 | .extra1 = &zero, | 1081 | .extra1 = &zero, |
1082 | .extra2 = &one_hundred, | 1082 | .extra2 = &one_hundred, |
1083 | }, | 1083 | }, |
1084 | { | 1084 | { |
1085 | .procname = "dirty_bytes", | 1085 | .procname = "dirty_bytes", |
1086 | .data = &vm_dirty_bytes, | 1086 | .data = &vm_dirty_bytes, |
1087 | .maxlen = sizeof(vm_dirty_bytes), | 1087 | .maxlen = sizeof(vm_dirty_bytes), |
1088 | .mode = 0644, | 1088 | .mode = 0644, |
1089 | .proc_handler = dirty_bytes_handler, | 1089 | .proc_handler = dirty_bytes_handler, |
1090 | .extra1 = &dirty_bytes_min, | 1090 | .extra1 = &dirty_bytes_min, |
1091 | }, | 1091 | }, |
1092 | { | 1092 | { |
1093 | .procname = "dirty_writeback_centisecs", | 1093 | .procname = "dirty_writeback_centisecs", |
1094 | .data = &dirty_writeback_interval, | 1094 | .data = &dirty_writeback_interval, |
1095 | .maxlen = sizeof(dirty_writeback_interval), | 1095 | .maxlen = sizeof(dirty_writeback_interval), |
1096 | .mode = 0644, | 1096 | .mode = 0644, |
1097 | .proc_handler = dirty_writeback_centisecs_handler, | 1097 | .proc_handler = dirty_writeback_centisecs_handler, |
1098 | }, | 1098 | }, |
1099 | { | 1099 | { |
1100 | .procname = "dirty_expire_centisecs", | 1100 | .procname = "dirty_expire_centisecs", |
1101 | .data = &dirty_expire_interval, | 1101 | .data = &dirty_expire_interval, |
1102 | .maxlen = sizeof(dirty_expire_interval), | 1102 | .maxlen = sizeof(dirty_expire_interval), |
1103 | .mode = 0644, | 1103 | .mode = 0644, |
1104 | .proc_handler = proc_dointvec_minmax, | 1104 | .proc_handler = proc_dointvec_minmax, |
1105 | .extra1 = &zero, | 1105 | .extra1 = &zero, |
1106 | }, | 1106 | }, |
1107 | { | 1107 | { |
1108 | .procname = "nr_pdflush_threads", | 1108 | .procname = "nr_pdflush_threads", |
1109 | .data = &nr_pdflush_threads, | 1109 | .data = &nr_pdflush_threads, |
1110 | .maxlen = sizeof nr_pdflush_threads, | 1110 | .maxlen = sizeof nr_pdflush_threads, |
1111 | .mode = 0444 /* read-only*/, | 1111 | .mode = 0444 /* read-only*/, |
1112 | .proc_handler = proc_dointvec, | 1112 | .proc_handler = proc_dointvec, |
1113 | }, | 1113 | }, |
1114 | { | 1114 | { |
1115 | .procname = "swappiness", | 1115 | .procname = "swappiness", |
1116 | .data = &vm_swappiness, | 1116 | .data = &vm_swappiness, |
1117 | .maxlen = sizeof(vm_swappiness), | 1117 | .maxlen = sizeof(vm_swappiness), |
1118 | .mode = 0644, | 1118 | .mode = 0644, |
1119 | .proc_handler = proc_dointvec_minmax, | 1119 | .proc_handler = proc_dointvec_minmax, |
1120 | .extra1 = &zero, | 1120 | .extra1 = &zero, |
1121 | .extra2 = &one_hundred, | 1121 | .extra2 = &one_hundred, |
1122 | }, | 1122 | }, |
1123 | #ifdef CONFIG_HUGETLB_PAGE | 1123 | #ifdef CONFIG_HUGETLB_PAGE |
1124 | { | 1124 | { |
1125 | .procname = "nr_hugepages", | 1125 | .procname = "nr_hugepages", |
1126 | .data = NULL, | 1126 | .data = NULL, |
1127 | .maxlen = sizeof(unsigned long), | 1127 | .maxlen = sizeof(unsigned long), |
1128 | .mode = 0644, | 1128 | .mode = 0644, |
1129 | .proc_handler = hugetlb_sysctl_handler, | 1129 | .proc_handler = hugetlb_sysctl_handler, |
1130 | .extra1 = (void *)&hugetlb_zero, | 1130 | .extra1 = (void *)&hugetlb_zero, |
1131 | .extra2 = (void *)&hugetlb_infinity, | 1131 | .extra2 = (void *)&hugetlb_infinity, |
1132 | }, | 1132 | }, |
1133 | #ifdef CONFIG_NUMA | 1133 | #ifdef CONFIG_NUMA |
1134 | { | 1134 | { |
1135 | .procname = "nr_hugepages_mempolicy", | 1135 | .procname = "nr_hugepages_mempolicy", |
1136 | .data = NULL, | 1136 | .data = NULL, |
1137 | .maxlen = sizeof(unsigned long), | 1137 | .maxlen = sizeof(unsigned long), |
1138 | .mode = 0644, | 1138 | .mode = 0644, |
1139 | .proc_handler = &hugetlb_mempolicy_sysctl_handler, | 1139 | .proc_handler = &hugetlb_mempolicy_sysctl_handler, |
1140 | .extra1 = (void *)&hugetlb_zero, | 1140 | .extra1 = (void *)&hugetlb_zero, |
1141 | .extra2 = (void *)&hugetlb_infinity, | 1141 | .extra2 = (void *)&hugetlb_infinity, |
1142 | }, | 1142 | }, |
1143 | #endif | 1143 | #endif |
1144 | { | 1144 | { |
1145 | .procname = "hugetlb_shm_group", | 1145 | .procname = "hugetlb_shm_group", |
1146 | .data = &sysctl_hugetlb_shm_group, | 1146 | .data = &sysctl_hugetlb_shm_group, |
1147 | .maxlen = sizeof(gid_t), | 1147 | .maxlen = sizeof(gid_t), |
1148 | .mode = 0644, | 1148 | .mode = 0644, |
1149 | .proc_handler = proc_dointvec, | 1149 | .proc_handler = proc_dointvec, |
1150 | }, | 1150 | }, |
1151 | { | 1151 | { |
1152 | .procname = "hugepages_treat_as_movable", | 1152 | .procname = "hugepages_treat_as_movable", |
1153 | .data = &hugepages_treat_as_movable, | 1153 | .data = &hugepages_treat_as_movable, |
1154 | .maxlen = sizeof(int), | 1154 | .maxlen = sizeof(int), |
1155 | .mode = 0644, | 1155 | .mode = 0644, |
1156 | .proc_handler = hugetlb_treat_movable_handler, | 1156 | .proc_handler = hugetlb_treat_movable_handler, |
1157 | }, | 1157 | }, |
1158 | { | 1158 | { |
1159 | .procname = "nr_overcommit_hugepages", | 1159 | .procname = "nr_overcommit_hugepages", |
1160 | .data = NULL, | 1160 | .data = NULL, |
1161 | .maxlen = sizeof(unsigned long), | 1161 | .maxlen = sizeof(unsigned long), |
1162 | .mode = 0644, | 1162 | .mode = 0644, |
1163 | .proc_handler = hugetlb_overcommit_handler, | 1163 | .proc_handler = hugetlb_overcommit_handler, |
1164 | .extra1 = (void *)&hugetlb_zero, | 1164 | .extra1 = (void *)&hugetlb_zero, |
1165 | .extra2 = (void *)&hugetlb_infinity, | 1165 | .extra2 = (void *)&hugetlb_infinity, |
1166 | }, | 1166 | }, |
1167 | #endif | 1167 | #endif |
1168 | { | 1168 | { |
1169 | .procname = "lowmem_reserve_ratio", | 1169 | .procname = "lowmem_reserve_ratio", |
1170 | .data = &sysctl_lowmem_reserve_ratio, | 1170 | .data = &sysctl_lowmem_reserve_ratio, |
1171 | .maxlen = sizeof(sysctl_lowmem_reserve_ratio), | 1171 | .maxlen = sizeof(sysctl_lowmem_reserve_ratio), |
1172 | .mode = 0644, | 1172 | .mode = 0644, |
1173 | .proc_handler = lowmem_reserve_ratio_sysctl_handler, | 1173 | .proc_handler = lowmem_reserve_ratio_sysctl_handler, |
1174 | }, | 1174 | }, |
1175 | { | 1175 | { |
1176 | .procname = "drop_caches", | 1176 | .procname = "drop_caches", |
1177 | .data = &sysctl_drop_caches, | 1177 | .data = &sysctl_drop_caches, |
1178 | .maxlen = sizeof(int), | 1178 | .maxlen = sizeof(int), |
1179 | .mode = 0644, | 1179 | .mode = 0644, |
1180 | .proc_handler = drop_caches_sysctl_handler, | 1180 | .proc_handler = drop_caches_sysctl_handler, |
1181 | .extra1 = &one, | 1181 | .extra1 = &one, |
1182 | .extra2 = &three, | 1182 | .extra2 = &three, |
1183 | }, | 1183 | }, |
1184 | #ifdef CONFIG_COMPACTION | 1184 | #ifdef CONFIG_COMPACTION |
1185 | { | 1185 | { |
1186 | .procname = "compact_memory", | 1186 | .procname = "compact_memory", |
1187 | .data = &sysctl_compact_memory, | 1187 | .data = &sysctl_compact_memory, |
1188 | .maxlen = sizeof(int), | 1188 | .maxlen = sizeof(int), |
1189 | .mode = 0200, | 1189 | .mode = 0200, |
1190 | .proc_handler = sysctl_compaction_handler, | 1190 | .proc_handler = sysctl_compaction_handler, |
1191 | }, | 1191 | }, |
1192 | { | 1192 | { |
1193 | .procname = "extfrag_threshold", | 1193 | .procname = "extfrag_threshold", |
1194 | .data = &sysctl_extfrag_threshold, | 1194 | .data = &sysctl_extfrag_threshold, |
1195 | .maxlen = sizeof(int), | 1195 | .maxlen = sizeof(int), |
1196 | .mode = 0644, | 1196 | .mode = 0644, |
1197 | .proc_handler = sysctl_extfrag_handler, | 1197 | .proc_handler = sysctl_extfrag_handler, |
1198 | .extra1 = &min_extfrag_threshold, | 1198 | .extra1 = &min_extfrag_threshold, |
1199 | .extra2 = &max_extfrag_threshold, | 1199 | .extra2 = &max_extfrag_threshold, |
1200 | }, | 1200 | }, |
1201 | 1201 | ||
1202 | #endif /* CONFIG_COMPACTION */ | 1202 | #endif /* CONFIG_COMPACTION */ |
1203 | { | 1203 | { |
1204 | .procname = "min_free_kbytes", | 1204 | .procname = "min_free_kbytes", |
1205 | .data = &min_free_kbytes, | 1205 | .data = &min_free_kbytes, |
1206 | .maxlen = sizeof(min_free_kbytes), | 1206 | .maxlen = sizeof(min_free_kbytes), |
1207 | .mode = 0644, | 1207 | .mode = 0644, |
1208 | .proc_handler = min_free_kbytes_sysctl_handler, | 1208 | .proc_handler = min_free_kbytes_sysctl_handler, |
1209 | .extra1 = &zero, | 1209 | .extra1 = &zero, |
1210 | }, | 1210 | }, |
1211 | { | 1211 | { |
1212 | .procname = "percpu_pagelist_fraction", | 1212 | .procname = "percpu_pagelist_fraction", |
1213 | .data = &percpu_pagelist_fraction, | 1213 | .data = &percpu_pagelist_fraction, |
1214 | .maxlen = sizeof(percpu_pagelist_fraction), | 1214 | .maxlen = sizeof(percpu_pagelist_fraction), |
1215 | .mode = 0644, | 1215 | .mode = 0644, |
1216 | .proc_handler = percpu_pagelist_fraction_sysctl_handler, | 1216 | .proc_handler = percpu_pagelist_fraction_sysctl_handler, |
1217 | .extra1 = &min_percpu_pagelist_fract, | 1217 | .extra1 = &min_percpu_pagelist_fract, |
1218 | }, | 1218 | }, |
1219 | #ifdef CONFIG_MMU | 1219 | #ifdef CONFIG_MMU |
1220 | { | 1220 | { |
1221 | .procname = "max_map_count", | 1221 | .procname = "max_map_count", |
1222 | .data = &sysctl_max_map_count, | 1222 | .data = &sysctl_max_map_count, |
1223 | .maxlen = sizeof(sysctl_max_map_count), | 1223 | .maxlen = sizeof(sysctl_max_map_count), |
1224 | .mode = 0644, | 1224 | .mode = 0644, |
1225 | .proc_handler = proc_dointvec_minmax, | 1225 | .proc_handler = proc_dointvec_minmax, |
1226 | .extra1 = &zero, | 1226 | .extra1 = &zero, |
1227 | }, | 1227 | }, |
1228 | #else | 1228 | #else |
1229 | { | 1229 | { |
1230 | .procname = "nr_trim_pages", | 1230 | .procname = "nr_trim_pages", |
1231 | .data = &sysctl_nr_trim_pages, | 1231 | .data = &sysctl_nr_trim_pages, |
1232 | .maxlen = sizeof(sysctl_nr_trim_pages), | 1232 | .maxlen = sizeof(sysctl_nr_trim_pages), |
1233 | .mode = 0644, | 1233 | .mode = 0644, |
1234 | .proc_handler = proc_dointvec_minmax, | 1234 | .proc_handler = proc_dointvec_minmax, |
1235 | .extra1 = &zero, | 1235 | .extra1 = &zero, |
1236 | }, | 1236 | }, |
1237 | #endif | 1237 | #endif |
1238 | { | 1238 | { |
1239 | .procname = "laptop_mode", | 1239 | .procname = "laptop_mode", |
1240 | .data = &laptop_mode, | 1240 | .data = &laptop_mode, |
1241 | .maxlen = sizeof(laptop_mode), | 1241 | .maxlen = sizeof(laptop_mode), |
1242 | .mode = 0644, | 1242 | .mode = 0644, |
1243 | .proc_handler = proc_dointvec_jiffies, | 1243 | .proc_handler = proc_dointvec_jiffies, |
1244 | }, | 1244 | }, |
1245 | { | 1245 | { |
1246 | .procname = "block_dump", | 1246 | .procname = "block_dump", |
1247 | .data = &block_dump, | 1247 | .data = &block_dump, |
1248 | .maxlen = sizeof(block_dump), | 1248 | .maxlen = sizeof(block_dump), |
1249 | .mode = 0644, | 1249 | .mode = 0644, |
1250 | .proc_handler = proc_dointvec, | 1250 | .proc_handler = proc_dointvec, |
1251 | .extra1 = &zero, | 1251 | .extra1 = &zero, |
1252 | }, | 1252 | }, |
1253 | { | 1253 | { |
1254 | .procname = "vfs_cache_pressure", | 1254 | .procname = "vfs_cache_pressure", |
1255 | .data = &sysctl_vfs_cache_pressure, | 1255 | .data = &sysctl_vfs_cache_pressure, |
1256 | .maxlen = sizeof(sysctl_vfs_cache_pressure), | 1256 | .maxlen = sizeof(sysctl_vfs_cache_pressure), |
1257 | .mode = 0644, | 1257 | .mode = 0644, |
1258 | .proc_handler = proc_dointvec, | 1258 | .proc_handler = proc_dointvec, |
1259 | .extra1 = &zero, | 1259 | .extra1 = &zero, |
1260 | }, | 1260 | }, |
1261 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT | 1261 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
1262 | { | 1262 | { |
1263 | .procname = "legacy_va_layout", | 1263 | .procname = "legacy_va_layout", |
1264 | .data = &sysctl_legacy_va_layout, | 1264 | .data = &sysctl_legacy_va_layout, |
1265 | .maxlen = sizeof(sysctl_legacy_va_layout), | 1265 | .maxlen = sizeof(sysctl_legacy_va_layout), |
1266 | .mode = 0644, | 1266 | .mode = 0644, |
1267 | .proc_handler = proc_dointvec, | 1267 | .proc_handler = proc_dointvec, |
1268 | .extra1 = &zero, | 1268 | .extra1 = &zero, |
1269 | }, | 1269 | }, |
1270 | #endif | 1270 | #endif |
1271 | #ifdef CONFIG_NUMA | 1271 | #ifdef CONFIG_NUMA |
1272 | { | 1272 | { |
1273 | .procname = "zone_reclaim_mode", | 1273 | .procname = "zone_reclaim_mode", |
1274 | .data = &zone_reclaim_mode, | 1274 | .data = &zone_reclaim_mode, |
1275 | .maxlen = sizeof(zone_reclaim_mode), | 1275 | .maxlen = sizeof(zone_reclaim_mode), |
1276 | .mode = 0644, | 1276 | .mode = 0644, |
1277 | .proc_handler = proc_dointvec, | 1277 | .proc_handler = proc_dointvec, |
1278 | .extra1 = &zero, | 1278 | .extra1 = &zero, |
1279 | }, | 1279 | }, |
1280 | { | 1280 | { |
1281 | .procname = "min_unmapped_ratio", | 1281 | .procname = "min_unmapped_ratio", |
1282 | .data = &sysctl_min_unmapped_ratio, | 1282 | .data = &sysctl_min_unmapped_ratio, |
1283 | .maxlen = sizeof(sysctl_min_unmapped_ratio), | 1283 | .maxlen = sizeof(sysctl_min_unmapped_ratio), |
1284 | .mode = 0644, | 1284 | .mode = 0644, |
1285 | .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, | 1285 | .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, |
1286 | .extra1 = &zero, | 1286 | .extra1 = &zero, |
1287 | .extra2 = &one_hundred, | 1287 | .extra2 = &one_hundred, |
1288 | }, | 1288 | }, |
1289 | { | 1289 | { |
1290 | .procname = "min_slab_ratio", | 1290 | .procname = "min_slab_ratio", |
1291 | .data = &sysctl_min_slab_ratio, | 1291 | .data = &sysctl_min_slab_ratio, |
1292 | .maxlen = sizeof(sysctl_min_slab_ratio), | 1292 | .maxlen = sizeof(sysctl_min_slab_ratio), |
1293 | .mode = 0644, | 1293 | .mode = 0644, |
1294 | .proc_handler = sysctl_min_slab_ratio_sysctl_handler, | 1294 | .proc_handler = sysctl_min_slab_ratio_sysctl_handler, |
1295 | .extra1 = &zero, | 1295 | .extra1 = &zero, |
1296 | .extra2 = &one_hundred, | 1296 | .extra2 = &one_hundred, |
1297 | }, | 1297 | }, |
1298 | #endif | 1298 | #endif |
1299 | #ifdef CONFIG_SMP | 1299 | #ifdef CONFIG_SMP |
1300 | { | 1300 | { |
1301 | .procname = "stat_interval", | 1301 | .procname = "stat_interval", |
1302 | .data = &sysctl_stat_interval, | 1302 | .data = &sysctl_stat_interval, |
1303 | .maxlen = sizeof(sysctl_stat_interval), | 1303 | .maxlen = sizeof(sysctl_stat_interval), |
1304 | .mode = 0644, | 1304 | .mode = 0644, |
1305 | .proc_handler = proc_dointvec_jiffies, | 1305 | .proc_handler = proc_dointvec_jiffies, |
1306 | }, | 1306 | }, |
1307 | #endif | 1307 | #endif |
1308 | #ifdef CONFIG_MMU | 1308 | #ifdef CONFIG_MMU |
1309 | { | 1309 | { |
1310 | .procname = "mmap_min_addr", | 1310 | .procname = "mmap_min_addr", |
1311 | .data = &dac_mmap_min_addr, | 1311 | .data = &dac_mmap_min_addr, |
1312 | .maxlen = sizeof(unsigned long), | 1312 | .maxlen = sizeof(unsigned long), |
1313 | .mode = 0644, | 1313 | .mode = 0644, |
1314 | .proc_handler = mmap_min_addr_handler, | 1314 | .proc_handler = mmap_min_addr_handler, |
1315 | }, | 1315 | }, |
1316 | #endif | 1316 | #endif |
1317 | #ifdef CONFIG_NUMA | 1317 | #ifdef CONFIG_NUMA |
1318 | { | 1318 | { |
1319 | .procname = "numa_zonelist_order", | 1319 | .procname = "numa_zonelist_order", |
1320 | .data = &numa_zonelist_order, | 1320 | .data = &numa_zonelist_order, |
1321 | .maxlen = NUMA_ZONELIST_ORDER_LEN, | 1321 | .maxlen = NUMA_ZONELIST_ORDER_LEN, |
1322 | .mode = 0644, | 1322 | .mode = 0644, |
1323 | .proc_handler = numa_zonelist_order_handler, | 1323 | .proc_handler = numa_zonelist_order_handler, |
1324 | }, | 1324 | }, |
1325 | #endif | 1325 | #endif |
1326 | #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ | 1326 | #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ |
1327 | (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) | 1327 | (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) |
1328 | { | 1328 | { |
1329 | .procname = "vdso_enabled", | 1329 | .procname = "vdso_enabled", |
1330 | .data = &vdso_enabled, | 1330 | .data = &vdso_enabled, |
1331 | .maxlen = sizeof(vdso_enabled), | 1331 | .maxlen = sizeof(vdso_enabled), |
1332 | .mode = 0644, | 1332 | .mode = 0644, |
1333 | .proc_handler = proc_dointvec, | 1333 | .proc_handler = proc_dointvec, |
1334 | .extra1 = &zero, | 1334 | .extra1 = &zero, |
1335 | }, | 1335 | }, |
1336 | #endif | 1336 | #endif |
1337 | #ifdef CONFIG_HIGHMEM | 1337 | #ifdef CONFIG_HIGHMEM |
1338 | { | 1338 | { |
1339 | .procname = "highmem_is_dirtyable", | 1339 | .procname = "highmem_is_dirtyable", |
1340 | .data = &vm_highmem_is_dirtyable, | 1340 | .data = &vm_highmem_is_dirtyable, |
1341 | .maxlen = sizeof(vm_highmem_is_dirtyable), | 1341 | .maxlen = sizeof(vm_highmem_is_dirtyable), |
1342 | .mode = 0644, | 1342 | .mode = 0644, |
1343 | .proc_handler = proc_dointvec_minmax, | 1343 | .proc_handler = proc_dointvec_minmax, |
1344 | .extra1 = &zero, | 1344 | .extra1 = &zero, |
1345 | .extra2 = &one, | 1345 | .extra2 = &one, |
1346 | }, | 1346 | }, |
1347 | #endif | 1347 | #endif |
1348 | { | 1348 | { |
1349 | .procname = "scan_unevictable_pages", | 1349 | .procname = "scan_unevictable_pages", |
1350 | .data = &scan_unevictable_pages, | 1350 | .data = &scan_unevictable_pages, |
1351 | .maxlen = sizeof(scan_unevictable_pages), | 1351 | .maxlen = sizeof(scan_unevictable_pages), |
1352 | .mode = 0644, | 1352 | .mode = 0644, |
1353 | .proc_handler = scan_unevictable_handler, | 1353 | .proc_handler = scan_unevictable_handler, |
1354 | }, | 1354 | }, |
1355 | #ifdef CONFIG_MEMORY_FAILURE | 1355 | #ifdef CONFIG_MEMORY_FAILURE |
1356 | { | 1356 | { |
1357 | .procname = "memory_failure_early_kill", | 1357 | .procname = "memory_failure_early_kill", |
1358 | .data = &sysctl_memory_failure_early_kill, | 1358 | .data = &sysctl_memory_failure_early_kill, |
1359 | .maxlen = sizeof(sysctl_memory_failure_early_kill), | 1359 | .maxlen = sizeof(sysctl_memory_failure_early_kill), |
1360 | .mode = 0644, | 1360 | .mode = 0644, |
1361 | .proc_handler = proc_dointvec_minmax, | 1361 | .proc_handler = proc_dointvec_minmax, |
1362 | .extra1 = &zero, | 1362 | .extra1 = &zero, |
1363 | .extra2 = &one, | 1363 | .extra2 = &one, |
1364 | }, | 1364 | }, |
1365 | { | 1365 | { |
1366 | .procname = "memory_failure_recovery", | 1366 | .procname = "memory_failure_recovery", |
1367 | .data = &sysctl_memory_failure_recovery, | 1367 | .data = &sysctl_memory_failure_recovery, |
1368 | .maxlen = sizeof(sysctl_memory_failure_recovery), | 1368 | .maxlen = sizeof(sysctl_memory_failure_recovery), |
1369 | .mode = 0644, | 1369 | .mode = 0644, |
1370 | .proc_handler = proc_dointvec_minmax, | 1370 | .proc_handler = proc_dointvec_minmax, |
1371 | .extra1 = &zero, | 1371 | .extra1 = &zero, |
1372 | .extra2 = &one, | 1372 | .extra2 = &one, |
1373 | }, | 1373 | }, |
1374 | #endif | 1374 | #endif |
1375 | { } | 1375 | { } |
1376 | }; | 1376 | }; |
1377 | 1377 | ||
1378 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) | 1378 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) |
1379 | static struct ctl_table binfmt_misc_table[] = { | 1379 | static struct ctl_table binfmt_misc_table[] = { |
1380 | { } | 1380 | { } |
1381 | }; | 1381 | }; |
1382 | #endif | 1382 | #endif |
1383 | 1383 | ||
1384 | static struct ctl_table fs_table[] = { | 1384 | static struct ctl_table fs_table[] = { |
1385 | { | 1385 | { |
1386 | .procname = "inode-nr", | 1386 | .procname = "inode-nr", |
1387 | .data = &inodes_stat, | 1387 | .data = &inodes_stat, |
1388 | .maxlen = 2*sizeof(int), | 1388 | .maxlen = 2*sizeof(int), |
1389 | .mode = 0444, | 1389 | .mode = 0444, |
1390 | .proc_handler = proc_nr_inodes, | 1390 | .proc_handler = proc_nr_inodes, |
1391 | }, | 1391 | }, |
1392 | { | 1392 | { |
1393 | .procname = "inode-state", | 1393 | .procname = "inode-state", |
1394 | .data = &inodes_stat, | 1394 | .data = &inodes_stat, |
1395 | .maxlen = 7*sizeof(int), | 1395 | .maxlen = 7*sizeof(int), |
1396 | .mode = 0444, | 1396 | .mode = 0444, |
1397 | .proc_handler = proc_nr_inodes, | 1397 | .proc_handler = proc_nr_inodes, |
1398 | }, | 1398 | }, |
1399 | { | 1399 | { |
1400 | .procname = "file-nr", | 1400 | .procname = "file-nr", |
1401 | .data = &files_stat, | 1401 | .data = &files_stat, |
1402 | .maxlen = sizeof(files_stat), | 1402 | .maxlen = sizeof(files_stat), |
1403 | .mode = 0444, | 1403 | .mode = 0444, |
1404 | .proc_handler = proc_nr_files, | 1404 | .proc_handler = proc_nr_files, |
1405 | }, | 1405 | }, |
1406 | { | 1406 | { |
1407 | .procname = "file-max", | 1407 | .procname = "file-max", |
1408 | .data = &files_stat.max_files, | 1408 | .data = &files_stat.max_files, |
1409 | .maxlen = sizeof(files_stat.max_files), | 1409 | .maxlen = sizeof(files_stat.max_files), |
1410 | .mode = 0644, | 1410 | .mode = 0644, |
1411 | .proc_handler = proc_doulongvec_minmax, | 1411 | .proc_handler = proc_doulongvec_minmax, |
1412 | }, | 1412 | }, |
1413 | { | 1413 | { |
1414 | .procname = "nr_open", | 1414 | .procname = "nr_open", |
1415 | .data = &sysctl_nr_open, | 1415 | .data = &sysctl_nr_open, |
1416 | .maxlen = sizeof(int), | 1416 | .maxlen = sizeof(int), |
1417 | .mode = 0644, | 1417 | .mode = 0644, |
1418 | .proc_handler = proc_dointvec_minmax, | 1418 | .proc_handler = proc_dointvec_minmax, |
1419 | .extra1 = &sysctl_nr_open_min, | 1419 | .extra1 = &sysctl_nr_open_min, |
1420 | .extra2 = &sysctl_nr_open_max, | 1420 | .extra2 = &sysctl_nr_open_max, |
1421 | }, | 1421 | }, |
1422 | { | 1422 | { |
1423 | .procname = "dentry-state", | 1423 | .procname = "dentry-state", |
1424 | .data = &dentry_stat, | 1424 | .data = &dentry_stat, |
1425 | .maxlen = 6*sizeof(int), | 1425 | .maxlen = 6*sizeof(int), |
1426 | .mode = 0444, | 1426 | .mode = 0444, |
1427 | .proc_handler = proc_nr_dentry, | 1427 | .proc_handler = proc_nr_dentry, |
1428 | }, | 1428 | }, |
1429 | { | 1429 | { |
1430 | .procname = "overflowuid", | 1430 | .procname = "overflowuid", |
1431 | .data = &fs_overflowuid, | 1431 | .data = &fs_overflowuid, |
1432 | .maxlen = sizeof(int), | 1432 | .maxlen = sizeof(int), |
1433 | .mode = 0644, | 1433 | .mode = 0644, |
1434 | .proc_handler = proc_dointvec_minmax, | 1434 | .proc_handler = proc_dointvec_minmax, |
1435 | .extra1 = &minolduid, | 1435 | .extra1 = &minolduid, |
1436 | .extra2 = &maxolduid, | 1436 | .extra2 = &maxolduid, |
1437 | }, | 1437 | }, |
1438 | { | 1438 | { |
1439 | .procname = "overflowgid", | 1439 | .procname = "overflowgid", |
1440 | .data = &fs_overflowgid, | 1440 | .data = &fs_overflowgid, |
1441 | .maxlen = sizeof(int), | 1441 | .maxlen = sizeof(int), |
1442 | .mode = 0644, | 1442 | .mode = 0644, |
1443 | .proc_handler = proc_dointvec_minmax, | 1443 | .proc_handler = proc_dointvec_minmax, |
1444 | .extra1 = &minolduid, | 1444 | .extra1 = &minolduid, |
1445 | .extra2 = &maxolduid, | 1445 | .extra2 = &maxolduid, |
1446 | }, | 1446 | }, |
1447 | #ifdef CONFIG_FILE_LOCKING | 1447 | #ifdef CONFIG_FILE_LOCKING |
1448 | { | 1448 | { |
1449 | .procname = "leases-enable", | 1449 | .procname = "leases-enable", |
1450 | .data = &leases_enable, | 1450 | .data = &leases_enable, |
1451 | .maxlen = sizeof(int), | 1451 | .maxlen = sizeof(int), |
1452 | .mode = 0644, | 1452 | .mode = 0644, |
1453 | .proc_handler = proc_dointvec, | 1453 | .proc_handler = proc_dointvec, |
1454 | }, | 1454 | }, |
1455 | #endif | 1455 | #endif |
1456 | #ifdef CONFIG_DNOTIFY | 1456 | #ifdef CONFIG_DNOTIFY |
1457 | { | 1457 | { |
1458 | .procname = "dir-notify-enable", | 1458 | .procname = "dir-notify-enable", |
1459 | .data = &dir_notify_enable, | 1459 | .data = &dir_notify_enable, |
1460 | .maxlen = sizeof(int), | 1460 | .maxlen = sizeof(int), |
1461 | .mode = 0644, | 1461 | .mode = 0644, |
1462 | .proc_handler = proc_dointvec, | 1462 | .proc_handler = proc_dointvec, |
1463 | }, | 1463 | }, |
1464 | #endif | 1464 | #endif |
1465 | #ifdef CONFIG_MMU | 1465 | #ifdef CONFIG_MMU |
1466 | #ifdef CONFIG_FILE_LOCKING | 1466 | #ifdef CONFIG_FILE_LOCKING |
1467 | { | 1467 | { |
1468 | .procname = "lease-break-time", | 1468 | .procname = "lease-break-time", |
1469 | .data = &lease_break_time, | 1469 | .data = &lease_break_time, |
1470 | .maxlen = sizeof(int), | 1470 | .maxlen = sizeof(int), |
1471 | .mode = 0644, | 1471 | .mode = 0644, |
1472 | .proc_handler = proc_dointvec, | 1472 | .proc_handler = proc_dointvec, |
1473 | }, | 1473 | }, |
1474 | #endif | 1474 | #endif |
1475 | #ifdef CONFIG_AIO | 1475 | #ifdef CONFIG_AIO |
1476 | { | 1476 | { |
1477 | .procname = "aio-nr", | 1477 | .procname = "aio-nr", |
1478 | .data = &aio_nr, | 1478 | .data = &aio_nr, |
1479 | .maxlen = sizeof(aio_nr), | 1479 | .maxlen = sizeof(aio_nr), |
1480 | .mode = 0444, | 1480 | .mode = 0444, |
1481 | .proc_handler = proc_doulongvec_minmax, | 1481 | .proc_handler = proc_doulongvec_minmax, |
1482 | }, | 1482 | }, |
1483 | { | 1483 | { |
1484 | .procname = "aio-max-nr", | 1484 | .procname = "aio-max-nr", |
1485 | .data = &aio_max_nr, | 1485 | .data = &aio_max_nr, |
1486 | .maxlen = sizeof(aio_max_nr), | 1486 | .maxlen = sizeof(aio_max_nr), |
1487 | .mode = 0644, | 1487 | .mode = 0644, |
1488 | .proc_handler = proc_doulongvec_minmax, | 1488 | .proc_handler = proc_doulongvec_minmax, |
1489 | }, | 1489 | }, |
1490 | #endif /* CONFIG_AIO */ | 1490 | #endif /* CONFIG_AIO */ |
1491 | #ifdef CONFIG_INOTIFY_USER | 1491 | #ifdef CONFIG_INOTIFY_USER |
1492 | { | 1492 | { |
1493 | .procname = "inotify", | 1493 | .procname = "inotify", |
1494 | .mode = 0555, | 1494 | .mode = 0555, |
1495 | .child = inotify_table, | 1495 | .child = inotify_table, |
1496 | }, | 1496 | }, |
1497 | #endif | 1497 | #endif |
1498 | #ifdef CONFIG_EPOLL | 1498 | #ifdef CONFIG_EPOLL |
1499 | { | 1499 | { |
1500 | .procname = "epoll", | 1500 | .procname = "epoll", |
1501 | .mode = 0555, | 1501 | .mode = 0555, |
1502 | .child = epoll_table, | 1502 | .child = epoll_table, |
1503 | }, | 1503 | }, |
1504 | #endif | 1504 | #endif |
1505 | #endif | 1505 | #endif |
1506 | { | 1506 | { |
1507 | .procname = "suid_dumpable", | 1507 | .procname = "suid_dumpable", |
1508 | .data = &suid_dumpable, | 1508 | .data = &suid_dumpable, |
1509 | .maxlen = sizeof(int), | 1509 | .maxlen = sizeof(int), |
1510 | .mode = 0644, | 1510 | .mode = 0644, |
1511 | .proc_handler = proc_dointvec_minmax, | 1511 | .proc_handler = proc_dointvec_minmax, |
1512 | .extra1 = &zero, | 1512 | .extra1 = &zero, |
1513 | .extra2 = &two, | 1513 | .extra2 = &two, |
1514 | }, | 1514 | }, |
1515 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) | 1515 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) |
1516 | { | 1516 | { |
1517 | .procname = "binfmt_misc", | 1517 | .procname = "binfmt_misc", |
1518 | .mode = 0555, | 1518 | .mode = 0555, |
1519 | .child = binfmt_misc_table, | 1519 | .child = binfmt_misc_table, |
1520 | }, | 1520 | }, |
1521 | #endif | 1521 | #endif |
1522 | { | 1522 | { |
1523 | .procname = "pipe-max-size", | 1523 | .procname = "pipe-max-size", |
1524 | .data = &pipe_max_size, | 1524 | .data = &pipe_max_size, |
1525 | .maxlen = sizeof(int), | 1525 | .maxlen = sizeof(int), |
1526 | .mode = 0644, | 1526 | .mode = 0644, |
1527 | .proc_handler = &pipe_proc_fn, | 1527 | .proc_handler = &pipe_proc_fn, |
1528 | .extra1 = &pipe_min_size, | 1528 | .extra1 = &pipe_min_size, |
1529 | }, | 1529 | }, |
1530 | { } | 1530 | { } |
1531 | }; | 1531 | }; |
1532 | 1532 | ||
1533 | static struct ctl_table debug_table[] = { | 1533 | static struct ctl_table debug_table[] = { |
1534 | #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \ | 1534 | #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \ |
1535 | defined(CONFIG_S390) || defined(CONFIG_TILE) | 1535 | defined(CONFIG_S390) || defined(CONFIG_TILE) |
1536 | { | 1536 | { |
1537 | .procname = "exception-trace", | 1537 | .procname = "exception-trace", |
1538 | .data = &show_unhandled_signals, | 1538 | .data = &show_unhandled_signals, |
1539 | .maxlen = sizeof(int), | 1539 | .maxlen = sizeof(int), |
1540 | .mode = 0644, | 1540 | .mode = 0644, |
1541 | .proc_handler = proc_dointvec | 1541 | .proc_handler = proc_dointvec |
1542 | }, | 1542 | }, |
1543 | #endif | 1543 | #endif |
1544 | #if defined(CONFIG_OPTPROBES) | 1544 | #if defined(CONFIG_OPTPROBES) |
1545 | { | 1545 | { |
1546 | .procname = "kprobes-optimization", | 1546 | .procname = "kprobes-optimization", |
1547 | .data = &sysctl_kprobes_optimization, | 1547 | .data = &sysctl_kprobes_optimization, |
1548 | .maxlen = sizeof(int), | 1548 | .maxlen = sizeof(int), |
1549 | .mode = 0644, | 1549 | .mode = 0644, |
1550 | .proc_handler = proc_kprobes_optimization_handler, | 1550 | .proc_handler = proc_kprobes_optimization_handler, |
1551 | .extra1 = &zero, | 1551 | .extra1 = &zero, |
1552 | .extra2 = &one, | 1552 | .extra2 = &one, |
1553 | }, | 1553 | }, |
1554 | #endif | 1554 | #endif |
1555 | { } | 1555 | { } |
1556 | }; | 1556 | }; |
1557 | 1557 | ||
1558 | static struct ctl_table dev_table[] = { | 1558 | static struct ctl_table dev_table[] = { |
1559 | { } | 1559 | { } |
1560 | }; | 1560 | }; |
1561 | 1561 | ||
1562 | static DEFINE_SPINLOCK(sysctl_lock); | 1562 | static DEFINE_SPINLOCK(sysctl_lock); |
1563 | 1563 | ||
1564 | /* called under sysctl_lock */ | 1564 | /* called under sysctl_lock */ |
1565 | static int use_table(struct ctl_table_header *p) | 1565 | static int use_table(struct ctl_table_header *p) |
1566 | { | 1566 | { |
1567 | if (unlikely(p->unregistering)) | 1567 | if (unlikely(p->unregistering)) |
1568 | return 0; | 1568 | return 0; |
1569 | p->used++; | 1569 | p->used++; |
1570 | return 1; | 1570 | return 1; |
1571 | } | 1571 | } |
1572 | 1572 | ||
1573 | /* called under sysctl_lock */ | 1573 | /* called under sysctl_lock */ |
1574 | static void unuse_table(struct ctl_table_header *p) | 1574 | static void unuse_table(struct ctl_table_header *p) |
1575 | { | 1575 | { |
1576 | if (!--p->used) | 1576 | if (!--p->used) |
1577 | if (unlikely(p->unregistering)) | 1577 | if (unlikely(p->unregistering)) |
1578 | complete(p->unregistering); | 1578 | complete(p->unregistering); |
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | /* called under sysctl_lock, will reacquire if has to wait */ | 1581 | /* called under sysctl_lock, will reacquire if has to wait */ |
1582 | static void start_unregistering(struct ctl_table_header *p) | 1582 | static void start_unregistering(struct ctl_table_header *p) |
1583 | { | 1583 | { |
1584 | /* | 1584 | /* |
1585 | * if p->used is 0, nobody will ever touch that entry again; | 1585 | * if p->used is 0, nobody will ever touch that entry again; |
1586 | * we'll eliminate all paths to it before dropping sysctl_lock | 1586 | * we'll eliminate all paths to it before dropping sysctl_lock |
1587 | */ | 1587 | */ |
1588 | if (unlikely(p->used)) { | 1588 | if (unlikely(p->used)) { |
1589 | struct completion wait; | 1589 | struct completion wait; |
1590 | init_completion(&wait); | 1590 | init_completion(&wait); |
1591 | p->unregistering = &wait; | 1591 | p->unregistering = &wait; |
1592 | spin_unlock(&sysctl_lock); | 1592 | spin_unlock(&sysctl_lock); |
1593 | wait_for_completion(&wait); | 1593 | wait_for_completion(&wait); |
1594 | spin_lock(&sysctl_lock); | 1594 | spin_lock(&sysctl_lock); |
1595 | } else { | 1595 | } else { |
1596 | /* anything non-NULL; we'll never dereference it */ | 1596 | /* anything non-NULL; we'll never dereference it */ |
1597 | p->unregistering = ERR_PTR(-EINVAL); | 1597 | p->unregistering = ERR_PTR(-EINVAL); |
1598 | } | 1598 | } |
1599 | /* | 1599 | /* |
1600 | * do not remove from the list until nobody holds it; walking the | 1600 | * do not remove from the list until nobody holds it; walking the |
1601 | * list in do_sysctl() relies on that. | 1601 | * list in do_sysctl() relies on that. |
1602 | */ | 1602 | */ |
1603 | list_del_init(&p->ctl_entry); | 1603 | list_del_init(&p->ctl_entry); |
1604 | } | 1604 | } |
1605 | 1605 | ||
1606 | void sysctl_head_get(struct ctl_table_header *head) | 1606 | void sysctl_head_get(struct ctl_table_header *head) |
1607 | { | 1607 | { |
1608 | spin_lock(&sysctl_lock); | 1608 | spin_lock(&sysctl_lock); |
1609 | head->count++; | 1609 | head->count++; |
1610 | spin_unlock(&sysctl_lock); | 1610 | spin_unlock(&sysctl_lock); |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | void sysctl_head_put(struct ctl_table_header *head) | 1613 | void sysctl_head_put(struct ctl_table_header *head) |
1614 | { | 1614 | { |
1615 | spin_lock(&sysctl_lock); | 1615 | spin_lock(&sysctl_lock); |
1616 | if (!--head->count) | 1616 | if (!--head->count) |
1617 | kfree_rcu(head, rcu); | 1617 | kfree_rcu(head, rcu); |
1618 | spin_unlock(&sysctl_lock); | 1618 | spin_unlock(&sysctl_lock); |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) | 1621 | struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) |
1622 | { | 1622 | { |
1623 | if (!head) | 1623 | if (!head) |
1624 | BUG(); | 1624 | BUG(); |
1625 | spin_lock(&sysctl_lock); | 1625 | spin_lock(&sysctl_lock); |
1626 | if (!use_table(head)) | 1626 | if (!use_table(head)) |
1627 | head = ERR_PTR(-ENOENT); | 1627 | head = ERR_PTR(-ENOENT); |
1628 | spin_unlock(&sysctl_lock); | 1628 | spin_unlock(&sysctl_lock); |
1629 | return head; | 1629 | return head; |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | void sysctl_head_finish(struct ctl_table_header *head) | 1632 | void sysctl_head_finish(struct ctl_table_header *head) |
1633 | { | 1633 | { |
1634 | if (!head) | 1634 | if (!head) |
1635 | return; | 1635 | return; |
1636 | spin_lock(&sysctl_lock); | 1636 | spin_lock(&sysctl_lock); |
1637 | unuse_table(head); | 1637 | unuse_table(head); |
1638 | spin_unlock(&sysctl_lock); | 1638 | spin_unlock(&sysctl_lock); |
1639 | } | 1639 | } |
1640 | 1640 | ||
1641 | static struct ctl_table_set * | 1641 | static struct ctl_table_set * |
1642 | lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) | 1642 | lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) |
1643 | { | 1643 | { |
1644 | struct ctl_table_set *set = &root->default_set; | 1644 | struct ctl_table_set *set = &root->default_set; |
1645 | if (root->lookup) | 1645 | if (root->lookup) |
1646 | set = root->lookup(root, namespaces); | 1646 | set = root->lookup(root, namespaces); |
1647 | return set; | 1647 | return set; |
1648 | } | 1648 | } |
1649 | 1649 | ||
1650 | static struct list_head * | 1650 | static struct list_head * |
1651 | lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) | 1651 | lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) |
1652 | { | 1652 | { |
1653 | struct ctl_table_set *set = lookup_header_set(root, namespaces); | 1653 | struct ctl_table_set *set = lookup_header_set(root, namespaces); |
1654 | return &set->list; | 1654 | return &set->list; |
1655 | } | 1655 | } |
1656 | 1656 | ||
1657 | struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, | 1657 | struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, |
1658 | struct ctl_table_header *prev) | 1658 | struct ctl_table_header *prev) |
1659 | { | 1659 | { |
1660 | struct ctl_table_root *root; | 1660 | struct ctl_table_root *root; |
1661 | struct list_head *header_list; | 1661 | struct list_head *header_list; |
1662 | struct ctl_table_header *head; | 1662 | struct ctl_table_header *head; |
1663 | struct list_head *tmp; | 1663 | struct list_head *tmp; |
1664 | 1664 | ||
1665 | spin_lock(&sysctl_lock); | 1665 | spin_lock(&sysctl_lock); |
1666 | if (prev) { | 1666 | if (prev) { |
1667 | head = prev; | 1667 | head = prev; |
1668 | tmp = &prev->ctl_entry; | 1668 | tmp = &prev->ctl_entry; |
1669 | unuse_table(prev); | 1669 | unuse_table(prev); |
1670 | goto next; | 1670 | goto next; |
1671 | } | 1671 | } |
1672 | tmp = &root_table_header.ctl_entry; | 1672 | tmp = &root_table_header.ctl_entry; |
1673 | for (;;) { | 1673 | for (;;) { |
1674 | head = list_entry(tmp, struct ctl_table_header, ctl_entry); | 1674 | head = list_entry(tmp, struct ctl_table_header, ctl_entry); |
1675 | 1675 | ||
1676 | if (!use_table(head)) | 1676 | if (!use_table(head)) |
1677 | goto next; | 1677 | goto next; |
1678 | spin_unlock(&sysctl_lock); | 1678 | spin_unlock(&sysctl_lock); |
1679 | return head; | 1679 | return head; |
1680 | next: | 1680 | next: |
1681 | root = head->root; | 1681 | root = head->root; |
1682 | tmp = tmp->next; | 1682 | tmp = tmp->next; |
1683 | header_list = lookup_header_list(root, namespaces); | 1683 | header_list = lookup_header_list(root, namespaces); |
1684 | if (tmp != header_list) | 1684 | if (tmp != header_list) |
1685 | continue; | 1685 | continue; |
1686 | 1686 | ||
1687 | do { | 1687 | do { |
1688 | root = list_entry(root->root_list.next, | 1688 | root = list_entry(root->root_list.next, |
1689 | struct ctl_table_root, root_list); | 1689 | struct ctl_table_root, root_list); |
1690 | if (root == &sysctl_table_root) | 1690 | if (root == &sysctl_table_root) |
1691 | goto out; | 1691 | goto out; |
1692 | header_list = lookup_header_list(root, namespaces); | 1692 | header_list = lookup_header_list(root, namespaces); |
1693 | } while (list_empty(header_list)); | 1693 | } while (list_empty(header_list)); |
1694 | tmp = header_list->next; | 1694 | tmp = header_list->next; |
1695 | } | 1695 | } |
1696 | out: | 1696 | out: |
1697 | spin_unlock(&sysctl_lock); | 1697 | spin_unlock(&sysctl_lock); |
1698 | return NULL; | 1698 | return NULL; |
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) | 1701 | struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) |
1702 | { | 1702 | { |
1703 | return __sysctl_head_next(current->nsproxy, prev); | 1703 | return __sysctl_head_next(current->nsproxy, prev); |
1704 | } | 1704 | } |
1705 | 1705 | ||
1706 | void register_sysctl_root(struct ctl_table_root *root) | 1706 | void register_sysctl_root(struct ctl_table_root *root) |
1707 | { | 1707 | { |
1708 | spin_lock(&sysctl_lock); | 1708 | spin_lock(&sysctl_lock); |
1709 | list_add_tail(&root->root_list, &sysctl_table_root.root_list); | 1709 | list_add_tail(&root->root_list, &sysctl_table_root.root_list); |
1710 | spin_unlock(&sysctl_lock); | 1710 | spin_unlock(&sysctl_lock); |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | /* | 1713 | /* |
1714 | * sysctl_perm does NOT grant the superuser all rights automatically, because | 1714 | * sysctl_perm does NOT grant the superuser all rights automatically, because |
1715 | * some sysctl variables are readonly even to root. | 1715 | * some sysctl variables are readonly even to root. |
1716 | */ | 1716 | */ |
1717 | 1717 | ||
1718 | static int test_perm(int mode, int op) | 1718 | static int test_perm(int mode, int op) |
1719 | { | 1719 | { |
1720 | if (!current_euid()) | 1720 | if (!current_euid()) |
1721 | mode >>= 6; | 1721 | mode >>= 6; |
1722 | else if (in_egroup_p(0)) | 1722 | else if (in_egroup_p(0)) |
1723 | mode >>= 3; | 1723 | mode >>= 3; |
1724 | if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) | 1724 | if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) |
1725 | return 0; | 1725 | return 0; |
1726 | return -EACCES; | 1726 | return -EACCES; |
1727 | } | 1727 | } |
1728 | 1728 | ||
1729 | int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) | 1729 | int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) |
1730 | { | 1730 | { |
1731 | int mode; | 1731 | int mode; |
1732 | 1732 | ||
1733 | if (root->permissions) | 1733 | if (root->permissions) |
1734 | mode = root->permissions(root, current->nsproxy, table); | 1734 | mode = root->permissions(root, current->nsproxy, table); |
1735 | else | 1735 | else |
1736 | mode = table->mode; | 1736 | mode = table->mode; |
1737 | 1737 | ||
1738 | return test_perm(mode, op); | 1738 | return test_perm(mode, op); |
1739 | } | 1739 | } |
1740 | 1740 | ||
1741 | static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) | 1741 | static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) |
1742 | { | 1742 | { |
1743 | for (; table->procname; table++) { | 1743 | for (; table->procname; table++) { |
1744 | table->parent = parent; | 1744 | table->parent = parent; |
1745 | if (table->child) | 1745 | if (table->child) |
1746 | sysctl_set_parent(table, table->child); | 1746 | sysctl_set_parent(table, table->child); |
1747 | } | 1747 | } |
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | static __init int sysctl_init(void) | 1750 | static __init int sysctl_init(void) |
1751 | { | 1751 | { |
1752 | sysctl_set_parent(NULL, root_table); | 1752 | sysctl_set_parent(NULL, root_table); |
1753 | #ifdef CONFIG_SYSCTL_SYSCALL_CHECK | 1753 | #ifdef CONFIG_SYSCTL_SYSCALL_CHECK |
1754 | sysctl_check_table(current->nsproxy, root_table); | 1754 | sysctl_check_table(current->nsproxy, root_table); |
1755 | #endif | 1755 | #endif |
1756 | return 0; | 1756 | return 0; |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | core_initcall(sysctl_init); | 1759 | core_initcall(sysctl_init); |
1760 | 1760 | ||
1761 | static struct ctl_table *is_branch_in(struct ctl_table *branch, | 1761 | static struct ctl_table *is_branch_in(struct ctl_table *branch, |
1762 | struct ctl_table *table) | 1762 | struct ctl_table *table) |
1763 | { | 1763 | { |
1764 | struct ctl_table *p; | 1764 | struct ctl_table *p; |
1765 | const char *s = branch->procname; | 1765 | const char *s = branch->procname; |
1766 | 1766 | ||
1767 | /* branch should have named subdirectory as its first element */ | 1767 | /* branch should have named subdirectory as its first element */ |
1768 | if (!s || !branch->child) | 1768 | if (!s || !branch->child) |
1769 | return NULL; | 1769 | return NULL; |
1770 | 1770 | ||
1771 | /* ... and nothing else */ | 1771 | /* ... and nothing else */ |
1772 | if (branch[1].procname) | 1772 | if (branch[1].procname) |
1773 | return NULL; | 1773 | return NULL; |
1774 | 1774 | ||
1775 | /* table should contain subdirectory with the same name */ | 1775 | /* table should contain subdirectory with the same name */ |
1776 | for (p = table; p->procname; p++) { | 1776 | for (p = table; p->procname; p++) { |
1777 | if (!p->child) | 1777 | if (!p->child) |
1778 | continue; | 1778 | continue; |
1779 | if (p->procname && strcmp(p->procname, s) == 0) | 1779 | if (p->procname && strcmp(p->procname, s) == 0) |
1780 | return p; | 1780 | return p; |
1781 | } | 1781 | } |
1782 | return NULL; | 1782 | return NULL; |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | /* see if attaching q to p would be an improvement */ | 1785 | /* see if attaching q to p would be an improvement */ |
1786 | static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) | 1786 | static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) |
1787 | { | 1787 | { |
1788 | struct ctl_table *to = p->ctl_table, *by = q->ctl_table; | 1788 | struct ctl_table *to = p->ctl_table, *by = q->ctl_table; |
1789 | struct ctl_table *next; | 1789 | struct ctl_table *next; |
1790 | int is_better = 0; | 1790 | int is_better = 0; |
1791 | int not_in_parent = !p->attached_by; | 1791 | int not_in_parent = !p->attached_by; |
1792 | 1792 | ||
1793 | while ((next = is_branch_in(by, to)) != NULL) { | 1793 | while ((next = is_branch_in(by, to)) != NULL) { |
1794 | if (by == q->attached_by) | 1794 | if (by == q->attached_by) |
1795 | is_better = 1; | 1795 | is_better = 1; |
1796 | if (to == p->attached_by) | 1796 | if (to == p->attached_by) |
1797 | not_in_parent = 1; | 1797 | not_in_parent = 1; |
1798 | by = by->child; | 1798 | by = by->child; |
1799 | to = next->child; | 1799 | to = next->child; |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | if (is_better && not_in_parent) { | 1802 | if (is_better && not_in_parent) { |
1803 | q->attached_by = by; | 1803 | q->attached_by = by; |
1804 | q->attached_to = to; | 1804 | q->attached_to = to; |
1805 | q->parent = p; | 1805 | q->parent = p; |
1806 | } | 1806 | } |
1807 | } | 1807 | } |
1808 | 1808 | ||
1809 | /** | 1809 | /** |
1810 | * __register_sysctl_paths - register a sysctl hierarchy | 1810 | * __register_sysctl_paths - register a sysctl hierarchy |
1811 | * @root: List of sysctl headers to register on | 1811 | * @root: List of sysctl headers to register on |
1812 | * @namespaces: Data to compute which lists of sysctl entries are visible | 1812 | * @namespaces: Data to compute which lists of sysctl entries are visible |
1813 | * @path: The path to the directory the sysctl table is in. | 1813 | * @path: The path to the directory the sysctl table is in. |
1814 | * @table: the top-level table structure | 1814 | * @table: the top-level table structure |
1815 | * | 1815 | * |
1816 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table | 1816 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table |
1817 | * array. A completely 0 filled entry terminates the table. | 1817 | * array. A completely 0 filled entry terminates the table. |
1818 | * | 1818 | * |
1819 | * The members of the &struct ctl_table structure are used as follows: | 1819 | * The members of the &struct ctl_table structure are used as follows: |
1820 | * | 1820 | * |
1821 | * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not | 1821 | * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not |
1822 | * enter a sysctl file | 1822 | * enter a sysctl file |
1823 | * | 1823 | * |
1824 | * data - a pointer to data for use by proc_handler | 1824 | * data - a pointer to data for use by proc_handler |
1825 | * | 1825 | * |
1826 | * maxlen - the maximum size in bytes of the data | 1826 | * maxlen - the maximum size in bytes of the data |
1827 | * | 1827 | * |
1828 | * mode - the file permissions for the /proc/sys file, and for sysctl(2) | 1828 | * mode - the file permissions for the /proc/sys file, and for sysctl(2) |
1829 | * | 1829 | * |
1830 | * child - a pointer to the child sysctl table if this entry is a directory, or | 1830 | * child - a pointer to the child sysctl table if this entry is a directory, or |
1831 | * %NULL. | 1831 | * %NULL. |
1832 | * | 1832 | * |
1833 | * proc_handler - the text handler routine (described below) | 1833 | * proc_handler - the text handler routine (described below) |
1834 | * | 1834 | * |
1835 | * de - for internal use by the sysctl routines | 1835 | * de - for internal use by the sysctl routines |
1836 | * | 1836 | * |
1837 | * extra1, extra2 - extra pointers usable by the proc handler routines | 1837 | * extra1, extra2 - extra pointers usable by the proc handler routines |
1838 | * | 1838 | * |
1839 | * Leaf nodes in the sysctl tree will be represented by a single file | 1839 | * Leaf nodes in the sysctl tree will be represented by a single file |
1840 | * under /proc; non-leaf nodes will be represented by directories. | 1840 | * under /proc; non-leaf nodes will be represented by directories. |
1841 | * | 1841 | * |
1842 | * sysctl(2) can automatically manage read and write requests through | 1842 | * sysctl(2) can automatically manage read and write requests through |
1843 | * the sysctl table. The data and maxlen fields of the ctl_table | 1843 | * the sysctl table. The data and maxlen fields of the ctl_table |
1844 | * struct enable minimal validation of the values being written to be | 1844 | * struct enable minimal validation of the values being written to be |
1845 | * performed, and the mode field allows minimal authentication. | 1845 | * performed, and the mode field allows minimal authentication. |
1846 | * | 1846 | * |
1847 | * There must be a proc_handler routine for any terminal nodes | 1847 | * There must be a proc_handler routine for any terminal nodes |
1848 | * mirrored under /proc/sys (non-terminals are handled by a built-in | 1848 | * mirrored under /proc/sys (non-terminals are handled by a built-in |
1849 | * directory handler). Several default handlers are available to | 1849 | * directory handler). Several default handlers are available to |
1850 | * cover common cases - | 1850 | * cover common cases - |
1851 | * | 1851 | * |
1852 | * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), | 1852 | * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), |
1853 | * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), | 1853 | * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), |
1854 | * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() | 1854 | * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() |
1855 | * | 1855 | * |
1856 | * It is the handler's job to read the input buffer from user memory | 1856 | * It is the handler's job to read the input buffer from user memory |
1857 | * and process it. The handler should return 0 on success. | 1857 | * and process it. The handler should return 0 on success. |
1858 | * | 1858 | * |
1859 | * This routine returns %NULL on a failure to register, and a pointer | 1859 | * This routine returns %NULL on a failure to register, and a pointer |
1860 | * to the table header on success. | 1860 | * to the table header on success. |
1861 | */ | 1861 | */ |
1862 | struct ctl_table_header *__register_sysctl_paths( | 1862 | struct ctl_table_header *__register_sysctl_paths( |
1863 | struct ctl_table_root *root, | 1863 | struct ctl_table_root *root, |
1864 | struct nsproxy *namespaces, | 1864 | struct nsproxy *namespaces, |
1865 | const struct ctl_path *path, struct ctl_table *table) | 1865 | const struct ctl_path *path, struct ctl_table *table) |
1866 | { | 1866 | { |
1867 | struct ctl_table_header *header; | 1867 | struct ctl_table_header *header; |
1868 | struct ctl_table *new, **prevp; | 1868 | struct ctl_table *new, **prevp; |
1869 | unsigned int n, npath; | 1869 | unsigned int n, npath; |
1870 | struct ctl_table_set *set; | 1870 | struct ctl_table_set *set; |
1871 | 1871 | ||
1872 | /* Count the path components */ | 1872 | /* Count the path components */ |
1873 | for (npath = 0; path[npath].procname; ++npath) | 1873 | for (npath = 0; path[npath].procname; ++npath) |
1874 | ; | 1874 | ; |
1875 | 1875 | ||
1876 | /* | 1876 | /* |
1877 | * For each path component, allocate a 2-element ctl_table array. | 1877 | * For each path component, allocate a 2-element ctl_table array. |
1878 | * The first array element will be filled with the sysctl entry | 1878 | * The first array element will be filled with the sysctl entry |
1879 | * for this, the second will be the sentinel (procname == 0). | 1879 | * for this, the second will be the sentinel (procname == 0). |
1880 | * | 1880 | * |
1881 | * We allocate everything in one go so that we don't have to | 1881 | * We allocate everything in one go so that we don't have to |
1882 | * worry about freeing additional memory in unregister_sysctl_table. | 1882 | * worry about freeing additional memory in unregister_sysctl_table. |
1883 | */ | 1883 | */ |
1884 | header = kzalloc(sizeof(struct ctl_table_header) + | 1884 | header = kzalloc(sizeof(struct ctl_table_header) + |
1885 | (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); | 1885 | (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); |
1886 | if (!header) | 1886 | if (!header) |
1887 | return NULL; | 1887 | return NULL; |
1888 | 1888 | ||
1889 | new = (struct ctl_table *) (header + 1); | 1889 | new = (struct ctl_table *) (header + 1); |
1890 | 1890 | ||
1891 | /* Now connect the dots */ | 1891 | /* Now connect the dots */ |
1892 | prevp = &header->ctl_table; | 1892 | prevp = &header->ctl_table; |
1893 | for (n = 0; n < npath; ++n, ++path) { | 1893 | for (n = 0; n < npath; ++n, ++path) { |
1894 | /* Copy the procname */ | 1894 | /* Copy the procname */ |
1895 | new->procname = path->procname; | 1895 | new->procname = path->procname; |
1896 | new->mode = 0555; | 1896 | new->mode = 0555; |
1897 | 1897 | ||
1898 | *prevp = new; | 1898 | *prevp = new; |
1899 | prevp = &new->child; | 1899 | prevp = &new->child; |
1900 | 1900 | ||
1901 | new += 2; | 1901 | new += 2; |
1902 | } | 1902 | } |
1903 | *prevp = table; | 1903 | *prevp = table; |
1904 | header->ctl_table_arg = table; | 1904 | header->ctl_table_arg = table; |
1905 | 1905 | ||
1906 | INIT_LIST_HEAD(&header->ctl_entry); | 1906 | INIT_LIST_HEAD(&header->ctl_entry); |
1907 | header->used = 0; | 1907 | header->used = 0; |
1908 | header->unregistering = NULL; | 1908 | header->unregistering = NULL; |
1909 | header->root = root; | 1909 | header->root = root; |
1910 | sysctl_set_parent(NULL, header->ctl_table); | 1910 | sysctl_set_parent(NULL, header->ctl_table); |
1911 | header->count = 1; | 1911 | header->count = 1; |
1912 | #ifdef CONFIG_SYSCTL_SYSCALL_CHECK | 1912 | #ifdef CONFIG_SYSCTL_SYSCALL_CHECK |
1913 | if (sysctl_check_table(namespaces, header->ctl_table)) { | 1913 | if (sysctl_check_table(namespaces, header->ctl_table)) { |
1914 | kfree(header); | 1914 | kfree(header); |
1915 | return NULL; | 1915 | return NULL; |
1916 | } | 1916 | } |
1917 | #endif | 1917 | #endif |
1918 | spin_lock(&sysctl_lock); | 1918 | spin_lock(&sysctl_lock); |
1919 | header->set = lookup_header_set(root, namespaces); | 1919 | header->set = lookup_header_set(root, namespaces); |
1920 | header->attached_by = header->ctl_table; | 1920 | header->attached_by = header->ctl_table; |
1921 | header->attached_to = root_table; | 1921 | header->attached_to = root_table; |
1922 | header->parent = &root_table_header; | 1922 | header->parent = &root_table_header; |
1923 | for (set = header->set; set; set = set->parent) { | 1923 | for (set = header->set; set; set = set->parent) { |
1924 | struct ctl_table_header *p; | 1924 | struct ctl_table_header *p; |
1925 | list_for_each_entry(p, &set->list, ctl_entry) { | 1925 | list_for_each_entry(p, &set->list, ctl_entry) { |
1926 | if (p->unregistering) | 1926 | if (p->unregistering) |
1927 | continue; | 1927 | continue; |
1928 | try_attach(p, header); | 1928 | try_attach(p, header); |
1929 | } | 1929 | } |
1930 | } | 1930 | } |
1931 | header->parent->count++; | 1931 | header->parent->count++; |
1932 | list_add_tail(&header->ctl_entry, &header->set->list); | 1932 | list_add_tail(&header->ctl_entry, &header->set->list); |
1933 | spin_unlock(&sysctl_lock); | 1933 | spin_unlock(&sysctl_lock); |
1934 | 1934 | ||
1935 | return header; | 1935 | return header; |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | /** | 1938 | /** |
1939 | * register_sysctl_table_path - register a sysctl table hierarchy | 1939 | * register_sysctl_table_path - register a sysctl table hierarchy |
1940 | * @path: The path to the directory the sysctl table is in. | 1940 | * @path: The path to the directory the sysctl table is in. |
1941 | * @table: the top-level table structure | 1941 | * @table: the top-level table structure |
1942 | * | 1942 | * |
1943 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table | 1943 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table |
1944 | * array. A completely 0 filled entry terminates the table. | 1944 | * array. A completely 0 filled entry terminates the table. |
1945 | * | 1945 | * |
1946 | * See __register_sysctl_paths for more details. | 1946 | * See __register_sysctl_paths for more details. |
1947 | */ | 1947 | */ |
1948 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, | 1948 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, |
1949 | struct ctl_table *table) | 1949 | struct ctl_table *table) |
1950 | { | 1950 | { |
1951 | return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, | 1951 | return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, |
1952 | path, table); | 1952 | path, table); |
1953 | } | 1953 | } |
1954 | 1954 | ||
1955 | /** | 1955 | /** |
1956 | * register_sysctl_table - register a sysctl table hierarchy | 1956 | * register_sysctl_table - register a sysctl table hierarchy |
1957 | * @table: the top-level table structure | 1957 | * @table: the top-level table structure |
1958 | * | 1958 | * |
1959 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table | 1959 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table |
1960 | * array. A completely 0 filled entry terminates the table. | 1960 | * array. A completely 0 filled entry terminates the table. |
1961 | * | 1961 | * |
1962 | * See register_sysctl_paths for more details. | 1962 | * See register_sysctl_paths for more details. |
1963 | */ | 1963 | */ |
1964 | struct ctl_table_header *register_sysctl_table(struct ctl_table *table) | 1964 | struct ctl_table_header *register_sysctl_table(struct ctl_table *table) |
1965 | { | 1965 | { |
1966 | static const struct ctl_path null_path[] = { {} }; | 1966 | static const struct ctl_path null_path[] = { {} }; |
1967 | 1967 | ||
1968 | return register_sysctl_paths(null_path, table); | 1968 | return register_sysctl_paths(null_path, table); |
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | /** | 1971 | /** |
1972 | * unregister_sysctl_table - unregister a sysctl table hierarchy | 1972 | * unregister_sysctl_table - unregister a sysctl table hierarchy |
1973 | * @header: the header returned from register_sysctl_table | 1973 | * @header: the header returned from register_sysctl_table |
1974 | * | 1974 | * |
1975 | * Unregisters the sysctl table and all children. proc entries may not | 1975 | * Unregisters the sysctl table and all children. proc entries may not |
1976 | * actually be removed until they are no longer used by anyone. | 1976 | * actually be removed until they are no longer used by anyone. |
1977 | */ | 1977 | */ |
1978 | void unregister_sysctl_table(struct ctl_table_header * header) | 1978 | void unregister_sysctl_table(struct ctl_table_header * header) |
1979 | { | 1979 | { |
1980 | might_sleep(); | 1980 | might_sleep(); |
1981 | 1981 | ||
1982 | if (header == NULL) | 1982 | if (header == NULL) |
1983 | return; | 1983 | return; |
1984 | 1984 | ||
1985 | spin_lock(&sysctl_lock); | 1985 | spin_lock(&sysctl_lock); |
1986 | start_unregistering(header); | 1986 | start_unregistering(header); |
1987 | if (!--header->parent->count) { | 1987 | if (!--header->parent->count) { |
1988 | WARN_ON(1); | 1988 | WARN_ON(1); |
1989 | kfree_rcu(header->parent, rcu); | 1989 | kfree_rcu(header->parent, rcu); |
1990 | } | 1990 | } |
1991 | if (!--header->count) | 1991 | if (!--header->count) |
1992 | kfree_rcu(header, rcu); | 1992 | kfree_rcu(header, rcu); |
1993 | spin_unlock(&sysctl_lock); | 1993 | spin_unlock(&sysctl_lock); |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | int sysctl_is_seen(struct ctl_table_header *p) | 1996 | int sysctl_is_seen(struct ctl_table_header *p) |
1997 | { | 1997 | { |
1998 | struct ctl_table_set *set = p->set; | 1998 | struct ctl_table_set *set = p->set; |
1999 | int res; | 1999 | int res; |
2000 | spin_lock(&sysctl_lock); | 2000 | spin_lock(&sysctl_lock); |
2001 | if (p->unregistering) | 2001 | if (p->unregistering) |
2002 | res = 0; | 2002 | res = 0; |
2003 | else if (!set->is_seen) | 2003 | else if (!set->is_seen) |
2004 | res = 1; | 2004 | res = 1; |
2005 | else | 2005 | else |
2006 | res = set->is_seen(set); | 2006 | res = set->is_seen(set); |
2007 | spin_unlock(&sysctl_lock); | 2007 | spin_unlock(&sysctl_lock); |
2008 | return res; | 2008 | return res; |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void setup_sysctl_set(struct ctl_table_set *p, | 2011 | void setup_sysctl_set(struct ctl_table_set *p, |
2012 | struct ctl_table_set *parent, | 2012 | struct ctl_table_set *parent, |
2013 | int (*is_seen)(struct ctl_table_set *)) | 2013 | int (*is_seen)(struct ctl_table_set *)) |
2014 | { | 2014 | { |
2015 | INIT_LIST_HEAD(&p->list); | 2015 | INIT_LIST_HEAD(&p->list); |
2016 | p->parent = parent ? parent : &sysctl_table_root.default_set; | 2016 | p->parent = parent ? parent : &sysctl_table_root.default_set; |
2017 | p->is_seen = is_seen; | 2017 | p->is_seen = is_seen; |
2018 | } | 2018 | } |
2019 | 2019 | ||
2020 | #else /* !CONFIG_SYSCTL */ | 2020 | #else /* !CONFIG_SYSCTL */ |
2021 | struct ctl_table_header *register_sysctl_table(struct ctl_table * table) | 2021 | struct ctl_table_header *register_sysctl_table(struct ctl_table * table) |
2022 | { | 2022 | { |
2023 | return NULL; | 2023 | return NULL; |
2024 | } | 2024 | } |
2025 | 2025 | ||
2026 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, | 2026 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, |
2027 | struct ctl_table *table) | 2027 | struct ctl_table *table) |
2028 | { | 2028 | { |
2029 | return NULL; | 2029 | return NULL; |
2030 | } | 2030 | } |
2031 | 2031 | ||
2032 | void unregister_sysctl_table(struct ctl_table_header * table) | 2032 | void unregister_sysctl_table(struct ctl_table_header * table) |
2033 | { | 2033 | { |
2034 | } | 2034 | } |
2035 | 2035 | ||
2036 | void setup_sysctl_set(struct ctl_table_set *p, | 2036 | void setup_sysctl_set(struct ctl_table_set *p, |
2037 | struct ctl_table_set *parent, | 2037 | struct ctl_table_set *parent, |
2038 | int (*is_seen)(struct ctl_table_set *)) | 2038 | int (*is_seen)(struct ctl_table_set *)) |
2039 | { | 2039 | { |
2040 | } | 2040 | } |
2041 | 2041 | ||
2042 | void sysctl_head_put(struct ctl_table_header *head) | 2042 | void sysctl_head_put(struct ctl_table_header *head) |
2043 | { | 2043 | { |
2044 | } | 2044 | } |
2045 | 2045 | ||
2046 | #endif /* CONFIG_SYSCTL */ | 2046 | #endif /* CONFIG_SYSCTL */ |
2047 | 2047 | ||
2048 | /* | 2048 | /* |
2049 | * /proc/sys support | 2049 | * /proc/sys support |
2050 | */ | 2050 | */ |
2051 | 2051 | ||
2052 | #ifdef CONFIG_PROC_SYSCTL | 2052 | #ifdef CONFIG_PROC_SYSCTL |
2053 | 2053 | ||
2054 | static int _proc_do_string(void* data, int maxlen, int write, | 2054 | static int _proc_do_string(void* data, int maxlen, int write, |
2055 | void __user *buffer, | 2055 | void __user *buffer, |
2056 | size_t *lenp, loff_t *ppos) | 2056 | size_t *lenp, loff_t *ppos) |
2057 | { | 2057 | { |
2058 | size_t len; | 2058 | size_t len; |
2059 | char __user *p; | 2059 | char __user *p; |
2060 | char c; | 2060 | char c; |
2061 | 2061 | ||
2062 | if (!data || !maxlen || !*lenp) { | 2062 | if (!data || !maxlen || !*lenp) { |
2063 | *lenp = 0; | 2063 | *lenp = 0; |
2064 | return 0; | 2064 | return 0; |
2065 | } | 2065 | } |
2066 | 2066 | ||
2067 | if (write) { | 2067 | if (write) { |
2068 | len = 0; | 2068 | len = 0; |
2069 | p = buffer; | 2069 | p = buffer; |
2070 | while (len < *lenp) { | 2070 | while (len < *lenp) { |
2071 | if (get_user(c, p++)) | 2071 | if (get_user(c, p++)) |
2072 | return -EFAULT; | 2072 | return -EFAULT; |
2073 | if (c == 0 || c == '\n') | 2073 | if (c == 0 || c == '\n') |
2074 | break; | 2074 | break; |
2075 | len++; | 2075 | len++; |
2076 | } | 2076 | } |
2077 | if (len >= maxlen) | 2077 | if (len >= maxlen) |
2078 | len = maxlen-1; | 2078 | len = maxlen-1; |
2079 | if(copy_from_user(data, buffer, len)) | 2079 | if(copy_from_user(data, buffer, len)) |
2080 | return -EFAULT; | 2080 | return -EFAULT; |
2081 | ((char *) data)[len] = 0; | 2081 | ((char *) data)[len] = 0; |
2082 | *ppos += *lenp; | 2082 | *ppos += *lenp; |
2083 | } else { | 2083 | } else { |
2084 | len = strlen(data); | 2084 | len = strlen(data); |
2085 | if (len > maxlen) | 2085 | if (len > maxlen) |
2086 | len = maxlen; | 2086 | len = maxlen; |
2087 | 2087 | ||
2088 | if (*ppos > len) { | 2088 | if (*ppos > len) { |
2089 | *lenp = 0; | 2089 | *lenp = 0; |
2090 | return 0; | 2090 | return 0; |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | data += *ppos; | 2093 | data += *ppos; |
2094 | len -= *ppos; | 2094 | len -= *ppos; |
2095 | 2095 | ||
2096 | if (len > *lenp) | 2096 | if (len > *lenp) |
2097 | len = *lenp; | 2097 | len = *lenp; |
2098 | if (len) | 2098 | if (len) |
2099 | if(copy_to_user(buffer, data, len)) | 2099 | if(copy_to_user(buffer, data, len)) |
2100 | return -EFAULT; | 2100 | return -EFAULT; |
2101 | if (len < *lenp) { | 2101 | if (len < *lenp) { |
2102 | if(put_user('\n', ((char __user *) buffer) + len)) | 2102 | if(put_user('\n', ((char __user *) buffer) + len)) |
2103 | return -EFAULT; | 2103 | return -EFAULT; |
2104 | len++; | 2104 | len++; |
2105 | } | 2105 | } |
2106 | *lenp = len; | 2106 | *lenp = len; |
2107 | *ppos += len; | 2107 | *ppos += len; |
2108 | } | 2108 | } |
2109 | return 0; | 2109 | return 0; |
2110 | } | 2110 | } |
2111 | 2111 | ||
2112 | /** | 2112 | /** |
2113 | * proc_dostring - read a string sysctl | 2113 | * proc_dostring - read a string sysctl |
2114 | * @table: the sysctl table | 2114 | * @table: the sysctl table |
2115 | * @write: %TRUE if this is a write to the sysctl file | 2115 | * @write: %TRUE if this is a write to the sysctl file |
2116 | * @buffer: the user buffer | 2116 | * @buffer: the user buffer |
2117 | * @lenp: the size of the user buffer | 2117 | * @lenp: the size of the user buffer |
2118 | * @ppos: file position | 2118 | * @ppos: file position |
2119 | * | 2119 | * |
2120 | * Reads/writes a string from/to the user buffer. If the kernel | 2120 | * Reads/writes a string from/to the user buffer. If the kernel |
2121 | * buffer provided is not large enough to hold the string, the | 2121 | * buffer provided is not large enough to hold the string, the |
2122 | * string is truncated. The copied string is %NULL-terminated. | 2122 | * string is truncated. The copied string is %NULL-terminated. |
2123 | * If the string is being read by the user process, it is copied | 2123 | * If the string is being read by the user process, it is copied |
2124 | * and a newline '\n' is added. It is truncated if the buffer is | 2124 | * and a newline '\n' is added. It is truncated if the buffer is |
2125 | * not large enough. | 2125 | * not large enough. |
2126 | * | 2126 | * |
2127 | * Returns 0 on success. | 2127 | * Returns 0 on success. |
2128 | */ | 2128 | */ |
2129 | int proc_dostring(struct ctl_table *table, int write, | 2129 | int proc_dostring(struct ctl_table *table, int write, |
2130 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2130 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2131 | { | 2131 | { |
2132 | return _proc_do_string(table->data, table->maxlen, write, | 2132 | return _proc_do_string(table->data, table->maxlen, write, |
2133 | buffer, lenp, ppos); | 2133 | buffer, lenp, ppos); |
2134 | } | 2134 | } |
2135 | 2135 | ||
2136 | static size_t proc_skip_spaces(char **buf) | 2136 | static size_t proc_skip_spaces(char **buf) |
2137 | { | 2137 | { |
2138 | size_t ret; | 2138 | size_t ret; |
2139 | char *tmp = skip_spaces(*buf); | 2139 | char *tmp = skip_spaces(*buf); |
2140 | ret = tmp - *buf; | 2140 | ret = tmp - *buf; |
2141 | *buf = tmp; | 2141 | *buf = tmp; |
2142 | return ret; | 2142 | return ret; |
2143 | } | 2143 | } |
2144 | 2144 | ||
2145 | static void proc_skip_char(char **buf, size_t *size, const char v) | 2145 | static void proc_skip_char(char **buf, size_t *size, const char v) |
2146 | { | 2146 | { |
2147 | while (*size) { | 2147 | while (*size) { |
2148 | if (**buf != v) | 2148 | if (**buf != v) |
2149 | break; | 2149 | break; |
2150 | (*size)--; | 2150 | (*size)--; |
2151 | (*buf)++; | 2151 | (*buf)++; |
2152 | } | 2152 | } |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | #define TMPBUFLEN 22 | 2155 | #define TMPBUFLEN 22 |
2156 | /** | 2156 | /** |
2157 | * proc_get_long - reads an ASCII formatted integer from a user buffer | 2157 | * proc_get_long - reads an ASCII formatted integer from a user buffer |
2158 | * | 2158 | * |
2159 | * @buf: a kernel buffer | 2159 | * @buf: a kernel buffer |
2160 | * @size: size of the kernel buffer | 2160 | * @size: size of the kernel buffer |
2161 | * @val: this is where the number will be stored | 2161 | * @val: this is where the number will be stored |
2162 | * @neg: set to %TRUE if number is negative | 2162 | * @neg: set to %TRUE if number is negative |
2163 | * @perm_tr: a vector which contains the allowed trailers | 2163 | * @perm_tr: a vector which contains the allowed trailers |
2164 | * @perm_tr_len: size of the perm_tr vector | 2164 | * @perm_tr_len: size of the perm_tr vector |
2165 | * @tr: pointer to store the trailer character | 2165 | * @tr: pointer to store the trailer character |
2166 | * | 2166 | * |
2167 | * In case of success %0 is returned and @buf and @size are updated with | 2167 | * In case of success %0 is returned and @buf and @size are updated with |
2168 | * the amount of bytes read. If @tr is non-NULL and a trailing | 2168 | * the amount of bytes read. If @tr is non-NULL and a trailing |
2169 | * character exists (size is non-zero after returning from this | 2169 | * character exists (size is non-zero after returning from this |
2170 | * function), @tr is updated with the trailing character. | 2170 | * function), @tr is updated with the trailing character. |
2171 | */ | 2171 | */ |
2172 | static int proc_get_long(char **buf, size_t *size, | 2172 | static int proc_get_long(char **buf, size_t *size, |
2173 | unsigned long *val, bool *neg, | 2173 | unsigned long *val, bool *neg, |
2174 | const char *perm_tr, unsigned perm_tr_len, char *tr) | 2174 | const char *perm_tr, unsigned perm_tr_len, char *tr) |
2175 | { | 2175 | { |
2176 | int len; | 2176 | int len; |
2177 | char *p, tmp[TMPBUFLEN]; | 2177 | char *p, tmp[TMPBUFLEN]; |
2178 | 2178 | ||
2179 | if (!*size) | 2179 | if (!*size) |
2180 | return -EINVAL; | 2180 | return -EINVAL; |
2181 | 2181 | ||
2182 | len = *size; | 2182 | len = *size; |
2183 | if (len > TMPBUFLEN - 1) | 2183 | if (len > TMPBUFLEN - 1) |
2184 | len = TMPBUFLEN - 1; | 2184 | len = TMPBUFLEN - 1; |
2185 | 2185 | ||
2186 | memcpy(tmp, *buf, len); | 2186 | memcpy(tmp, *buf, len); |
2187 | 2187 | ||
2188 | tmp[len] = 0; | 2188 | tmp[len] = 0; |
2189 | p = tmp; | 2189 | p = tmp; |
2190 | if (*p == '-' && *size > 1) { | 2190 | if (*p == '-' && *size > 1) { |
2191 | *neg = true; | 2191 | *neg = true; |
2192 | p++; | 2192 | p++; |
2193 | } else | 2193 | } else |
2194 | *neg = false; | 2194 | *neg = false; |
2195 | if (!isdigit(*p)) | 2195 | if (!isdigit(*p)) |
2196 | return -EINVAL; | 2196 | return -EINVAL; |
2197 | 2197 | ||
2198 | *val = simple_strtoul(p, &p, 0); | 2198 | *val = simple_strtoul(p, &p, 0); |
2199 | 2199 | ||
2200 | len = p - tmp; | 2200 | len = p - tmp; |
2201 | 2201 | ||
2202 | /* We don't know if the next char is whitespace thus we may accept | 2202 | /* We don't know if the next char is whitespace thus we may accept |
2203 | * invalid integers (e.g. 1234...a) or two integers instead of one | 2203 | * invalid integers (e.g. 1234...a) or two integers instead of one |
2204 | * (e.g. 123...1). So lets not allow such large numbers. */ | 2204 | * (e.g. 123...1). So lets not allow such large numbers. */ |
2205 | if (len == TMPBUFLEN - 1) | 2205 | if (len == TMPBUFLEN - 1) |
2206 | return -EINVAL; | 2206 | return -EINVAL; |
2207 | 2207 | ||
2208 | if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) | 2208 | if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) |
2209 | return -EINVAL; | 2209 | return -EINVAL; |
2210 | 2210 | ||
2211 | if (tr && (len < *size)) | 2211 | if (tr && (len < *size)) |
2212 | *tr = *p; | 2212 | *tr = *p; |
2213 | 2213 | ||
2214 | *buf += len; | 2214 | *buf += len; |
2215 | *size -= len; | 2215 | *size -= len; |
2216 | 2216 | ||
2217 | return 0; | 2217 | return 0; |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | /** | 2220 | /** |
2221 | * proc_put_long - converts an integer to a decimal ASCII formatted string | 2221 | * proc_put_long - converts an integer to a decimal ASCII formatted string |
2222 | * | 2222 | * |
2223 | * @buf: the user buffer | 2223 | * @buf: the user buffer |
2224 | * @size: the size of the user buffer | 2224 | * @size: the size of the user buffer |
2225 | * @val: the integer to be converted | 2225 | * @val: the integer to be converted |
2226 | * @neg: sign of the number, %TRUE for negative | 2226 | * @neg: sign of the number, %TRUE for negative |
2227 | * | 2227 | * |
2228 | * In case of success %0 is returned and @buf and @size are updated with | 2228 | * In case of success %0 is returned and @buf and @size are updated with |
2229 | * the amount of bytes written. | 2229 | * the amount of bytes written. |
2230 | */ | 2230 | */ |
2231 | static int proc_put_long(void __user **buf, size_t *size, unsigned long val, | 2231 | static int proc_put_long(void __user **buf, size_t *size, unsigned long val, |
2232 | bool neg) | 2232 | bool neg) |
2233 | { | 2233 | { |
2234 | int len; | 2234 | int len; |
2235 | char tmp[TMPBUFLEN], *p = tmp; | 2235 | char tmp[TMPBUFLEN], *p = tmp; |
2236 | 2236 | ||
2237 | sprintf(p, "%s%lu", neg ? "-" : "", val); | 2237 | sprintf(p, "%s%lu", neg ? "-" : "", val); |
2238 | len = strlen(tmp); | 2238 | len = strlen(tmp); |
2239 | if (len > *size) | 2239 | if (len > *size) |
2240 | len = *size; | 2240 | len = *size; |
2241 | if (copy_to_user(*buf, tmp, len)) | 2241 | if (copy_to_user(*buf, tmp, len)) |
2242 | return -EFAULT; | 2242 | return -EFAULT; |
2243 | *size -= len; | 2243 | *size -= len; |
2244 | *buf += len; | 2244 | *buf += len; |
2245 | return 0; | 2245 | return 0; |
2246 | } | 2246 | } |
2247 | #undef TMPBUFLEN | 2247 | #undef TMPBUFLEN |
2248 | 2248 | ||
2249 | static int proc_put_char(void __user **buf, size_t *size, char c) | 2249 | static int proc_put_char(void __user **buf, size_t *size, char c) |
2250 | { | 2250 | { |
2251 | if (*size) { | 2251 | if (*size) { |
2252 | char __user **buffer = (char __user **)buf; | 2252 | char __user **buffer = (char __user **)buf; |
2253 | if (put_user(c, *buffer)) | 2253 | if (put_user(c, *buffer)) |
2254 | return -EFAULT; | 2254 | return -EFAULT; |
2255 | (*size)--, (*buffer)++; | 2255 | (*size)--, (*buffer)++; |
2256 | *buf = *buffer; | 2256 | *buf = *buffer; |
2257 | } | 2257 | } |
2258 | return 0; | 2258 | return 0; |
2259 | } | 2259 | } |
2260 | 2260 | ||
2261 | static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, | 2261 | static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, |
2262 | int *valp, | 2262 | int *valp, |
2263 | int write, void *data) | 2263 | int write, void *data) |
2264 | { | 2264 | { |
2265 | if (write) { | 2265 | if (write) { |
2266 | *valp = *negp ? -*lvalp : *lvalp; | 2266 | *valp = *negp ? -*lvalp : *lvalp; |
2267 | } else { | 2267 | } else { |
2268 | int val = *valp; | 2268 | int val = *valp; |
2269 | if (val < 0) { | 2269 | if (val < 0) { |
2270 | *negp = true; | 2270 | *negp = true; |
2271 | *lvalp = (unsigned long)-val; | 2271 | *lvalp = (unsigned long)-val; |
2272 | } else { | 2272 | } else { |
2273 | *negp = false; | 2273 | *negp = false; |
2274 | *lvalp = (unsigned long)val; | 2274 | *lvalp = (unsigned long)val; |
2275 | } | 2275 | } |
2276 | } | 2276 | } |
2277 | return 0; | 2277 | return 0; |
2278 | } | 2278 | } |
2279 | 2279 | ||
2280 | static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; | 2280 | static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; |
2281 | 2281 | ||
2282 | static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, | 2282 | static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, |
2283 | int write, void __user *buffer, | 2283 | int write, void __user *buffer, |
2284 | size_t *lenp, loff_t *ppos, | 2284 | size_t *lenp, loff_t *ppos, |
2285 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, | 2285 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, |
2286 | int write, void *data), | 2286 | int write, void *data), |
2287 | void *data) | 2287 | void *data) |
2288 | { | 2288 | { |
2289 | int *i, vleft, first = 1, err = 0; | 2289 | int *i, vleft, first = 1, err = 0; |
2290 | unsigned long page = 0; | 2290 | unsigned long page = 0; |
2291 | size_t left; | 2291 | size_t left; |
2292 | char *kbuf; | 2292 | char *kbuf; |
2293 | 2293 | ||
2294 | if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { | 2294 | if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { |
2295 | *lenp = 0; | 2295 | *lenp = 0; |
2296 | return 0; | 2296 | return 0; |
2297 | } | 2297 | } |
2298 | 2298 | ||
2299 | i = (int *) tbl_data; | 2299 | i = (int *) tbl_data; |
2300 | vleft = table->maxlen / sizeof(*i); | 2300 | vleft = table->maxlen / sizeof(*i); |
2301 | left = *lenp; | 2301 | left = *lenp; |
2302 | 2302 | ||
2303 | if (!conv) | 2303 | if (!conv) |
2304 | conv = do_proc_dointvec_conv; | 2304 | conv = do_proc_dointvec_conv; |
2305 | 2305 | ||
2306 | if (write) { | 2306 | if (write) { |
2307 | if (left > PAGE_SIZE - 1) | 2307 | if (left > PAGE_SIZE - 1) |
2308 | left = PAGE_SIZE - 1; | 2308 | left = PAGE_SIZE - 1; |
2309 | page = __get_free_page(GFP_TEMPORARY); | 2309 | page = __get_free_page(GFP_TEMPORARY); |
2310 | kbuf = (char *) page; | 2310 | kbuf = (char *) page; |
2311 | if (!kbuf) | 2311 | if (!kbuf) |
2312 | return -ENOMEM; | 2312 | return -ENOMEM; |
2313 | if (copy_from_user(kbuf, buffer, left)) { | 2313 | if (copy_from_user(kbuf, buffer, left)) { |
2314 | err = -EFAULT; | 2314 | err = -EFAULT; |
2315 | goto free; | 2315 | goto free; |
2316 | } | 2316 | } |
2317 | kbuf[left] = 0; | 2317 | kbuf[left] = 0; |
2318 | } | 2318 | } |
2319 | 2319 | ||
2320 | for (; left && vleft--; i++, first=0) { | 2320 | for (; left && vleft--; i++, first=0) { |
2321 | unsigned long lval; | 2321 | unsigned long lval; |
2322 | bool neg; | 2322 | bool neg; |
2323 | 2323 | ||
2324 | if (write) { | 2324 | if (write) { |
2325 | left -= proc_skip_spaces(&kbuf); | 2325 | left -= proc_skip_spaces(&kbuf); |
2326 | 2326 | ||
2327 | if (!left) | 2327 | if (!left) |
2328 | break; | 2328 | break; |
2329 | err = proc_get_long(&kbuf, &left, &lval, &neg, | 2329 | err = proc_get_long(&kbuf, &left, &lval, &neg, |
2330 | proc_wspace_sep, | 2330 | proc_wspace_sep, |
2331 | sizeof(proc_wspace_sep), NULL); | 2331 | sizeof(proc_wspace_sep), NULL); |
2332 | if (err) | 2332 | if (err) |
2333 | break; | 2333 | break; |
2334 | if (conv(&neg, &lval, i, 1, data)) { | 2334 | if (conv(&neg, &lval, i, 1, data)) { |
2335 | err = -EINVAL; | 2335 | err = -EINVAL; |
2336 | break; | 2336 | break; |
2337 | } | 2337 | } |
2338 | } else { | 2338 | } else { |
2339 | if (conv(&neg, &lval, i, 0, data)) { | 2339 | if (conv(&neg, &lval, i, 0, data)) { |
2340 | err = -EINVAL; | 2340 | err = -EINVAL; |
2341 | break; | 2341 | break; |
2342 | } | 2342 | } |
2343 | if (!first) | 2343 | if (!first) |
2344 | err = proc_put_char(&buffer, &left, '\t'); | 2344 | err = proc_put_char(&buffer, &left, '\t'); |
2345 | if (err) | 2345 | if (err) |
2346 | break; | 2346 | break; |
2347 | err = proc_put_long(&buffer, &left, lval, neg); | 2347 | err = proc_put_long(&buffer, &left, lval, neg); |
2348 | if (err) | 2348 | if (err) |
2349 | break; | 2349 | break; |
2350 | } | 2350 | } |
2351 | } | 2351 | } |
2352 | 2352 | ||
2353 | if (!write && !first && left && !err) | 2353 | if (!write && !first && left && !err) |
2354 | err = proc_put_char(&buffer, &left, '\n'); | 2354 | err = proc_put_char(&buffer, &left, '\n'); |
2355 | if (write && !err && left) | 2355 | if (write && !err && left) |
2356 | left -= proc_skip_spaces(&kbuf); | 2356 | left -= proc_skip_spaces(&kbuf); |
2357 | free: | 2357 | free: |
2358 | if (write) { | 2358 | if (write) { |
2359 | free_page(page); | 2359 | free_page(page); |
2360 | if (first) | 2360 | if (first) |
2361 | return err ? : -EINVAL; | 2361 | return err ? : -EINVAL; |
2362 | } | 2362 | } |
2363 | *lenp -= left; | 2363 | *lenp -= left; |
2364 | *ppos += *lenp; | 2364 | *ppos += *lenp; |
2365 | return err; | 2365 | return err; |
2366 | } | 2366 | } |
2367 | 2367 | ||
2368 | static int do_proc_dointvec(struct ctl_table *table, int write, | 2368 | static int do_proc_dointvec(struct ctl_table *table, int write, |
2369 | void __user *buffer, size_t *lenp, loff_t *ppos, | 2369 | void __user *buffer, size_t *lenp, loff_t *ppos, |
2370 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, | 2370 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, |
2371 | int write, void *data), | 2371 | int write, void *data), |
2372 | void *data) | 2372 | void *data) |
2373 | { | 2373 | { |
2374 | return __do_proc_dointvec(table->data, table, write, | 2374 | return __do_proc_dointvec(table->data, table, write, |
2375 | buffer, lenp, ppos, conv, data); | 2375 | buffer, lenp, ppos, conv, data); |
2376 | } | 2376 | } |
2377 | 2377 | ||
2378 | /** | 2378 | /** |
2379 | * proc_dointvec - read a vector of integers | 2379 | * proc_dointvec - read a vector of integers |
2380 | * @table: the sysctl table | 2380 | * @table: the sysctl table |
2381 | * @write: %TRUE if this is a write to the sysctl file | 2381 | * @write: %TRUE if this is a write to the sysctl file |
2382 | * @buffer: the user buffer | 2382 | * @buffer: the user buffer |
2383 | * @lenp: the size of the user buffer | 2383 | * @lenp: the size of the user buffer |
2384 | * @ppos: file position | 2384 | * @ppos: file position |
2385 | * | 2385 | * |
2386 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | 2386 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
2387 | * values from/to the user buffer, treated as an ASCII string. | 2387 | * values from/to the user buffer, treated as an ASCII string. |
2388 | * | 2388 | * |
2389 | * Returns 0 on success. | 2389 | * Returns 0 on success. |
2390 | */ | 2390 | */ |
2391 | int proc_dointvec(struct ctl_table *table, int write, | 2391 | int proc_dointvec(struct ctl_table *table, int write, |
2392 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2392 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2393 | { | 2393 | { |
2394 | return do_proc_dointvec(table,write,buffer,lenp,ppos, | 2394 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
2395 | NULL,NULL); | 2395 | NULL,NULL); |
2396 | } | 2396 | } |
2397 | 2397 | ||
2398 | /* | 2398 | /* |
2399 | * Taint values can only be increased | 2399 | * Taint values can only be increased |
2400 | * This means we can safely use a temporary. | 2400 | * This means we can safely use a temporary. |
2401 | */ | 2401 | */ |
2402 | static int proc_taint(struct ctl_table *table, int write, | 2402 | static int proc_taint(struct ctl_table *table, int write, |
2403 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2403 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2404 | { | 2404 | { |
2405 | struct ctl_table t; | 2405 | struct ctl_table t; |
2406 | unsigned long tmptaint = get_taint(); | 2406 | unsigned long tmptaint = get_taint(); |
2407 | int err; | 2407 | int err; |
2408 | 2408 | ||
2409 | if (write && !capable(CAP_SYS_ADMIN)) | 2409 | if (write && !capable(CAP_SYS_ADMIN)) |
2410 | return -EPERM; | 2410 | return -EPERM; |
2411 | 2411 | ||
2412 | t = *table; | 2412 | t = *table; |
2413 | t.data = &tmptaint; | 2413 | t.data = &tmptaint; |
2414 | err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); | 2414 | err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); |
2415 | if (err < 0) | 2415 | if (err < 0) |
2416 | return err; | 2416 | return err; |
2417 | 2417 | ||
2418 | if (write) { | 2418 | if (write) { |
2419 | /* | 2419 | /* |
2420 | * Poor man's atomic or. Not worth adding a primitive | 2420 | * Poor man's atomic or. Not worth adding a primitive |
2421 | * to everyone's atomic.h for this | 2421 | * to everyone's atomic.h for this |
2422 | */ | 2422 | */ |
2423 | int i; | 2423 | int i; |
2424 | for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { | 2424 | for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { |
2425 | if ((tmptaint >> i) & 1) | 2425 | if ((tmptaint >> i) & 1) |
2426 | add_taint(i); | 2426 | add_taint(i); |
2427 | } | 2427 | } |
2428 | } | 2428 | } |
2429 | 2429 | ||
2430 | return err; | 2430 | return err; |
2431 | } | 2431 | } |
2432 | 2432 | ||
2433 | #ifdef CONFIG_PRINTK | 2433 | #ifdef CONFIG_PRINTK |
2434 | static int proc_dmesg_restrict(struct ctl_table *table, int write, | 2434 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, |
2435 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2435 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2436 | { | 2436 | { |
2437 | if (write && !capable(CAP_SYS_ADMIN)) | 2437 | if (write && !capable(CAP_SYS_ADMIN)) |
2438 | return -EPERM; | 2438 | return -EPERM; |
2439 | 2439 | ||
2440 | return proc_dointvec_minmax(table, write, buffer, lenp, ppos); | 2440 | return proc_dointvec_minmax(table, write, buffer, lenp, ppos); |
2441 | } | 2441 | } |
2442 | #endif | 2442 | #endif |
2443 | 2443 | ||
2444 | struct do_proc_dointvec_minmax_conv_param { | 2444 | struct do_proc_dointvec_minmax_conv_param { |
2445 | int *min; | 2445 | int *min; |
2446 | int *max; | 2446 | int *max; |
2447 | }; | 2447 | }; |
2448 | 2448 | ||
2449 | static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, | 2449 | static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, |
2450 | int *valp, | 2450 | int *valp, |
2451 | int write, void *data) | 2451 | int write, void *data) |
2452 | { | 2452 | { |
2453 | struct do_proc_dointvec_minmax_conv_param *param = data; | 2453 | struct do_proc_dointvec_minmax_conv_param *param = data; |
2454 | if (write) { | 2454 | if (write) { |
2455 | int val = *negp ? -*lvalp : *lvalp; | 2455 | int val = *negp ? -*lvalp : *lvalp; |
2456 | if ((param->min && *param->min > val) || | 2456 | if ((param->min && *param->min > val) || |
2457 | (param->max && *param->max < val)) | 2457 | (param->max && *param->max < val)) |
2458 | return -EINVAL; | 2458 | return -EINVAL; |
2459 | *valp = val; | 2459 | *valp = val; |
2460 | } else { | 2460 | } else { |
2461 | int val = *valp; | 2461 | int val = *valp; |
2462 | if (val < 0) { | 2462 | if (val < 0) { |
2463 | *negp = true; | 2463 | *negp = true; |
2464 | *lvalp = (unsigned long)-val; | 2464 | *lvalp = (unsigned long)-val; |
2465 | } else { | 2465 | } else { |
2466 | *negp = false; | 2466 | *negp = false; |
2467 | *lvalp = (unsigned long)val; | 2467 | *lvalp = (unsigned long)val; |
2468 | } | 2468 | } |
2469 | } | 2469 | } |
2470 | return 0; | 2470 | return 0; |
2471 | } | 2471 | } |
2472 | 2472 | ||
2473 | /** | 2473 | /** |
2474 | * proc_dointvec_minmax - read a vector of integers with min/max values | 2474 | * proc_dointvec_minmax - read a vector of integers with min/max values |
2475 | * @table: the sysctl table | 2475 | * @table: the sysctl table |
2476 | * @write: %TRUE if this is a write to the sysctl file | 2476 | * @write: %TRUE if this is a write to the sysctl file |
2477 | * @buffer: the user buffer | 2477 | * @buffer: the user buffer |
2478 | * @lenp: the size of the user buffer | 2478 | * @lenp: the size of the user buffer |
2479 | * @ppos: file position | 2479 | * @ppos: file position |
2480 | * | 2480 | * |
2481 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | 2481 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
2482 | * values from/to the user buffer, treated as an ASCII string. | 2482 | * values from/to the user buffer, treated as an ASCII string. |
2483 | * | 2483 | * |
2484 | * This routine will ensure the values are within the range specified by | 2484 | * This routine will ensure the values are within the range specified by |
2485 | * table->extra1 (min) and table->extra2 (max). | 2485 | * table->extra1 (min) and table->extra2 (max). |
2486 | * | 2486 | * |
2487 | * Returns 0 on success. | 2487 | * Returns 0 on success. |
2488 | */ | 2488 | */ |
2489 | int proc_dointvec_minmax(struct ctl_table *table, int write, | 2489 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
2490 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2490 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2491 | { | 2491 | { |
2492 | struct do_proc_dointvec_minmax_conv_param param = { | 2492 | struct do_proc_dointvec_minmax_conv_param param = { |
2493 | .min = (int *) table->extra1, | 2493 | .min = (int *) table->extra1, |
2494 | .max = (int *) table->extra2, | 2494 | .max = (int *) table->extra2, |
2495 | }; | 2495 | }; |
2496 | return do_proc_dointvec(table, write, buffer, lenp, ppos, | 2496 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
2497 | do_proc_dointvec_minmax_conv, ¶m); | 2497 | do_proc_dointvec_minmax_conv, ¶m); |
2498 | } | 2498 | } |
2499 | 2499 | ||
2500 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, | 2500 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, |
2501 | void __user *buffer, | 2501 | void __user *buffer, |
2502 | size_t *lenp, loff_t *ppos, | 2502 | size_t *lenp, loff_t *ppos, |
2503 | unsigned long convmul, | 2503 | unsigned long convmul, |
2504 | unsigned long convdiv) | 2504 | unsigned long convdiv) |
2505 | { | 2505 | { |
2506 | unsigned long *i, *min, *max; | 2506 | unsigned long *i, *min, *max; |
2507 | int vleft, first = 1, err = 0; | 2507 | int vleft, first = 1, err = 0; |
2508 | unsigned long page = 0; | 2508 | unsigned long page = 0; |
2509 | size_t left; | 2509 | size_t left; |
2510 | char *kbuf; | 2510 | char *kbuf; |
2511 | 2511 | ||
2512 | if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { | 2512 | if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { |
2513 | *lenp = 0; | 2513 | *lenp = 0; |
2514 | return 0; | 2514 | return 0; |
2515 | } | 2515 | } |
2516 | 2516 | ||
2517 | i = (unsigned long *) data; | 2517 | i = (unsigned long *) data; |
2518 | min = (unsigned long *) table->extra1; | 2518 | min = (unsigned long *) table->extra1; |
2519 | max = (unsigned long *) table->extra2; | 2519 | max = (unsigned long *) table->extra2; |
2520 | vleft = table->maxlen / sizeof(unsigned long); | 2520 | vleft = table->maxlen / sizeof(unsigned long); |
2521 | left = *lenp; | 2521 | left = *lenp; |
2522 | 2522 | ||
2523 | if (write) { | 2523 | if (write) { |
2524 | if (left > PAGE_SIZE - 1) | 2524 | if (left > PAGE_SIZE - 1) |
2525 | left = PAGE_SIZE - 1; | 2525 | left = PAGE_SIZE - 1; |
2526 | page = __get_free_page(GFP_TEMPORARY); | 2526 | page = __get_free_page(GFP_TEMPORARY); |
2527 | kbuf = (char *) page; | 2527 | kbuf = (char *) page; |
2528 | if (!kbuf) | 2528 | if (!kbuf) |
2529 | return -ENOMEM; | 2529 | return -ENOMEM; |
2530 | if (copy_from_user(kbuf, buffer, left)) { | 2530 | if (copy_from_user(kbuf, buffer, left)) { |
2531 | err = -EFAULT; | 2531 | err = -EFAULT; |
2532 | goto free; | 2532 | goto free; |
2533 | } | 2533 | } |
2534 | kbuf[left] = 0; | 2534 | kbuf[left] = 0; |
2535 | } | 2535 | } |
2536 | 2536 | ||
2537 | for (; left && vleft--; i++, first = 0) { | 2537 | for (; left && vleft--; i++, first = 0) { |
2538 | unsigned long val; | 2538 | unsigned long val; |
2539 | 2539 | ||
2540 | if (write) { | 2540 | if (write) { |
2541 | bool neg; | 2541 | bool neg; |
2542 | 2542 | ||
2543 | left -= proc_skip_spaces(&kbuf); | 2543 | left -= proc_skip_spaces(&kbuf); |
2544 | 2544 | ||
2545 | err = proc_get_long(&kbuf, &left, &val, &neg, | 2545 | err = proc_get_long(&kbuf, &left, &val, &neg, |
2546 | proc_wspace_sep, | 2546 | proc_wspace_sep, |
2547 | sizeof(proc_wspace_sep), NULL); | 2547 | sizeof(proc_wspace_sep), NULL); |
2548 | if (err) | 2548 | if (err) |
2549 | break; | 2549 | break; |
2550 | if (neg) | 2550 | if (neg) |
2551 | continue; | 2551 | continue; |
2552 | if ((min && val < *min) || (max && val > *max)) | 2552 | if ((min && val < *min) || (max && val > *max)) |
2553 | continue; | 2553 | continue; |
2554 | *i = val; | 2554 | *i = val; |
2555 | } else { | 2555 | } else { |
2556 | val = convdiv * (*i) / convmul; | 2556 | val = convdiv * (*i) / convmul; |
2557 | if (!first) | 2557 | if (!first) |
2558 | err = proc_put_char(&buffer, &left, '\t'); | 2558 | err = proc_put_char(&buffer, &left, '\t'); |
2559 | err = proc_put_long(&buffer, &left, val, false); | 2559 | err = proc_put_long(&buffer, &left, val, false); |
2560 | if (err) | 2560 | if (err) |
2561 | break; | 2561 | break; |
2562 | } | 2562 | } |
2563 | } | 2563 | } |
2564 | 2564 | ||
2565 | if (!write && !first && left && !err) | 2565 | if (!write && !first && left && !err) |
2566 | err = proc_put_char(&buffer, &left, '\n'); | 2566 | err = proc_put_char(&buffer, &left, '\n'); |
2567 | if (write && !err) | 2567 | if (write && !err) |
2568 | left -= proc_skip_spaces(&kbuf); | 2568 | left -= proc_skip_spaces(&kbuf); |
2569 | free: | 2569 | free: |
2570 | if (write) { | 2570 | if (write) { |
2571 | free_page(page); | 2571 | free_page(page); |
2572 | if (first) | 2572 | if (first) |
2573 | return err ? : -EINVAL; | 2573 | return err ? : -EINVAL; |
2574 | } | 2574 | } |
2575 | *lenp -= left; | 2575 | *lenp -= left; |
2576 | *ppos += *lenp; | 2576 | *ppos += *lenp; |
2577 | return err; | 2577 | return err; |
2578 | } | 2578 | } |
2579 | 2579 | ||
2580 | static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, | 2580 | static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, |
2581 | void __user *buffer, | 2581 | void __user *buffer, |
2582 | size_t *lenp, loff_t *ppos, | 2582 | size_t *lenp, loff_t *ppos, |
2583 | unsigned long convmul, | 2583 | unsigned long convmul, |
2584 | unsigned long convdiv) | 2584 | unsigned long convdiv) |
2585 | { | 2585 | { |
2586 | return __do_proc_doulongvec_minmax(table->data, table, write, | 2586 | return __do_proc_doulongvec_minmax(table->data, table, write, |
2587 | buffer, lenp, ppos, convmul, convdiv); | 2587 | buffer, lenp, ppos, convmul, convdiv); |
2588 | } | 2588 | } |
2589 | 2589 | ||
2590 | /** | 2590 | /** |
2591 | * proc_doulongvec_minmax - read a vector of long integers with min/max values | 2591 | * proc_doulongvec_minmax - read a vector of long integers with min/max values |
2592 | * @table: the sysctl table | 2592 | * @table: the sysctl table |
2593 | * @write: %TRUE if this is a write to the sysctl file | 2593 | * @write: %TRUE if this is a write to the sysctl file |
2594 | * @buffer: the user buffer | 2594 | * @buffer: the user buffer |
2595 | * @lenp: the size of the user buffer | 2595 | * @lenp: the size of the user buffer |
2596 | * @ppos: file position | 2596 | * @ppos: file position |
2597 | * | 2597 | * |
2598 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long | 2598 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long |
2599 | * values from/to the user buffer, treated as an ASCII string. | 2599 | * values from/to the user buffer, treated as an ASCII string. |
2600 | * | 2600 | * |
2601 | * This routine will ensure the values are within the range specified by | 2601 | * This routine will ensure the values are within the range specified by |
2602 | * table->extra1 (min) and table->extra2 (max). | 2602 | * table->extra1 (min) and table->extra2 (max). |
2603 | * | 2603 | * |
2604 | * Returns 0 on success. | 2604 | * Returns 0 on success. |
2605 | */ | 2605 | */ |
2606 | int proc_doulongvec_minmax(struct ctl_table *table, int write, | 2606 | int proc_doulongvec_minmax(struct ctl_table *table, int write, |
2607 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2607 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2608 | { | 2608 | { |
2609 | return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); | 2609 | return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); |
2610 | } | 2610 | } |
2611 | 2611 | ||
2612 | /** | 2612 | /** |
2613 | * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values | 2613 | * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values |
2614 | * @table: the sysctl table | 2614 | * @table: the sysctl table |
2615 | * @write: %TRUE if this is a write to the sysctl file | 2615 | * @write: %TRUE if this is a write to the sysctl file |
2616 | * @buffer: the user buffer | 2616 | * @buffer: the user buffer |
2617 | * @lenp: the size of the user buffer | 2617 | * @lenp: the size of the user buffer |
2618 | * @ppos: file position | 2618 | * @ppos: file position |
2619 | * | 2619 | * |
2620 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long | 2620 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long |
2621 | * values from/to the user buffer, treated as an ASCII string. The values | 2621 | * values from/to the user buffer, treated as an ASCII string. The values |
2622 | * are treated as milliseconds, and converted to jiffies when they are stored. | 2622 | * are treated as milliseconds, and converted to jiffies when they are stored. |
2623 | * | 2623 | * |
2624 | * This routine will ensure the values are within the range specified by | 2624 | * This routine will ensure the values are within the range specified by |
2625 | * table->extra1 (min) and table->extra2 (max). | 2625 | * table->extra1 (min) and table->extra2 (max). |
2626 | * | 2626 | * |
2627 | * Returns 0 on success. | 2627 | * Returns 0 on success. |
2628 | */ | 2628 | */ |
2629 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, | 2629 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
2630 | void __user *buffer, | 2630 | void __user *buffer, |
2631 | size_t *lenp, loff_t *ppos) | 2631 | size_t *lenp, loff_t *ppos) |
2632 | { | 2632 | { |
2633 | return do_proc_doulongvec_minmax(table, write, buffer, | 2633 | return do_proc_doulongvec_minmax(table, write, buffer, |
2634 | lenp, ppos, HZ, 1000l); | 2634 | lenp, ppos, HZ, 1000l); |
2635 | } | 2635 | } |
2636 | 2636 | ||
2637 | 2637 | ||
2638 | static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, | 2638 | static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, |
2639 | int *valp, | 2639 | int *valp, |
2640 | int write, void *data) | 2640 | int write, void *data) |
2641 | { | 2641 | { |
2642 | if (write) { | 2642 | if (write) { |
2643 | if (*lvalp > LONG_MAX / HZ) | 2643 | if (*lvalp > LONG_MAX / HZ) |
2644 | return 1; | 2644 | return 1; |
2645 | *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); | 2645 | *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); |
2646 | } else { | 2646 | } else { |
2647 | int val = *valp; | 2647 | int val = *valp; |
2648 | unsigned long lval; | 2648 | unsigned long lval; |
2649 | if (val < 0) { | 2649 | if (val < 0) { |
2650 | *negp = true; | 2650 | *negp = true; |
2651 | lval = (unsigned long)-val; | 2651 | lval = (unsigned long)-val; |
2652 | } else { | 2652 | } else { |
2653 | *negp = false; | 2653 | *negp = false; |
2654 | lval = (unsigned long)val; | 2654 | lval = (unsigned long)val; |
2655 | } | 2655 | } |
2656 | *lvalp = lval / HZ; | 2656 | *lvalp = lval / HZ; |
2657 | } | 2657 | } |
2658 | return 0; | 2658 | return 0; |
2659 | } | 2659 | } |
2660 | 2660 | ||
2661 | static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, | 2661 | static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, |
2662 | int *valp, | 2662 | int *valp, |
2663 | int write, void *data) | 2663 | int write, void *data) |
2664 | { | 2664 | { |
2665 | if (write) { | 2665 | if (write) { |
2666 | if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) | 2666 | if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) |
2667 | return 1; | 2667 | return 1; |
2668 | *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); | 2668 | *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); |
2669 | } else { | 2669 | } else { |
2670 | int val = *valp; | 2670 | int val = *valp; |
2671 | unsigned long lval; | 2671 | unsigned long lval; |
2672 | if (val < 0) { | 2672 | if (val < 0) { |
2673 | *negp = true; | 2673 | *negp = true; |
2674 | lval = (unsigned long)-val; | 2674 | lval = (unsigned long)-val; |
2675 | } else { | 2675 | } else { |
2676 | *negp = false; | 2676 | *negp = false; |
2677 | lval = (unsigned long)val; | 2677 | lval = (unsigned long)val; |
2678 | } | 2678 | } |
2679 | *lvalp = jiffies_to_clock_t(lval); | 2679 | *lvalp = jiffies_to_clock_t(lval); |
2680 | } | 2680 | } |
2681 | return 0; | 2681 | return 0; |
2682 | } | 2682 | } |
2683 | 2683 | ||
2684 | static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, | 2684 | static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, |
2685 | int *valp, | 2685 | int *valp, |
2686 | int write, void *data) | 2686 | int write, void *data) |
2687 | { | 2687 | { |
2688 | if (write) { | 2688 | if (write) { |
2689 | *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); | 2689 | *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); |
2690 | } else { | 2690 | } else { |
2691 | int val = *valp; | 2691 | int val = *valp; |
2692 | unsigned long lval; | 2692 | unsigned long lval; |
2693 | if (val < 0) { | 2693 | if (val < 0) { |
2694 | *negp = true; | 2694 | *negp = true; |
2695 | lval = (unsigned long)-val; | 2695 | lval = (unsigned long)-val; |
2696 | } else { | 2696 | } else { |
2697 | *negp = false; | 2697 | *negp = false; |
2698 | lval = (unsigned long)val; | 2698 | lval = (unsigned long)val; |
2699 | } | 2699 | } |
2700 | *lvalp = jiffies_to_msecs(lval); | 2700 | *lvalp = jiffies_to_msecs(lval); |
2701 | } | 2701 | } |
2702 | return 0; | 2702 | return 0; |
2703 | } | 2703 | } |
2704 | 2704 | ||
2705 | /** | 2705 | /** |
2706 | * proc_dointvec_jiffies - read a vector of integers as seconds | 2706 | * proc_dointvec_jiffies - read a vector of integers as seconds |
2707 | * @table: the sysctl table | 2707 | * @table: the sysctl table |
2708 | * @write: %TRUE if this is a write to the sysctl file | 2708 | * @write: %TRUE if this is a write to the sysctl file |
2709 | * @buffer: the user buffer | 2709 | * @buffer: the user buffer |
2710 | * @lenp: the size of the user buffer | 2710 | * @lenp: the size of the user buffer |
2711 | * @ppos: file position | 2711 | * @ppos: file position |
2712 | * | 2712 | * |
2713 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | 2713 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
2714 | * values from/to the user buffer, treated as an ASCII string. | 2714 | * values from/to the user buffer, treated as an ASCII string. |
2715 | * The values read are assumed to be in seconds, and are converted into | 2715 | * The values read are assumed to be in seconds, and are converted into |
2716 | * jiffies. | 2716 | * jiffies. |
2717 | * | 2717 | * |
2718 | * Returns 0 on success. | 2718 | * Returns 0 on success. |
2719 | */ | 2719 | */ |
2720 | int proc_dointvec_jiffies(struct ctl_table *table, int write, | 2720 | int proc_dointvec_jiffies(struct ctl_table *table, int write, |
2721 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2721 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2722 | { | 2722 | { |
2723 | return do_proc_dointvec(table,write,buffer,lenp,ppos, | 2723 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
2724 | do_proc_dointvec_jiffies_conv,NULL); | 2724 | do_proc_dointvec_jiffies_conv,NULL); |
2725 | } | 2725 | } |
2726 | 2726 | ||
2727 | /** | 2727 | /** |
2728 | * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds | 2728 | * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds |
2729 | * @table: the sysctl table | 2729 | * @table: the sysctl table |
2730 | * @write: %TRUE if this is a write to the sysctl file | 2730 | * @write: %TRUE if this is a write to the sysctl file |
2731 | * @buffer: the user buffer | 2731 | * @buffer: the user buffer |
2732 | * @lenp: the size of the user buffer | 2732 | * @lenp: the size of the user buffer |
2733 | * @ppos: pointer to the file position | 2733 | * @ppos: pointer to the file position |
2734 | * | 2734 | * |
2735 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | 2735 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
2736 | * values from/to the user buffer, treated as an ASCII string. | 2736 | * values from/to the user buffer, treated as an ASCII string. |
2737 | * The values read are assumed to be in 1/USER_HZ seconds, and | 2737 | * The values read are assumed to be in 1/USER_HZ seconds, and |
2738 | * are converted into jiffies. | 2738 | * are converted into jiffies. |
2739 | * | 2739 | * |
2740 | * Returns 0 on success. | 2740 | * Returns 0 on success. |
2741 | */ | 2741 | */ |
2742 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, | 2742 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, |
2743 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2743 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2744 | { | 2744 | { |
2745 | return do_proc_dointvec(table,write,buffer,lenp,ppos, | 2745 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
2746 | do_proc_dointvec_userhz_jiffies_conv,NULL); | 2746 | do_proc_dointvec_userhz_jiffies_conv,NULL); |
2747 | } | 2747 | } |
2748 | 2748 | ||
2749 | /** | 2749 | /** |
2750 | * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds | 2750 | * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds |
2751 | * @table: the sysctl table | 2751 | * @table: the sysctl table |
2752 | * @write: %TRUE if this is a write to the sysctl file | 2752 | * @write: %TRUE if this is a write to the sysctl file |
2753 | * @buffer: the user buffer | 2753 | * @buffer: the user buffer |
2754 | * @lenp: the size of the user buffer | 2754 | * @lenp: the size of the user buffer |
2755 | * @ppos: file position | 2755 | * @ppos: file position |
2756 | * @ppos: the current position in the file | 2756 | * @ppos: the current position in the file |
2757 | * | 2757 | * |
2758 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | 2758 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
2759 | * values from/to the user buffer, treated as an ASCII string. | 2759 | * values from/to the user buffer, treated as an ASCII string. |
2760 | * The values read are assumed to be in 1/1000 seconds, and | 2760 | * The values read are assumed to be in 1/1000 seconds, and |
2761 | * are converted into jiffies. | 2761 | * are converted into jiffies. |
2762 | * | 2762 | * |
2763 | * Returns 0 on success. | 2763 | * Returns 0 on success. |
2764 | */ | 2764 | */ |
2765 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, | 2765 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, |
2766 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2766 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2767 | { | 2767 | { |
2768 | return do_proc_dointvec(table, write, buffer, lenp, ppos, | 2768 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
2769 | do_proc_dointvec_ms_jiffies_conv, NULL); | 2769 | do_proc_dointvec_ms_jiffies_conv, NULL); |
2770 | } | 2770 | } |
2771 | 2771 | ||
2772 | static int proc_do_cad_pid(struct ctl_table *table, int write, | 2772 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
2773 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2773 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2774 | { | 2774 | { |
2775 | struct pid *new_pid; | 2775 | struct pid *new_pid; |
2776 | pid_t tmp; | 2776 | pid_t tmp; |
2777 | int r; | 2777 | int r; |
2778 | 2778 | ||
2779 | tmp = pid_vnr(cad_pid); | 2779 | tmp = pid_vnr(cad_pid); |
2780 | 2780 | ||
2781 | r = __do_proc_dointvec(&tmp, table, write, buffer, | 2781 | r = __do_proc_dointvec(&tmp, table, write, buffer, |
2782 | lenp, ppos, NULL, NULL); | 2782 | lenp, ppos, NULL, NULL); |
2783 | if (r || !write) | 2783 | if (r || !write) |
2784 | return r; | 2784 | return r; |
2785 | 2785 | ||
2786 | new_pid = find_get_pid(tmp); | 2786 | new_pid = find_get_pid(tmp); |
2787 | if (!new_pid) | 2787 | if (!new_pid) |
2788 | return -ESRCH; | 2788 | return -ESRCH; |
2789 | 2789 | ||
2790 | put_pid(xchg(&cad_pid, new_pid)); | 2790 | put_pid(xchg(&cad_pid, new_pid)); |
2791 | return 0; | 2791 | return 0; |
2792 | } | 2792 | } |
2793 | 2793 | ||
2794 | /** | 2794 | /** |
2795 | * proc_do_large_bitmap - read/write from/to a large bitmap | 2795 | * proc_do_large_bitmap - read/write from/to a large bitmap |
2796 | * @table: the sysctl table | 2796 | * @table: the sysctl table |
2797 | * @write: %TRUE if this is a write to the sysctl file | 2797 | * @write: %TRUE if this is a write to the sysctl file |
2798 | * @buffer: the user buffer | 2798 | * @buffer: the user buffer |
2799 | * @lenp: the size of the user buffer | 2799 | * @lenp: the size of the user buffer |
2800 | * @ppos: file position | 2800 | * @ppos: file position |
2801 | * | 2801 | * |
2802 | * The bitmap is stored at table->data and the bitmap length (in bits) | 2802 | * The bitmap is stored at table->data and the bitmap length (in bits) |
2803 | * in table->maxlen. | 2803 | * in table->maxlen. |
2804 | * | 2804 | * |
2805 | * We use a range comma separated format (e.g. 1,3-4,10-10) so that | 2805 | * We use a range comma separated format (e.g. 1,3-4,10-10) so that |
2806 | * large bitmaps may be represented in a compact manner. Writing into | 2806 | * large bitmaps may be represented in a compact manner. Writing into |
2807 | * the file will clear the bitmap then update it with the given input. | 2807 | * the file will clear the bitmap then update it with the given input. |
2808 | * | 2808 | * |
2809 | * Returns 0 on success. | 2809 | * Returns 0 on success. |
2810 | */ | 2810 | */ |
2811 | int proc_do_large_bitmap(struct ctl_table *table, int write, | 2811 | int proc_do_large_bitmap(struct ctl_table *table, int write, |
2812 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2812 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2813 | { | 2813 | { |
2814 | int err = 0; | 2814 | int err = 0; |
2815 | bool first = 1; | 2815 | bool first = 1; |
2816 | size_t left = *lenp; | 2816 | size_t left = *lenp; |
2817 | unsigned long bitmap_len = table->maxlen; | 2817 | unsigned long bitmap_len = table->maxlen; |
2818 | unsigned long *bitmap = (unsigned long *) table->data; | 2818 | unsigned long *bitmap = (unsigned long *) table->data; |
2819 | unsigned long *tmp_bitmap = NULL; | 2819 | unsigned long *tmp_bitmap = NULL; |
2820 | char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; | 2820 | char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; |
2821 | 2821 | ||
2822 | if (!bitmap_len || !left || (*ppos && !write)) { | 2822 | if (!bitmap_len || !left || (*ppos && !write)) { |
2823 | *lenp = 0; | 2823 | *lenp = 0; |
2824 | return 0; | 2824 | return 0; |
2825 | } | 2825 | } |
2826 | 2826 | ||
2827 | if (write) { | 2827 | if (write) { |
2828 | unsigned long page = 0; | 2828 | unsigned long page = 0; |
2829 | char *kbuf; | 2829 | char *kbuf; |
2830 | 2830 | ||
2831 | if (left > PAGE_SIZE - 1) | 2831 | if (left > PAGE_SIZE - 1) |
2832 | left = PAGE_SIZE - 1; | 2832 | left = PAGE_SIZE - 1; |
2833 | 2833 | ||
2834 | page = __get_free_page(GFP_TEMPORARY); | 2834 | page = __get_free_page(GFP_TEMPORARY); |
2835 | kbuf = (char *) page; | 2835 | kbuf = (char *) page; |
2836 | if (!kbuf) | 2836 | if (!kbuf) |
2837 | return -ENOMEM; | 2837 | return -ENOMEM; |
2838 | if (copy_from_user(kbuf, buffer, left)) { | 2838 | if (copy_from_user(kbuf, buffer, left)) { |
2839 | free_page(page); | 2839 | free_page(page); |
2840 | return -EFAULT; | 2840 | return -EFAULT; |
2841 | } | 2841 | } |
2842 | kbuf[left] = 0; | 2842 | kbuf[left] = 0; |
2843 | 2843 | ||
2844 | tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), | 2844 | tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), |
2845 | GFP_KERNEL); | 2845 | GFP_KERNEL); |
2846 | if (!tmp_bitmap) { | 2846 | if (!tmp_bitmap) { |
2847 | free_page(page); | 2847 | free_page(page); |
2848 | return -ENOMEM; | 2848 | return -ENOMEM; |
2849 | } | 2849 | } |
2850 | proc_skip_char(&kbuf, &left, '\n'); | 2850 | proc_skip_char(&kbuf, &left, '\n'); |
2851 | while (!err && left) { | 2851 | while (!err && left) { |
2852 | unsigned long val_a, val_b; | 2852 | unsigned long val_a, val_b; |
2853 | bool neg; | 2853 | bool neg; |
2854 | 2854 | ||
2855 | err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a, | 2855 | err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a, |
2856 | sizeof(tr_a), &c); | 2856 | sizeof(tr_a), &c); |
2857 | if (err) | 2857 | if (err) |
2858 | break; | 2858 | break; |
2859 | if (val_a >= bitmap_len || neg) { | 2859 | if (val_a >= bitmap_len || neg) { |
2860 | err = -EINVAL; | 2860 | err = -EINVAL; |
2861 | break; | 2861 | break; |
2862 | } | 2862 | } |
2863 | 2863 | ||
2864 | val_b = val_a; | 2864 | val_b = val_a; |
2865 | if (left) { | 2865 | if (left) { |
2866 | kbuf++; | 2866 | kbuf++; |
2867 | left--; | 2867 | left--; |
2868 | } | 2868 | } |
2869 | 2869 | ||
2870 | if (c == '-') { | 2870 | if (c == '-') { |
2871 | err = proc_get_long(&kbuf, &left, &val_b, | 2871 | err = proc_get_long(&kbuf, &left, &val_b, |
2872 | &neg, tr_b, sizeof(tr_b), | 2872 | &neg, tr_b, sizeof(tr_b), |
2873 | &c); | 2873 | &c); |
2874 | if (err) | 2874 | if (err) |
2875 | break; | 2875 | break; |
2876 | if (val_b >= bitmap_len || neg || | 2876 | if (val_b >= bitmap_len || neg || |
2877 | val_a > val_b) { | 2877 | val_a > val_b) { |
2878 | err = -EINVAL; | 2878 | err = -EINVAL; |
2879 | break; | 2879 | break; |
2880 | } | 2880 | } |
2881 | if (left) { | 2881 | if (left) { |
2882 | kbuf++; | 2882 | kbuf++; |
2883 | left--; | 2883 | left--; |
2884 | } | 2884 | } |
2885 | } | 2885 | } |
2886 | 2886 | ||
2887 | while (val_a <= val_b) | 2887 | while (val_a <= val_b) |
2888 | set_bit(val_a++, tmp_bitmap); | 2888 | set_bit(val_a++, tmp_bitmap); |
2889 | 2889 | ||
2890 | first = 0; | 2890 | first = 0; |
2891 | proc_skip_char(&kbuf, &left, '\n'); | 2891 | proc_skip_char(&kbuf, &left, '\n'); |
2892 | } | 2892 | } |
2893 | free_page(page); | 2893 | free_page(page); |
2894 | } else { | 2894 | } else { |
2895 | unsigned long bit_a, bit_b = 0; | 2895 | unsigned long bit_a, bit_b = 0; |
2896 | 2896 | ||
2897 | while (left) { | 2897 | while (left) { |
2898 | bit_a = find_next_bit(bitmap, bitmap_len, bit_b); | 2898 | bit_a = find_next_bit(bitmap, bitmap_len, bit_b); |
2899 | if (bit_a >= bitmap_len) | 2899 | if (bit_a >= bitmap_len) |
2900 | break; | 2900 | break; |
2901 | bit_b = find_next_zero_bit(bitmap, bitmap_len, | 2901 | bit_b = find_next_zero_bit(bitmap, bitmap_len, |
2902 | bit_a + 1) - 1; | 2902 | bit_a + 1) - 1; |
2903 | 2903 | ||
2904 | if (!first) { | 2904 | if (!first) { |
2905 | err = proc_put_char(&buffer, &left, ','); | 2905 | err = proc_put_char(&buffer, &left, ','); |
2906 | if (err) | 2906 | if (err) |
2907 | break; | 2907 | break; |
2908 | } | 2908 | } |
2909 | err = proc_put_long(&buffer, &left, bit_a, false); | 2909 | err = proc_put_long(&buffer, &left, bit_a, false); |
2910 | if (err) | 2910 | if (err) |
2911 | break; | 2911 | break; |
2912 | if (bit_a != bit_b) { | 2912 | if (bit_a != bit_b) { |
2913 | err = proc_put_char(&buffer, &left, '-'); | 2913 | err = proc_put_char(&buffer, &left, '-'); |
2914 | if (err) | 2914 | if (err) |
2915 | break; | 2915 | break; |
2916 | err = proc_put_long(&buffer, &left, bit_b, false); | 2916 | err = proc_put_long(&buffer, &left, bit_b, false); |
2917 | if (err) | 2917 | if (err) |
2918 | break; | 2918 | break; |
2919 | } | 2919 | } |
2920 | 2920 | ||
2921 | first = 0; bit_b++; | 2921 | first = 0; bit_b++; |
2922 | } | 2922 | } |
2923 | if (!err) | 2923 | if (!err) |
2924 | err = proc_put_char(&buffer, &left, '\n'); | 2924 | err = proc_put_char(&buffer, &left, '\n'); |
2925 | } | 2925 | } |
2926 | 2926 | ||
2927 | if (!err) { | 2927 | if (!err) { |
2928 | if (write) { | 2928 | if (write) { |
2929 | if (*ppos) | 2929 | if (*ppos) |
2930 | bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); | 2930 | bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); |
2931 | else | 2931 | else |
2932 | memcpy(bitmap, tmp_bitmap, | 2932 | memcpy(bitmap, tmp_bitmap, |
2933 | BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long)); | 2933 | BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long)); |
2934 | } | 2934 | } |
2935 | kfree(tmp_bitmap); | 2935 | kfree(tmp_bitmap); |
2936 | *lenp -= left; | 2936 | *lenp -= left; |
2937 | *ppos += *lenp; | 2937 | *ppos += *lenp; |
2938 | return 0; | 2938 | return 0; |
2939 | } else { | 2939 | } else { |
2940 | kfree(tmp_bitmap); | 2940 | kfree(tmp_bitmap); |
2941 | return err; | 2941 | return err; |
2942 | } | 2942 | } |
2943 | } | 2943 | } |
2944 | 2944 | ||
2945 | #else /* CONFIG_PROC_SYSCTL */ | 2945 | #else /* CONFIG_PROC_SYSCTL */ |
2946 | 2946 | ||
2947 | int proc_dostring(struct ctl_table *table, int write, | 2947 | int proc_dostring(struct ctl_table *table, int write, |
2948 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2948 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2949 | { | 2949 | { |
2950 | return -ENOSYS; | 2950 | return -ENOSYS; |
2951 | } | 2951 | } |
2952 | 2952 | ||
2953 | int proc_dointvec(struct ctl_table *table, int write, | 2953 | int proc_dointvec(struct ctl_table *table, int write, |
2954 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2954 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2955 | { | 2955 | { |
2956 | return -ENOSYS; | 2956 | return -ENOSYS; |
2957 | } | 2957 | } |
2958 | 2958 | ||
2959 | int proc_dointvec_minmax(struct ctl_table *table, int write, | 2959 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
2960 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2960 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2961 | { | 2961 | { |
2962 | return -ENOSYS; | 2962 | return -ENOSYS; |
2963 | } | 2963 | } |
2964 | 2964 | ||
2965 | int proc_dointvec_jiffies(struct ctl_table *table, int write, | 2965 | int proc_dointvec_jiffies(struct ctl_table *table, int write, |
2966 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2966 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2967 | { | 2967 | { |
2968 | return -ENOSYS; | 2968 | return -ENOSYS; |
2969 | } | 2969 | } |
2970 | 2970 | ||
2971 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, | 2971 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, |
2972 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2972 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2973 | { | 2973 | { |
2974 | return -ENOSYS; | 2974 | return -ENOSYS; |
2975 | } | 2975 | } |
2976 | 2976 | ||
2977 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, | 2977 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, |
2978 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2978 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2979 | { | 2979 | { |
2980 | return -ENOSYS; | 2980 | return -ENOSYS; |
2981 | } | 2981 | } |
2982 | 2982 | ||
2983 | int proc_doulongvec_minmax(struct ctl_table *table, int write, | 2983 | int proc_doulongvec_minmax(struct ctl_table *table, int write, |
2984 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2984 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2985 | { | 2985 | { |
2986 | return -ENOSYS; | 2986 | return -ENOSYS; |
2987 | } | 2987 | } |
2988 | 2988 | ||
2989 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, | 2989 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
2990 | void __user *buffer, | 2990 | void __user *buffer, |
2991 | size_t *lenp, loff_t *ppos) | 2991 | size_t *lenp, loff_t *ppos) |
2992 | { | 2992 | { |
2993 | return -ENOSYS; | 2993 | return -ENOSYS; |
2994 | } | 2994 | } |
2995 | 2995 | ||
2996 | 2996 | ||
2997 | #endif /* CONFIG_PROC_SYSCTL */ | 2997 | #endif /* CONFIG_PROC_SYSCTL */ |
2998 | 2998 | ||
2999 | /* | 2999 | /* |
3000 | * No sense putting this after each symbol definition, twice, | 3000 | * No sense putting this after each symbol definition, twice, |
3001 | * exception granted :-) | 3001 | * exception granted :-) |
3002 | */ | 3002 | */ |
3003 | EXPORT_SYMBOL(proc_dointvec); | 3003 | EXPORT_SYMBOL(proc_dointvec); |
3004 | EXPORT_SYMBOL(proc_dointvec_jiffies); | 3004 | EXPORT_SYMBOL(proc_dointvec_jiffies); |
3005 | EXPORT_SYMBOL(proc_dointvec_minmax); | 3005 | EXPORT_SYMBOL(proc_dointvec_minmax); |
3006 | EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); | 3006 | EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); |
3007 | EXPORT_SYMBOL(proc_dointvec_ms_jiffies); | 3007 | EXPORT_SYMBOL(proc_dointvec_ms_jiffies); |
3008 | EXPORT_SYMBOL(proc_dostring); | 3008 | EXPORT_SYMBOL(proc_dostring); |
3009 | EXPORT_SYMBOL(proc_doulongvec_minmax); | 3009 | EXPORT_SYMBOL(proc_doulongvec_minmax); |
3010 | EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); | 3010 | EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); |
3011 | EXPORT_SYMBOL(register_sysctl_table); | 3011 | EXPORT_SYMBOL(register_sysctl_table); |
3012 | EXPORT_SYMBOL(register_sysctl_paths); | 3012 | EXPORT_SYMBOL(register_sysctl_paths); |
3013 | EXPORT_SYMBOL(unregister_sysctl_table); | 3013 | EXPORT_SYMBOL(unregister_sysctl_table); |
3014 | 3014 |