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