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