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