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