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