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