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