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