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