]>
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 | }, | |
bc7a34b8 | 1207 | #endif |
6fce56ec | 1208 | { } |
1da177e4 LT |
1209 | }; |
1210 | ||
d8217f07 | 1211 | static struct ctl_table vm_table[] = { |
1da177e4 | 1212 | { |
1da177e4 LT |
1213 | .procname = "overcommit_memory", |
1214 | .data = &sysctl_overcommit_memory, | |
1215 | .maxlen = sizeof(sysctl_overcommit_memory), | |
1216 | .mode = 0644, | |
cb16e95f PH |
1217 | .proc_handler = proc_dointvec_minmax, |
1218 | .extra1 = &zero, | |
1219 | .extra2 = &two, | |
1da177e4 | 1220 | }, |
fadd8fbd | 1221 | { |
fadd8fbd KH |
1222 | .procname = "panic_on_oom", |
1223 | .data = &sysctl_panic_on_oom, | |
1224 | .maxlen = sizeof(sysctl_panic_on_oom), | |
1225 | .mode = 0644, | |
cb16e95f PH |
1226 | .proc_handler = proc_dointvec_minmax, |
1227 | .extra1 = &zero, | |
1228 | .extra2 = &two, | |
fadd8fbd | 1229 | }, |
fe071d7e | 1230 | { |
fe071d7e DR |
1231 | .procname = "oom_kill_allocating_task", |
1232 | .data = &sysctl_oom_kill_allocating_task, | |
1233 | .maxlen = sizeof(sysctl_oom_kill_allocating_task), | |
1234 | .mode = 0644, | |
6d456111 | 1235 | .proc_handler = proc_dointvec, |
fe071d7e | 1236 | }, |
fef1bdd6 | 1237 | { |
fef1bdd6 DR |
1238 | .procname = "oom_dump_tasks", |
1239 | .data = &sysctl_oom_dump_tasks, | |
1240 | .maxlen = sizeof(sysctl_oom_dump_tasks), | |
1241 | .mode = 0644, | |
6d456111 | 1242 | .proc_handler = proc_dointvec, |
fef1bdd6 | 1243 | }, |
1da177e4 | 1244 | { |
1da177e4 LT |
1245 | .procname = "overcommit_ratio", |
1246 | .data = &sysctl_overcommit_ratio, | |
1247 | .maxlen = sizeof(sysctl_overcommit_ratio), | |
1248 | .mode = 0644, | |
49f0ce5f JM |
1249 | .proc_handler = overcommit_ratio_handler, |
1250 | }, | |
1251 | { | |
1252 | .procname = "overcommit_kbytes", | |
1253 | .data = &sysctl_overcommit_kbytes, | |
1254 | .maxlen = sizeof(sysctl_overcommit_kbytes), | |
1255 | .mode = 0644, | |
1256 | .proc_handler = overcommit_kbytes_handler, | |
1da177e4 LT |
1257 | }, |
1258 | { | |
1da177e4 LT |
1259 | .procname = "page-cluster", |
1260 | .data = &page_cluster, | |
1261 | .maxlen = sizeof(int), | |
1262 | .mode = 0644, | |
cb16e95f PH |
1263 | .proc_handler = proc_dointvec_minmax, |
1264 | .extra1 = &zero, | |
1da177e4 LT |
1265 | }, |
1266 | { | |
1da177e4 LT |
1267 | .procname = "dirty_background_ratio", |
1268 | .data = &dirty_background_ratio, | |
1269 | .maxlen = sizeof(dirty_background_ratio), | |
1270 | .mode = 0644, | |
6d456111 | 1271 | .proc_handler = dirty_background_ratio_handler, |
1da177e4 LT |
1272 | .extra1 = &zero, |
1273 | .extra2 = &one_hundred, | |
1274 | }, | |
2da02997 | 1275 | { |
2da02997 DR |
1276 | .procname = "dirty_background_bytes", |
1277 | .data = &dirty_background_bytes, | |
1278 | .maxlen = sizeof(dirty_background_bytes), | |
1279 | .mode = 0644, | |
6d456111 | 1280 | .proc_handler = dirty_background_bytes_handler, |
fc3501d4 | 1281 | .extra1 = &one_ul, |
2da02997 | 1282 | }, |
1da177e4 | 1283 | { |
1da177e4 LT |
1284 | .procname = "dirty_ratio", |
1285 | .data = &vm_dirty_ratio, | |
1286 | .maxlen = sizeof(vm_dirty_ratio), | |
1287 | .mode = 0644, | |
6d456111 | 1288 | .proc_handler = dirty_ratio_handler, |
1da177e4 LT |
1289 | .extra1 = &zero, |
1290 | .extra2 = &one_hundred, | |
1291 | }, | |
2da02997 | 1292 | { |
2da02997 DR |
1293 | .procname = "dirty_bytes", |
1294 | .data = &vm_dirty_bytes, | |
1295 | .maxlen = sizeof(vm_dirty_bytes), | |
1296 | .mode = 0644, | |
6d456111 | 1297 | .proc_handler = dirty_bytes_handler, |
9e4a5bda | 1298 | .extra1 = &dirty_bytes_min, |
2da02997 | 1299 | }, |
1da177e4 | 1300 | { |
1da177e4 | 1301 | .procname = "dirty_writeback_centisecs", |
f6ef9438 BS |
1302 | .data = &dirty_writeback_interval, |
1303 | .maxlen = sizeof(dirty_writeback_interval), | |
1da177e4 | 1304 | .mode = 0644, |
6d456111 | 1305 | .proc_handler = dirty_writeback_centisecs_handler, |
1da177e4 LT |
1306 | }, |
1307 | { | |
1da177e4 | 1308 | .procname = "dirty_expire_centisecs", |
f6ef9438 BS |
1309 | .data = &dirty_expire_interval, |
1310 | .maxlen = sizeof(dirty_expire_interval), | |
1da177e4 | 1311 | .mode = 0644, |
cb16e95f PH |
1312 | .proc_handler = proc_dointvec_minmax, |
1313 | .extra1 = &zero, | |
1da177e4 | 1314 | }, |
1efff914 TT |
1315 | { |
1316 | .procname = "dirtytime_expire_seconds", | |
1317 | .data = &dirtytime_expire_interval, | |
1318 | .maxlen = sizeof(dirty_expire_interval), | |
1319 | .mode = 0644, | |
1320 | .proc_handler = dirtytime_interval_handler, | |
1321 | .extra1 = &zero, | |
1322 | }, | |
1da177e4 | 1323 | { |
3965c9ae WL |
1324 | .procname = "nr_pdflush_threads", |
1325 | .mode = 0444 /* read-only */, | |
1326 | .proc_handler = pdflush_proc_obsolete, | |
1da177e4 LT |
1327 | }, |
1328 | { | |
1da177e4 LT |
1329 | .procname = "swappiness", |
1330 | .data = &vm_swappiness, | |
1331 | .maxlen = sizeof(vm_swappiness), | |
1332 | .mode = 0644, | |
6d456111 | 1333 | .proc_handler = proc_dointvec_minmax, |
1da177e4 LT |
1334 | .extra1 = &zero, |
1335 | .extra2 = &one_hundred, | |
1336 | }, | |
1337 | #ifdef CONFIG_HUGETLB_PAGE | |
06808b08 | 1338 | { |
1da177e4 | 1339 | .procname = "nr_hugepages", |
e5ff2159 | 1340 | .data = NULL, |
1da177e4 LT |
1341 | .maxlen = sizeof(unsigned long), |
1342 | .mode = 0644, | |
6d456111 | 1343 | .proc_handler = hugetlb_sysctl_handler, |
06808b08 LS |
1344 | }, |
1345 | #ifdef CONFIG_NUMA | |
1346 | { | |
1347 | .procname = "nr_hugepages_mempolicy", | |
1348 | .data = NULL, | |
1349 | .maxlen = sizeof(unsigned long), | |
1350 | .mode = 0644, | |
1351 | .proc_handler = &hugetlb_mempolicy_sysctl_handler, | |
06808b08 LS |
1352 | }, |
1353 | #endif | |
1da177e4 | 1354 | { |
1da177e4 LT |
1355 | .procname = "hugetlb_shm_group", |
1356 | .data = &sysctl_hugetlb_shm_group, | |
1357 | .maxlen = sizeof(gid_t), | |
1358 | .mode = 0644, | |
6d456111 | 1359 | .proc_handler = proc_dointvec, |
1da177e4 | 1360 | }, |
396faf03 | 1361 | { |
396faf03 MG |
1362 | .procname = "hugepages_treat_as_movable", |
1363 | .data = &hugepages_treat_as_movable, | |
1364 | .maxlen = sizeof(int), | |
1365 | .mode = 0644, | |
86cdb465 | 1366 | .proc_handler = proc_dointvec, |
396faf03 | 1367 | }, |
d1c3fb1f | 1368 | { |
d1c3fb1f | 1369 | .procname = "nr_overcommit_hugepages", |
e5ff2159 AK |
1370 | .data = NULL, |
1371 | .maxlen = sizeof(unsigned long), | |
d1c3fb1f | 1372 | .mode = 0644, |
6d456111 | 1373 | .proc_handler = hugetlb_overcommit_handler, |
d1c3fb1f | 1374 | }, |
1da177e4 LT |
1375 | #endif |
1376 | { | |
1da177e4 LT |
1377 | .procname = "lowmem_reserve_ratio", |
1378 | .data = &sysctl_lowmem_reserve_ratio, | |
1379 | .maxlen = sizeof(sysctl_lowmem_reserve_ratio), | |
1380 | .mode = 0644, | |
6d456111 | 1381 | .proc_handler = lowmem_reserve_ratio_sysctl_handler, |
1da177e4 | 1382 | }, |
9d0243bc | 1383 | { |
9d0243bc AM |
1384 | .procname = "drop_caches", |
1385 | .data = &sysctl_drop_caches, | |
1386 | .maxlen = sizeof(int), | |
1387 | .mode = 0644, | |
1388 | .proc_handler = drop_caches_sysctl_handler, | |
cb16e95f | 1389 | .extra1 = &one, |
5509a5d2 | 1390 | .extra2 = &four, |
9d0243bc | 1391 | }, |
76ab0f53 MG |
1392 | #ifdef CONFIG_COMPACTION |
1393 | { | |
1394 | .procname = "compact_memory", | |
1395 | .data = &sysctl_compact_memory, | |
1396 | .maxlen = sizeof(int), | |
1397 | .mode = 0200, | |
1398 | .proc_handler = sysctl_compaction_handler, | |
1399 | }, | |
5e771905 MG |
1400 | { |
1401 | .procname = "extfrag_threshold", | |
1402 | .data = &sysctl_extfrag_threshold, | |
1403 | .maxlen = sizeof(int), | |
1404 | .mode = 0644, | |
1405 | .proc_handler = sysctl_extfrag_handler, | |
1406 | .extra1 = &min_extfrag_threshold, | |
1407 | .extra2 = &max_extfrag_threshold, | |
1408 | }, | |
5bbe3547 EM |
1409 | { |
1410 | .procname = "compact_unevictable_allowed", | |
1411 | .data = &sysctl_compact_unevictable_allowed, | |
1412 | .maxlen = sizeof(int), | |
1413 | .mode = 0644, | |
1414 | .proc_handler = proc_dointvec, | |
1415 | .extra1 = &zero, | |
1416 | .extra2 = &one, | |
1417 | }, | |
5e771905 | 1418 | |
76ab0f53 | 1419 | #endif /* CONFIG_COMPACTION */ |
1da177e4 | 1420 | { |
1da177e4 LT |
1421 | .procname = "min_free_kbytes", |
1422 | .data = &min_free_kbytes, | |
1423 | .maxlen = sizeof(min_free_kbytes), | |
1424 | .mode = 0644, | |
6d456111 | 1425 | .proc_handler = min_free_kbytes_sysctl_handler, |
1da177e4 LT |
1426 | .extra1 = &zero, |
1427 | }, | |
795ae7a0 JW |
1428 | { |
1429 | .procname = "watermark_scale_factor", | |
1430 | .data = &watermark_scale_factor, | |
1431 | .maxlen = sizeof(watermark_scale_factor), | |
1432 | .mode = 0644, | |
1433 | .proc_handler = watermark_scale_factor_sysctl_handler, | |
1434 | .extra1 = &one, | |
1435 | .extra2 = &one_thousand, | |
1436 | }, | |
8ad4b1fb | 1437 | { |
8ad4b1fb RS |
1438 | .procname = "percpu_pagelist_fraction", |
1439 | .data = &percpu_pagelist_fraction, | |
1440 | .maxlen = sizeof(percpu_pagelist_fraction), | |
1441 | .mode = 0644, | |
6d456111 | 1442 | .proc_handler = percpu_pagelist_fraction_sysctl_handler, |
7cd2b0a3 | 1443 | .extra1 = &zero, |
8ad4b1fb | 1444 | }, |
1da177e4 LT |
1445 | #ifdef CONFIG_MMU |
1446 | { | |
1da177e4 LT |
1447 | .procname = "max_map_count", |
1448 | .data = &sysctl_max_map_count, | |
1449 | .maxlen = sizeof(sysctl_max_map_count), | |
1450 | .mode = 0644, | |
3e26120c | 1451 | .proc_handler = proc_dointvec_minmax, |
70da2340 | 1452 | .extra1 = &zero, |
1da177e4 | 1453 | }, |
dd8632a1 PM |
1454 | #else |
1455 | { | |
dd8632a1 PM |
1456 | .procname = "nr_trim_pages", |
1457 | .data = &sysctl_nr_trim_pages, | |
1458 | .maxlen = sizeof(sysctl_nr_trim_pages), | |
1459 | .mode = 0644, | |
6d456111 | 1460 | .proc_handler = proc_dointvec_minmax, |
dd8632a1 PM |
1461 | .extra1 = &zero, |
1462 | }, | |
1da177e4 LT |
1463 | #endif |
1464 | { | |
1da177e4 LT |
1465 | .procname = "laptop_mode", |
1466 | .data = &laptop_mode, | |
1467 | .maxlen = sizeof(laptop_mode), | |
1468 | .mode = 0644, | |
6d456111 | 1469 | .proc_handler = proc_dointvec_jiffies, |
1da177e4 LT |
1470 | }, |
1471 | { | |
1da177e4 LT |
1472 | .procname = "block_dump", |
1473 | .data = &block_dump, | |
1474 | .maxlen = sizeof(block_dump), | |
1475 | .mode = 0644, | |
6d456111 | 1476 | .proc_handler = proc_dointvec, |
1da177e4 LT |
1477 | .extra1 = &zero, |
1478 | }, | |
1479 | { | |
1da177e4 LT |
1480 | .procname = "vfs_cache_pressure", |
1481 | .data = &sysctl_vfs_cache_pressure, | |
1482 | .maxlen = sizeof(sysctl_vfs_cache_pressure), | |
1483 | .mode = 0644, | |
6d456111 | 1484 | .proc_handler = proc_dointvec, |
1da177e4 LT |
1485 | .extra1 = &zero, |
1486 | }, | |
1487 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT | |
1488 | { | |
1da177e4 LT |
1489 | .procname = "legacy_va_layout", |
1490 | .data = &sysctl_legacy_va_layout, | |
1491 | .maxlen = sizeof(sysctl_legacy_va_layout), | |
1492 | .mode = 0644, | |
6d456111 | 1493 | .proc_handler = proc_dointvec, |
1da177e4 LT |
1494 | .extra1 = &zero, |
1495 | }, | |
1496 | #endif | |
1743660b CL |
1497 | #ifdef CONFIG_NUMA |
1498 | { | |
1743660b CL |
1499 | .procname = "zone_reclaim_mode", |
1500 | .data = &zone_reclaim_mode, | |
1501 | .maxlen = sizeof(zone_reclaim_mode), | |
1502 | .mode = 0644, | |
6d456111 | 1503 | .proc_handler = proc_dointvec, |
c84db23c | 1504 | .extra1 = &zero, |
1743660b | 1505 | }, |
9614634f | 1506 | { |
9614634f CL |
1507 | .procname = "min_unmapped_ratio", |
1508 | .data = &sysctl_min_unmapped_ratio, | |
1509 | .maxlen = sizeof(sysctl_min_unmapped_ratio), | |
1510 | .mode = 0644, | |
6d456111 | 1511 | .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, |
9614634f CL |
1512 | .extra1 = &zero, |
1513 | .extra2 = &one_hundred, | |
1514 | }, | |
0ff38490 | 1515 | { |
0ff38490 CL |
1516 | .procname = "min_slab_ratio", |
1517 | .data = &sysctl_min_slab_ratio, | |
1518 | .maxlen = sizeof(sysctl_min_slab_ratio), | |
1519 | .mode = 0644, | |
6d456111 | 1520 | .proc_handler = sysctl_min_slab_ratio_sysctl_handler, |
0ff38490 CL |
1521 | .extra1 = &zero, |
1522 | .extra2 = &one_hundred, | |
1523 | }, | |
e6e5494c | 1524 | #endif |
77461ab3 CL |
1525 | #ifdef CONFIG_SMP |
1526 | { | |
77461ab3 CL |
1527 | .procname = "stat_interval", |
1528 | .data = &sysctl_stat_interval, | |
1529 | .maxlen = sizeof(sysctl_stat_interval), | |
1530 | .mode = 0644, | |
6d456111 | 1531 | .proc_handler = proc_dointvec_jiffies, |
77461ab3 | 1532 | }, |
52b6f46b HD |
1533 | { |
1534 | .procname = "stat_refresh", | |
1535 | .data = NULL, | |
1536 | .maxlen = 0, | |
1537 | .mode = 0600, | |
1538 | .proc_handler = vmstat_refresh, | |
1539 | }, | |
77461ab3 | 1540 | #endif |
6e141546 | 1541 | #ifdef CONFIG_MMU |
ed032189 | 1542 | { |
ed032189 | 1543 | .procname = "mmap_min_addr", |
788084ab EP |
1544 | .data = &dac_mmap_min_addr, |
1545 | .maxlen = sizeof(unsigned long), | |
ed032189 | 1546 | .mode = 0644, |
6d456111 | 1547 | .proc_handler = mmap_min_addr_handler, |
ed032189 | 1548 | }, |
6e141546 | 1549 | #endif |
f0c0b2b8 KH |
1550 | #ifdef CONFIG_NUMA |
1551 | { | |
f0c0b2b8 KH |
1552 | .procname = "numa_zonelist_order", |
1553 | .data = &numa_zonelist_order, | |
1554 | .maxlen = NUMA_ZONELIST_ORDER_LEN, | |
1555 | .mode = 0644, | |
6d456111 | 1556 | .proc_handler = numa_zonelist_order_handler, |
f0c0b2b8 KH |
1557 | }, |
1558 | #endif | |
2b8232ce | 1559 | #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ |
5c36e657 | 1560 | (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) |
e6e5494c | 1561 | { |
e6e5494c | 1562 | .procname = "vdso_enabled", |
3d7ee969 AL |
1563 | #ifdef CONFIG_X86_32 |
1564 | .data = &vdso32_enabled, | |
1565 | .maxlen = sizeof(vdso32_enabled), | |
1566 | #else | |
e6e5494c IM |
1567 | .data = &vdso_enabled, |
1568 | .maxlen = sizeof(vdso_enabled), | |
3d7ee969 | 1569 | #endif |
e6e5494c | 1570 | .mode = 0644, |
6d456111 | 1571 | .proc_handler = proc_dointvec, |
e6e5494c IM |
1572 | .extra1 = &zero, |
1573 | }, | |
1da177e4 | 1574 | #endif |
195cf453 BG |
1575 | #ifdef CONFIG_HIGHMEM |
1576 | { | |
195cf453 BG |
1577 | .procname = "highmem_is_dirtyable", |
1578 | .data = &vm_highmem_is_dirtyable, | |
1579 | .maxlen = sizeof(vm_highmem_is_dirtyable), | |
1580 | .mode = 0644, | |
6d456111 | 1581 | .proc_handler = proc_dointvec_minmax, |
195cf453 BG |
1582 | .extra1 = &zero, |
1583 | .extra2 = &one, | |
1584 | }, | |
1585 | #endif | |
6a46079c AK |
1586 | #ifdef CONFIG_MEMORY_FAILURE |
1587 | { | |
6a46079c AK |
1588 | .procname = "memory_failure_early_kill", |
1589 | .data = &sysctl_memory_failure_early_kill, | |
1590 | .maxlen = sizeof(sysctl_memory_failure_early_kill), | |
1591 | .mode = 0644, | |
6d456111 | 1592 | .proc_handler = proc_dointvec_minmax, |
6a46079c AK |
1593 | .extra1 = &zero, |
1594 | .extra2 = &one, | |
1595 | }, | |
1596 | { | |
6a46079c AK |
1597 | .procname = "memory_failure_recovery", |
1598 | .data = &sysctl_memory_failure_recovery, | |
1599 | .maxlen = sizeof(sysctl_memory_failure_recovery), | |
1600 | .mode = 0644, | |
6d456111 | 1601 | .proc_handler = proc_dointvec_minmax, |
6a46079c AK |
1602 | .extra1 = &zero, |
1603 | .extra2 = &one, | |
1604 | }, | |
1605 | #endif | |
c9b1d098 AS |
1606 | { |
1607 | .procname = "user_reserve_kbytes", | |
1608 | .data = &sysctl_user_reserve_kbytes, | |
1609 | .maxlen = sizeof(sysctl_user_reserve_kbytes), | |
1610 | .mode = 0644, | |
1611 | .proc_handler = proc_doulongvec_minmax, | |
1612 | }, | |
4eeab4f5 AS |
1613 | { |
1614 | .procname = "admin_reserve_kbytes", | |
1615 | .data = &sysctl_admin_reserve_kbytes, | |
1616 | .maxlen = sizeof(sysctl_admin_reserve_kbytes), | |
1617 | .mode = 0644, | |
1618 | .proc_handler = proc_doulongvec_minmax, | |
1619 | }, | |
d07e2259 DC |
1620 | #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS |
1621 | { | |
1622 | .procname = "mmap_rnd_bits", | |
1623 | .data = &mmap_rnd_bits, | |
1624 | .maxlen = sizeof(mmap_rnd_bits), | |
1625 | .mode = 0600, | |
1626 | .proc_handler = proc_dointvec_minmax, | |
1627 | .extra1 = (void *)&mmap_rnd_bits_min, | |
1628 | .extra2 = (void *)&mmap_rnd_bits_max, | |
1629 | }, | |
1630 | #endif | |
1631 | #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS | |
1632 | { | |
1633 | .procname = "mmap_rnd_compat_bits", | |
1634 | .data = &mmap_rnd_compat_bits, | |
1635 | .maxlen = sizeof(mmap_rnd_compat_bits), | |
1636 | .mode = 0600, | |
1637 | .proc_handler = proc_dointvec_minmax, | |
1638 | .extra1 = (void *)&mmap_rnd_compat_bits_min, | |
1639 | .extra2 = (void *)&mmap_rnd_compat_bits_max, | |
1640 | }, | |
1641 | #endif | |
6fce56ec | 1642 | { } |
1da177e4 LT |
1643 | }; |
1644 | ||
d8217f07 | 1645 | static struct ctl_table fs_table[] = { |
1da177e4 | 1646 | { |
1da177e4 LT |
1647 | .procname = "inode-nr", |
1648 | .data = &inodes_stat, | |
3942c07c | 1649 | .maxlen = 2*sizeof(long), |
1da177e4 | 1650 | .mode = 0444, |
cffbc8aa | 1651 | .proc_handler = proc_nr_inodes, |
1da177e4 LT |
1652 | }, |
1653 | { | |
1da177e4 LT |
1654 | .procname = "inode-state", |
1655 | .data = &inodes_stat, | |
3942c07c | 1656 | .maxlen = 7*sizeof(long), |
1da177e4 | 1657 | .mode = 0444, |
cffbc8aa | 1658 | .proc_handler = proc_nr_inodes, |
1da177e4 LT |
1659 | }, |
1660 | { | |
1da177e4 LT |
1661 | .procname = "file-nr", |
1662 | .data = &files_stat, | |
518de9b3 | 1663 | .maxlen = sizeof(files_stat), |
1da177e4 | 1664 | .mode = 0444, |
6d456111 | 1665 | .proc_handler = proc_nr_files, |
1da177e4 LT |
1666 | }, |
1667 | { | |
1da177e4 LT |
1668 | .procname = "file-max", |
1669 | .data = &files_stat.max_files, | |
518de9b3 | 1670 | .maxlen = sizeof(files_stat.max_files), |
1da177e4 | 1671 | .mode = 0644, |
518de9b3 | 1672 | .proc_handler = proc_doulongvec_minmax, |
1da177e4 | 1673 | }, |
9cfe015a | 1674 | { |
9cfe015a ED |
1675 | .procname = "nr_open", |
1676 | .data = &sysctl_nr_open, | |
1677 | .maxlen = sizeof(int), | |
1678 | .mode = 0644, | |
6d456111 | 1679 | .proc_handler = proc_dointvec_minmax, |
eceea0b3 AV |
1680 | .extra1 = &sysctl_nr_open_min, |
1681 | .extra2 = &sysctl_nr_open_max, | |
9cfe015a | 1682 | }, |
1da177e4 | 1683 | { |
1da177e4 LT |
1684 | .procname = "dentry-state", |
1685 | .data = &dentry_stat, | |
3942c07c | 1686 | .maxlen = 6*sizeof(long), |
1da177e4 | 1687 | .mode = 0444, |
312d3ca8 | 1688 | .proc_handler = proc_nr_dentry, |
1da177e4 LT |
1689 | }, |
1690 | { | |
1da177e4 LT |
1691 | .procname = "overflowuid", |
1692 | .data = &fs_overflowuid, | |
1693 | .maxlen = sizeof(int), | |
1694 | .mode = 0644, | |
6d456111 | 1695 | .proc_handler = proc_dointvec_minmax, |
1da177e4 LT |
1696 | .extra1 = &minolduid, |
1697 | .extra2 = &maxolduid, | |
1698 | }, | |
1699 | { | |
1da177e4 LT |
1700 | .procname = "overflowgid", |
1701 | .data = &fs_overflowgid, | |
1702 | .maxlen = sizeof(int), | |
1703 | .mode = 0644, | |
6d456111 | 1704 | .proc_handler = proc_dointvec_minmax, |
1da177e4 LT |
1705 | .extra1 = &minolduid, |
1706 | .extra2 = &maxolduid, | |
1707 | }, | |
bfcd17a6 | 1708 | #ifdef CONFIG_FILE_LOCKING |
1da177e4 | 1709 | { |
1da177e4 LT |
1710 | .procname = "leases-enable", |
1711 | .data = &leases_enable, | |
1712 | .maxlen = sizeof(int), | |
1713 | .mode = 0644, | |
6d456111 | 1714 | .proc_handler = proc_dointvec, |
1da177e4 | 1715 | }, |
bfcd17a6 | 1716 | #endif |
1da177e4 LT |
1717 | #ifdef CONFIG_DNOTIFY |
1718 | { | |
1da177e4 LT |
1719 | .procname = "dir-notify-enable", |
1720 | .data = &dir_notify_enable, | |
1721 | .maxlen = sizeof(int), | |
1722 | .mode = 0644, | |
6d456111 | 1723 | .proc_handler = proc_dointvec, |
1da177e4 LT |
1724 | }, |
1725 | #endif | |
1726 | #ifdef CONFIG_MMU | |
bfcd17a6 | 1727 | #ifdef CONFIG_FILE_LOCKING |
1da177e4 | 1728 | { |
1da177e4 LT |
1729 | .procname = "lease-break-time", |
1730 | .data = &lease_break_time, | |
1731 | .maxlen = sizeof(int), | |
1732 | .mode = 0644, | |
6d456111 | 1733 | .proc_handler = proc_dointvec, |
1da177e4 | 1734 | }, |
bfcd17a6 | 1735 | #endif |
ebf3f09c | 1736 | #ifdef CONFIG_AIO |
1da177e4 | 1737 | { |
1da177e4 LT |
1738 | .procname = "aio-nr", |
1739 | .data = &aio_nr, | |
1740 | .maxlen = sizeof(aio_nr), | |
1741 | .mode = 0444, | |
6d456111 | 1742 | .proc_handler = proc_doulongvec_minmax, |
1da177e4 LT |
1743 | }, |
1744 | { | |
1da177e4 LT |
1745 | .procname = "aio-max-nr", |
1746 | .data = &aio_max_nr, | |
1747 | .maxlen = sizeof(aio_max_nr), | |
1748 | .mode = 0644, | |
6d456111 | 1749 | .proc_handler = proc_doulongvec_minmax, |
1da177e4 | 1750 | }, |
ebf3f09c | 1751 | #endif /* CONFIG_AIO */ |
2d9048e2 | 1752 | #ifdef CONFIG_INOTIFY_USER |
0399cb08 | 1753 | { |
0399cb08 RL |
1754 | .procname = "inotify", |
1755 | .mode = 0555, | |
1756 | .child = inotify_table, | |
1757 | }, | |
1758 | #endif | |
7ef9964e DL |
1759 | #ifdef CONFIG_EPOLL |
1760 | { | |
1761 | .procname = "epoll", | |
1762 | .mode = 0555, | |
1763 | .child = epoll_table, | |
1764 | }, | |
1765 | #endif | |
1da177e4 | 1766 | #endif |
800179c9 KC |
1767 | { |
1768 | .procname = "protected_symlinks", | |
1769 | .data = &sysctl_protected_symlinks, | |
1770 | .maxlen = sizeof(int), | |
1771 | .mode = 0600, | |
1772 | .proc_handler = proc_dointvec_minmax, | |
1773 | .extra1 = &zero, | |
1774 | .extra2 = &one, | |
1775 | }, | |
1776 | { | |
1777 | .procname = "protected_hardlinks", | |
1778 | .data = &sysctl_protected_hardlinks, | |
1779 | .maxlen = sizeof(int), | |
1780 | .mode = 0600, | |
1781 | .proc_handler = proc_dointvec_minmax, | |
1782 | .extra1 = &zero, | |
1783 | .extra2 = &one, | |
1784 | }, | |
d6e71144 | 1785 | { |
d6e71144 AC |
1786 | .procname = "suid_dumpable", |
1787 | .data = &suid_dumpable, | |
1788 | .maxlen = sizeof(int), | |
1789 | .mode = 0644, | |
54b50199 | 1790 | .proc_handler = proc_dointvec_minmax_coredump, |
8e654fba MW |
1791 | .extra1 = &zero, |
1792 | .extra2 = &two, | |
d6e71144 | 1793 | }, |
2abc26fc EB |
1794 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) |
1795 | { | |
2abc26fc EB |
1796 | .procname = "binfmt_misc", |
1797 | .mode = 0555, | |
f9bd6733 | 1798 | .child = sysctl_mount_point, |
2abc26fc EB |
1799 | }, |
1800 | #endif | |
b492e95b | 1801 | { |
ff9da691 JA |
1802 | .procname = "pipe-max-size", |
1803 | .data = &pipe_max_size, | |
b492e95b JA |
1804 | .maxlen = sizeof(int), |
1805 | .mode = 0644, | |
ff9da691 JA |
1806 | .proc_handler = &pipe_proc_fn, |
1807 | .extra1 = &pipe_min_size, | |
b492e95b | 1808 | }, |
759c0114 WT |
1809 | { |
1810 | .procname = "pipe-user-pages-hard", | |
1811 | .data = &pipe_user_pages_hard, | |
1812 | .maxlen = sizeof(pipe_user_pages_hard), | |
1813 | .mode = 0644, | |
1814 | .proc_handler = proc_doulongvec_minmax, | |
1815 | }, | |
1816 | { | |
1817 | .procname = "pipe-user-pages-soft", | |
1818 | .data = &pipe_user_pages_soft, | |
1819 | .maxlen = sizeof(pipe_user_pages_soft), | |
1820 | .mode = 0644, | |
1821 | .proc_handler = proc_doulongvec_minmax, | |
1822 | }, | |
6fce56ec | 1823 | { } |
1da177e4 LT |
1824 | }; |
1825 | ||
d8217f07 | 1826 | static struct ctl_table debug_table[] = { |
7ac57a89 | 1827 | #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE |
abd4f750 | 1828 | { |
abd4f750 MAS |
1829 | .procname = "exception-trace", |
1830 | .data = &show_unhandled_signals, | |
1831 | .maxlen = sizeof(int), | |
1832 | .mode = 0644, | |
1833 | .proc_handler = proc_dointvec | |
1834 | }, | |
b2be84df MH |
1835 | #endif |
1836 | #if defined(CONFIG_OPTPROBES) | |
1837 | { | |
1838 | .procname = "kprobes-optimization", | |
1839 | .data = &sysctl_kprobes_optimization, | |
1840 | .maxlen = sizeof(int), | |
1841 | .mode = 0644, | |
1842 | .proc_handler = proc_kprobes_optimization_handler, | |
1843 | .extra1 = &zero, | |
1844 | .extra2 = &one, | |
1845 | }, | |
abd4f750 | 1846 | #endif |
6fce56ec | 1847 | { } |
1da177e4 LT |
1848 | }; |
1849 | ||
d8217f07 | 1850 | static struct ctl_table dev_table[] = { |
6fce56ec | 1851 | { } |
0eeca283 | 1852 | }; |
1da177e4 | 1853 | |
de4e83bd | 1854 | int __init sysctl_init(void) |
d912b0cc | 1855 | { |
fd4b616b SR |
1856 | struct ctl_table_header *hdr; |
1857 | ||
1858 | hdr = register_sysctl_table(sysctl_base_table); | |
1859 | kmemleak_not_leak(hdr); | |
d912b0cc EB |
1860 | return 0; |
1861 | } | |
1862 | ||
b89a8171 EB |
1863 | #endif /* CONFIG_SYSCTL */ |
1864 | ||
1da177e4 LT |
1865 | /* |
1866 | * /proc/sys support | |
1867 | */ | |
1868 | ||
b89a8171 | 1869 | #ifdef CONFIG_PROC_SYSCTL |
1da177e4 | 1870 | |
f8808300 KC |
1871 | static int _proc_do_string(char *data, int maxlen, int write, |
1872 | char __user *buffer, | |
b1ba4ddd | 1873 | size_t *lenp, loff_t *ppos) |
1da177e4 LT |
1874 | { |
1875 | size_t len; | |
1876 | char __user *p; | |
1877 | char c; | |
8d060877 ON |
1878 | |
1879 | if (!data || !maxlen || !*lenp) { | |
1da177e4 LT |
1880 | *lenp = 0; |
1881 | return 0; | |
1882 | } | |
8d060877 | 1883 | |
1da177e4 | 1884 | if (write) { |
f4aacea2 KC |
1885 | if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { |
1886 | /* Only continue writes not past the end of buffer. */ | |
1887 | len = strlen(data); | |
1888 | if (len > maxlen - 1) | |
1889 | len = maxlen - 1; | |
1890 | ||
1891 | if (*ppos > len) | |
1892 | return 0; | |
1893 | len = *ppos; | |
1894 | } else { | |
1895 | /* Start writing from beginning of buffer. */ | |
1896 | len = 0; | |
1897 | } | |
1898 | ||
2ca9bb45 | 1899 | *ppos += *lenp; |
1da177e4 | 1900 | p = buffer; |
2ca9bb45 | 1901 | while ((p - buffer) < *lenp && len < maxlen - 1) { |
1da177e4 LT |
1902 | if (get_user(c, p++)) |
1903 | return -EFAULT; | |
1904 | if (c == 0 || c == '\n') | |
1905 | break; | |
2ca9bb45 | 1906 | data[len++] = c; |
1da177e4 | 1907 | } |
f8808300 | 1908 | data[len] = 0; |
1da177e4 | 1909 | } else { |
f5dd3d6f SV |
1910 | len = strlen(data); |
1911 | if (len > maxlen) | |
1912 | len = maxlen; | |
8d060877 ON |
1913 | |
1914 | if (*ppos > len) { | |
1915 | *lenp = 0; | |
1916 | return 0; | |
1917 | } | |
1918 | ||
1919 | data += *ppos; | |
1920 | len -= *ppos; | |
1921 | ||
1da177e4 LT |
1922 | if (len > *lenp) |
1923 | len = *lenp; | |
1924 | if (len) | |
f8808300 | 1925 | if (copy_to_user(buffer, data, len)) |
1da177e4 LT |
1926 | return -EFAULT; |
1927 | if (len < *lenp) { | |
f8808300 | 1928 | if (put_user('\n', buffer + len)) |
1da177e4 LT |
1929 | return -EFAULT; |
1930 | len++; | |
1931 | } | |
1932 | *lenp = len; | |
1933 | *ppos += len; | |
1934 | } | |
1935 | return 0; | |
1936 | } | |
1937 | ||
f4aacea2 KC |
1938 | static void warn_sysctl_write(struct ctl_table *table) |
1939 | { | |
1940 | pr_warn_once("%s wrote to %s when file position was not 0!\n" | |
1941 | "This will not be supported in the future. To silence this\n" | |
1942 | "warning, set kernel.sysctl_writes_strict = -1\n", | |
1943 | current->comm, table->procname); | |
1944 | } | |
1945 | ||
f5dd3d6f SV |
1946 | /** |
1947 | * proc_dostring - read a string sysctl | |
1948 | * @table: the sysctl table | |
1949 | * @write: %TRUE if this is a write to the sysctl file | |
f5dd3d6f SV |
1950 | * @buffer: the user buffer |
1951 | * @lenp: the size of the user buffer | |
1952 | * @ppos: file position | |
1953 | * | |
1954 | * Reads/writes a string from/to the user buffer. If the kernel | |
1955 | * buffer provided is not large enough to hold the string, the | |
1956 | * string is truncated. The copied string is %NULL-terminated. | |
1957 | * If the string is being read by the user process, it is copied | |
1958 | * and a newline '\n' is added. It is truncated if the buffer is | |
1959 | * not large enough. | |
1960 | * | |
1961 | * Returns 0 on success. | |
1962 | */ | |
8d65af78 | 1963 | int proc_dostring(struct ctl_table *table, int write, |
f5dd3d6f SV |
1964 | void __user *buffer, size_t *lenp, loff_t *ppos) |
1965 | { | |
f4aacea2 KC |
1966 | if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN) |
1967 | warn_sysctl_write(table); | |
1968 | ||
f8808300 KC |
1969 | return _proc_do_string((char *)(table->data), table->maxlen, write, |
1970 | (char __user *)buffer, lenp, ppos); | |
f5dd3d6f SV |
1971 | } |
1972 | ||
00b7c339 AW |
1973 | static size_t proc_skip_spaces(char **buf) |
1974 | { | |
1975 | size_t ret; | |
1976 | char *tmp = skip_spaces(*buf); | |
1977 | ret = tmp - *buf; | |
1978 | *buf = tmp; | |
1979 | return ret; | |
1980 | } | |
1981 | ||
9f977fb7 OP |
1982 | static void proc_skip_char(char **buf, size_t *size, const char v) |
1983 | { | |
1984 | while (*size) { | |
1985 | if (**buf != v) | |
1986 | break; | |
1987 | (*size)--; | |
1988 | (*buf)++; | |
1989 | } | |
1990 | } | |
1991 | ||
00b7c339 AW |
1992 | #define TMPBUFLEN 22 |
1993 | /** | |
0fc377bd | 1994 | * proc_get_long - reads an ASCII formatted integer from a user buffer |
00b7c339 | 1995 | * |
0fc377bd RD |
1996 | * @buf: a kernel buffer |
1997 | * @size: size of the kernel buffer | |
1998 | * @val: this is where the number will be stored | |
1999 | * @neg: set to %TRUE if number is negative | |
2000 | * @perm_tr: a vector which contains the allowed trailers | |
2001 | * @perm_tr_len: size of the perm_tr vector | |
2002 | * @tr: pointer to store the trailer character | |
00b7c339 | 2003 | * |
0fc377bd RD |
2004 | * In case of success %0 is returned and @buf and @size are updated with |
2005 | * the amount of bytes read. If @tr is non-NULL and a trailing | |
2006 | * character exists (size is non-zero after returning from this | |
2007 | * function), @tr is updated with the trailing character. | |
00b7c339 AW |
2008 | */ |
2009 | static int proc_get_long(char **buf, size_t *size, | |
2010 | unsigned long *val, bool *neg, | |
2011 | const char *perm_tr, unsigned perm_tr_len, char *tr) | |
2012 | { | |
2013 | int len; | |
2014 | char *p, tmp[TMPBUFLEN]; | |
2015 | ||
2016 | if (!*size) | |
2017 | return -EINVAL; | |
2018 | ||
2019 | len = *size; | |
2020 | if (len > TMPBUFLEN - 1) | |
2021 | len = TMPBUFLEN - 1; | |
2022 | ||
2023 | memcpy(tmp, *buf, len); | |
2024 | ||
2025 | tmp[len] = 0; | |
2026 | p = tmp; | |
2027 | if (*p == '-' && *size > 1) { | |
2028 | *neg = true; | |
2029 | p++; | |
2030 | } else | |
2031 | *neg = false; | |
2032 | if (!isdigit(*p)) | |
2033 | return -EINVAL; | |
2034 | ||
2035 | *val = simple_strtoul(p, &p, 0); | |
2036 | ||
2037 | len = p - tmp; | |
2038 | ||
2039 | /* We don't know if the next char is whitespace thus we may accept | |
2040 | * invalid integers (e.g. 1234...a) or two integers instead of one | |
2041 | * (e.g. 123...1). So lets not allow such large numbers. */ | |
2042 | if (len == TMPBUFLEN - 1) | |
2043 | return -EINVAL; | |
2044 | ||
2045 | if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) | |
2046 | return -EINVAL; | |
1da177e4 | 2047 | |
00b7c339 AW |
2048 | if (tr && (len < *size)) |
2049 | *tr = *p; | |
2050 | ||
2051 | *buf += len; | |
2052 | *size -= len; | |
2053 | ||
2054 | return 0; | |
2055 | } | |
2056 | ||
2057 | /** | |
0fc377bd | 2058 | * proc_put_long - converts an integer to a decimal ASCII formatted string |
00b7c339 | 2059 | * |
0fc377bd RD |
2060 | * @buf: the user buffer |
2061 | * @size: the size of the user buffer | |
2062 | * @val: the integer to be converted | |
2063 | * @neg: sign of the number, %TRUE for negative | |
00b7c339 | 2064 | * |
0fc377bd RD |
2065 | * In case of success %0 is returned and @buf and @size are updated with |
2066 | * the amount of bytes written. | |
00b7c339 AW |
2067 | */ |
2068 | static int proc_put_long(void __user **buf, size_t *size, unsigned long val, | |
2069 | bool neg) | |
2070 | { | |
2071 | int len; | |
2072 | char tmp[TMPBUFLEN], *p = tmp; | |
2073 | ||
2074 | sprintf(p, "%s%lu", neg ? "-" : "", val); | |
2075 | len = strlen(tmp); | |
2076 | if (len > *size) | |
2077 | len = *size; | |
2078 | if (copy_to_user(*buf, tmp, len)) | |
2079 | return -EFAULT; | |
2080 | *size -= len; | |
2081 | *buf += len; | |
2082 | return 0; | |
2083 | } | |
2084 | #undef TMPBUFLEN | |
2085 | ||
2086 | static int proc_put_char(void __user **buf, size_t *size, char c) | |
2087 | { | |
2088 | if (*size) { | |
2089 | char __user **buffer = (char __user **)buf; | |
2090 | if (put_user(c, *buffer)) | |
2091 | return -EFAULT; | |
2092 | (*size)--, (*buffer)++; | |
2093 | *buf = *buffer; | |
2094 | } | |
2095 | return 0; | |
2096 | } | |
1da177e4 | 2097 | |
00b7c339 | 2098 | static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, |
1da177e4 LT |
2099 | int *valp, |
2100 | int write, void *data) | |
2101 | { | |
2102 | if (write) { | |
230633d1 HS |
2103 | if (*negp) { |
2104 | if (*lvalp > (unsigned long) INT_MAX + 1) | |
2105 | return -EINVAL; | |
2106 | *valp = -*lvalp; | |
2107 | } else { | |
2108 | if (*lvalp > (unsigned long) INT_MAX) | |
2109 | return -EINVAL; | |
2110 | *valp = *lvalp; | |
2111 | } | |
1da177e4 LT |
2112 | } else { |
2113 | int val = *valp; | |
2114 | if (val < 0) { | |
00b7c339 | 2115 | *negp = true; |
9a5bc726 | 2116 | *lvalp = -(unsigned long)val; |
1da177e4 | 2117 | } else { |
00b7c339 | 2118 | *negp = false; |
1da177e4 LT |
2119 | *lvalp = (unsigned long)val; |
2120 | } | |
2121 | } | |
2122 | return 0; | |
2123 | } | |
2124 | ||
00b7c339 AW |
2125 | static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; |
2126 | ||
d8217f07 | 2127 | static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, |
8d65af78 | 2128 | int write, void __user *buffer, |
fcfbd547 | 2129 | size_t *lenp, loff_t *ppos, |
00b7c339 | 2130 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, |
1da177e4 LT |
2131 | int write, void *data), |
2132 | void *data) | |
2133 | { | |
00b7c339 | 2134 | int *i, vleft, first = 1, err = 0; |
00b7c339 | 2135 | size_t left; |
70f6cbb6 | 2136 | char *kbuf = NULL, *p; |
1da177e4 | 2137 | |
00b7c339 | 2138 | if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { |
1da177e4 LT |
2139 | *lenp = 0; |
2140 | return 0; | |
2141 | } | |
2142 | ||
fcfbd547 | 2143 | i = (int *) tbl_data; |
1da177e4 LT |
2144 | vleft = table->maxlen / sizeof(*i); |
2145 | left = *lenp; | |
2146 | ||
2147 | if (!conv) | |
2148 | conv = do_proc_dointvec_conv; | |
2149 | ||
00b7c339 | 2150 | if (write) { |
f4aacea2 KC |
2151 | if (*ppos) { |
2152 | switch (sysctl_writes_strict) { | |
2153 | case SYSCTL_WRITES_STRICT: | |
2154 | goto out; | |
2155 | case SYSCTL_WRITES_WARN: | |
2156 | warn_sysctl_write(table); | |
2157 | break; | |
2158 | default: | |
2159 | break; | |
2160 | } | |
2161 | } | |
2162 | ||
00b7c339 AW |
2163 | if (left > PAGE_SIZE - 1) |
2164 | left = PAGE_SIZE - 1; | |
70f6cbb6 AV |
2165 | p = kbuf = memdup_user_nul(buffer, left); |
2166 | if (IS_ERR(kbuf)) | |
2167 | return PTR_ERR(kbuf); | |
00b7c339 AW |
2168 | } |
2169 | ||
1da177e4 | 2170 | for (; left && vleft--; i++, first=0) { |
00b7c339 AW |
2171 | unsigned long lval; |
2172 | bool neg; | |
1da177e4 | 2173 | |
00b7c339 | 2174 | if (write) { |
70f6cbb6 | 2175 | left -= proc_skip_spaces(&p); |
1da177e4 | 2176 | |
563b0467 O |
2177 | if (!left) |
2178 | break; | |
70f6cbb6 | 2179 | err = proc_get_long(&p, &left, &lval, &neg, |
00b7c339 AW |
2180 | proc_wspace_sep, |
2181 | sizeof(proc_wspace_sep), NULL); | |
2182 | if (err) | |
1da177e4 | 2183 | break; |
00b7c339 AW |
2184 | if (conv(&neg, &lval, i, 1, data)) { |
2185 | err = -EINVAL; | |
1da177e4 | 2186 | break; |
00b7c339 | 2187 | } |
1da177e4 | 2188 | } else { |
00b7c339 AW |
2189 | if (conv(&neg, &lval, i, 0, data)) { |
2190 | err = -EINVAL; | |
2191 | break; | |
2192 | } | |
1da177e4 | 2193 | if (!first) |
00b7c339 AW |
2194 | err = proc_put_char(&buffer, &left, '\t'); |
2195 | if (err) | |
2196 | break; | |
2197 | err = proc_put_long(&buffer, &left, lval, neg); | |
2198 | if (err) | |
1da177e4 | 2199 | break; |
1da177e4 LT |
2200 | } |
2201 | } | |
2202 | ||
00b7c339 AW |
2203 | if (!write && !first && left && !err) |
2204 | err = proc_put_char(&buffer, &left, '\n'); | |
563b0467 | 2205 | if (write && !err && left) |
70f6cbb6 | 2206 | left -= proc_skip_spaces(&p); |
1da177e4 | 2207 | if (write) { |
70f6cbb6 | 2208 | kfree(kbuf); |
00b7c339 AW |
2209 | if (first) |
2210 | return err ? : -EINVAL; | |
1da177e4 | 2211 | } |
1da177e4 | 2212 | *lenp -= left; |
f4aacea2 | 2213 | out: |
1da177e4 | 2214 | *ppos += *lenp; |
00b7c339 | 2215 | return err; |
1da177e4 LT |
2216 | } |
2217 | ||
8d65af78 | 2218 | static int do_proc_dointvec(struct ctl_table *table, int write, |
fcfbd547 | 2219 | void __user *buffer, size_t *lenp, loff_t *ppos, |
00b7c339 | 2220 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, |
fcfbd547 KK |
2221 | int write, void *data), |
2222 | void *data) | |
2223 | { | |
8d65af78 | 2224 | return __do_proc_dointvec(table->data, table, write, |
fcfbd547 KK |
2225 | buffer, lenp, ppos, conv, data); |
2226 | } | |
2227 | ||
1da177e4 LT |
2228 | /** |
2229 | * proc_dointvec - read a vector of integers | |
2230 | * @table: the sysctl table | |
2231 | * @write: %TRUE if this is a write to the sysctl file | |
1da177e4 LT |
2232 | * @buffer: the user buffer |
2233 | * @lenp: the size of the user buffer | |
2234 | * @ppos: file position | |
2235 | * | |
2236 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | |
2237 | * values from/to the user buffer, treated as an ASCII string. | |
2238 | * | |
2239 | * Returns 0 on success. | |
2240 | */ | |
8d65af78 | 2241 | int proc_dointvec(struct ctl_table *table, int write, |
1da177e4 LT |
2242 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2243 | { | |
8d65af78 | 2244 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
1da177e4 LT |
2245 | NULL,NULL); |
2246 | } | |
2247 | ||
34f5a398 | 2248 | /* |
25ddbb18 AK |
2249 | * Taint values can only be increased |
2250 | * This means we can safely use a temporary. | |
34f5a398 | 2251 | */ |
8d65af78 | 2252 | static int proc_taint(struct ctl_table *table, int write, |
34f5a398 TT |
2253 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2254 | { | |
25ddbb18 AK |
2255 | struct ctl_table t; |
2256 | unsigned long tmptaint = get_taint(); | |
2257 | int err; | |
34f5a398 | 2258 | |
91fcd412 | 2259 | if (write && !capable(CAP_SYS_ADMIN)) |
34f5a398 TT |
2260 | return -EPERM; |
2261 | ||
25ddbb18 AK |
2262 | t = *table; |
2263 | t.data = &tmptaint; | |
8d65af78 | 2264 | err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); |
25ddbb18 AK |
2265 | if (err < 0) |
2266 | return err; | |
2267 | ||
2268 | if (write) { | |
2269 | /* | |
2270 | * Poor man's atomic or. Not worth adding a primitive | |
2271 | * to everyone's atomic.h for this | |
2272 | */ | |
2273 | int i; | |
2274 | for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { | |
2275 | if ((tmptaint >> i) & 1) | |
373d4d09 | 2276 | add_taint(i, LOCKDEP_STILL_OK); |
25ddbb18 AK |
2277 | } |
2278 | } | |
2279 | ||
2280 | return err; | |
34f5a398 TT |
2281 | } |
2282 | ||
bfdc0b49 | 2283 | #ifdef CONFIG_PRINTK |
620f6e8e | 2284 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, |
bfdc0b49 RW |
2285 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2286 | { | |
2287 | if (write && !capable(CAP_SYS_ADMIN)) | |
2288 | return -EPERM; | |
2289 | ||
2290 | return proc_dointvec_minmax(table, write, buffer, lenp, ppos); | |
2291 | } | |
2292 | #endif | |
2293 | ||
1da177e4 LT |
2294 | struct do_proc_dointvec_minmax_conv_param { |
2295 | int *min; | |
2296 | int *max; | |
2297 | }; | |
2298 | ||
00b7c339 AW |
2299 | static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, |
2300 | int *valp, | |
1da177e4 LT |
2301 | int write, void *data) |
2302 | { | |
2303 | struct do_proc_dointvec_minmax_conv_param *param = data; | |
2304 | if (write) { | |
2305 | int val = *negp ? -*lvalp : *lvalp; | |
2306 | if ((param->min && *param->min > val) || | |
2307 | (param->max && *param->max < val)) | |
2308 | return -EINVAL; | |
2309 | *valp = val; | |
2310 | } else { | |
2311 | int val = *valp; | |
2312 | if (val < 0) { | |
00b7c339 | 2313 | *negp = true; |
9a5bc726 | 2314 | *lvalp = -(unsigned long)val; |
1da177e4 | 2315 | } else { |
00b7c339 | 2316 | *negp = false; |
1da177e4 LT |
2317 | *lvalp = (unsigned long)val; |
2318 | } | |
2319 | } | |
2320 | return 0; | |
2321 | } | |
2322 | ||
2323 | /** | |
2324 | * proc_dointvec_minmax - read a vector of integers with min/max values | |
2325 | * @table: the sysctl table | |
2326 | * @write: %TRUE if this is a write to the sysctl file | |
1da177e4 LT |
2327 | * @buffer: the user buffer |
2328 | * @lenp: the size of the user buffer | |
2329 | * @ppos: file position | |
2330 | * | |
2331 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | |
2332 | * values from/to the user buffer, treated as an ASCII string. | |
2333 | * | |
2334 | * This routine will ensure the values are within the range specified by | |
2335 | * table->extra1 (min) and table->extra2 (max). | |
2336 | * | |
2337 | * Returns 0 on success. | |
2338 | */ | |
8d65af78 | 2339 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
1da177e4 LT |
2340 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2341 | { | |
2342 | struct do_proc_dointvec_minmax_conv_param param = { | |
2343 | .min = (int *) table->extra1, | |
2344 | .max = (int *) table->extra2, | |
2345 | }; | |
8d65af78 | 2346 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
1da177e4 LT |
2347 | do_proc_dointvec_minmax_conv, ¶m); |
2348 | } | |
2349 | ||
54b50199 KC |
2350 | static void validate_coredump_safety(void) |
2351 | { | |
046d662f | 2352 | #ifdef CONFIG_COREDUMP |
e579d2c2 | 2353 | if (suid_dumpable == SUID_DUMP_ROOT && |
54b50199 KC |
2354 | core_pattern[0] != '/' && core_pattern[0] != '|') { |
2355 | printk(KERN_WARNING "Unsafe core_pattern used with "\ | |
2356 | "suid_dumpable=2. Pipe handler or fully qualified "\ | |
2357 | "core dump path required.\n"); | |
2358 | } | |
046d662f | 2359 | #endif |
54b50199 KC |
2360 | } |
2361 | ||
2362 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, | |
2363 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
2364 | { | |
2365 | int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | |
2366 | if (!error) | |
2367 | validate_coredump_safety(); | |
2368 | return error; | |
2369 | } | |
2370 | ||
046d662f | 2371 | #ifdef CONFIG_COREDUMP |
54b50199 KC |
2372 | static int proc_dostring_coredump(struct ctl_table *table, int write, |
2373 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
2374 | { | |
2375 | int error = proc_dostring(table, write, buffer, lenp, ppos); | |
2376 | if (!error) | |
2377 | validate_coredump_safety(); | |
2378 | return error; | |
2379 | } | |
046d662f | 2380 | #endif |
54b50199 | 2381 | |
d8217f07 | 2382 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, |
1da177e4 LT |
2383 | void __user *buffer, |
2384 | size_t *lenp, loff_t *ppos, | |
2385 | unsigned long convmul, | |
2386 | unsigned long convdiv) | |
2387 | { | |
00b7c339 AW |
2388 | unsigned long *i, *min, *max; |
2389 | int vleft, first = 1, err = 0; | |
00b7c339 | 2390 | size_t left; |
70f6cbb6 | 2391 | char *kbuf = NULL, *p; |
00b7c339 AW |
2392 | |
2393 | if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { | |
1da177e4 LT |
2394 | *lenp = 0; |
2395 | return 0; | |
2396 | } | |
00b7c339 | 2397 | |
fcfbd547 | 2398 | i = (unsigned long *) data; |
1da177e4 LT |
2399 | min = (unsigned long *) table->extra1; |
2400 | max = (unsigned long *) table->extra2; | |
2401 | vleft = table->maxlen / sizeof(unsigned long); | |
2402 | left = *lenp; | |
00b7c339 AW |
2403 | |
2404 | if (write) { | |
f4aacea2 KC |
2405 | if (*ppos) { |
2406 | switch (sysctl_writes_strict) { | |
2407 | case SYSCTL_WRITES_STRICT: | |
2408 | goto out; | |
2409 | case SYSCTL_WRITES_WARN: | |
2410 | warn_sysctl_write(table); | |
2411 | break; | |
2412 | default: | |
2413 | break; | |
2414 | } | |
2415 | } | |
2416 | ||
00b7c339 AW |
2417 | if (left > PAGE_SIZE - 1) |
2418 | left = PAGE_SIZE - 1; | |
70f6cbb6 AV |
2419 | p = kbuf = memdup_user_nul(buffer, left); |
2420 | if (IS_ERR(kbuf)) | |
2421 | return PTR_ERR(kbuf); | |
00b7c339 AW |
2422 | } |
2423 | ||
27b3d80a | 2424 | for (; left && vleft--; i++, first = 0) { |
00b7c339 AW |
2425 | unsigned long val; |
2426 | ||
1da177e4 | 2427 | if (write) { |
00b7c339 AW |
2428 | bool neg; |
2429 | ||
70f6cbb6 | 2430 | left -= proc_skip_spaces(&p); |
00b7c339 | 2431 | |
70f6cbb6 | 2432 | err = proc_get_long(&p, &left, &val, &neg, |
00b7c339 AW |
2433 | proc_wspace_sep, |
2434 | sizeof(proc_wspace_sep), NULL); | |
2435 | if (err) | |
1da177e4 LT |
2436 | break; |
2437 | if (neg) | |
1da177e4 LT |
2438 | continue; |
2439 | if ((min && val < *min) || (max && val > *max)) | |
2440 | continue; | |
2441 | *i = val; | |
2442 | } else { | |
00b7c339 | 2443 | val = convdiv * (*i) / convmul; |
7833819d | 2444 | if (!first) { |
00b7c339 | 2445 | err = proc_put_char(&buffer, &left, '\t'); |
7833819d CG |
2446 | if (err) |
2447 | break; | |
2448 | } | |
00b7c339 AW |
2449 | err = proc_put_long(&buffer, &left, val, false); |
2450 | if (err) | |
2451 | break; | |
1da177e4 LT |
2452 | } |
2453 | } | |
2454 | ||
00b7c339 AW |
2455 | if (!write && !first && left && !err) |
2456 | err = proc_put_char(&buffer, &left, '\n'); | |
2457 | if (write && !err) | |
70f6cbb6 | 2458 | left -= proc_skip_spaces(&p); |
1da177e4 | 2459 | if (write) { |
70f6cbb6 | 2460 | kfree(kbuf); |
00b7c339 AW |
2461 | if (first) |
2462 | return err ? : -EINVAL; | |
1da177e4 | 2463 | } |
1da177e4 | 2464 | *lenp -= left; |
f4aacea2 | 2465 | out: |
1da177e4 | 2466 | *ppos += *lenp; |
00b7c339 | 2467 | return err; |
1da177e4 LT |
2468 | } |
2469 | ||
d8217f07 | 2470 | static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, |
fcfbd547 KK |
2471 | void __user *buffer, |
2472 | size_t *lenp, loff_t *ppos, | |
2473 | unsigned long convmul, | |
2474 | unsigned long convdiv) | |
2475 | { | |
2476 | return __do_proc_doulongvec_minmax(table->data, table, write, | |
8d65af78 | 2477 | buffer, lenp, ppos, convmul, convdiv); |
fcfbd547 KK |
2478 | } |
2479 | ||
1da177e4 LT |
2480 | /** |
2481 | * proc_doulongvec_minmax - read a vector of long integers with min/max values | |
2482 | * @table: the sysctl table | |
2483 | * @write: %TRUE if this is a write to the sysctl file | |
1da177e4 LT |
2484 | * @buffer: the user buffer |
2485 | * @lenp: the size of the user buffer | |
2486 | * @ppos: file position | |
2487 | * | |
2488 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long | |
2489 | * values from/to the user buffer, treated as an ASCII string. | |
2490 | * | |
2491 | * This routine will ensure the values are within the range specified by | |
2492 | * table->extra1 (min) and table->extra2 (max). | |
2493 | * | |
2494 | * Returns 0 on success. | |
2495 | */ | |
8d65af78 | 2496 | int proc_doulongvec_minmax(struct ctl_table *table, int write, |
1da177e4 LT |
2497 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2498 | { | |
8d65af78 | 2499 | return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); |
1da177e4 LT |
2500 | } |
2501 | ||
2502 | /** | |
2503 | * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values | |
2504 | * @table: the sysctl table | |
2505 | * @write: %TRUE if this is a write to the sysctl file | |
1da177e4 LT |
2506 | * @buffer: the user buffer |
2507 | * @lenp: the size of the user buffer | |
2508 | * @ppos: file position | |
2509 | * | |
2510 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long | |
2511 | * values from/to the user buffer, treated as an ASCII string. The values | |
2512 | * are treated as milliseconds, and converted to jiffies when they are stored. | |
2513 | * | |
2514 | * This routine will ensure the values are within the range specified by | |
2515 | * table->extra1 (min) and table->extra2 (max). | |
2516 | * | |
2517 | * Returns 0 on success. | |
2518 | */ | |
d8217f07 | 2519 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
1da177e4 LT |
2520 | void __user *buffer, |
2521 | size_t *lenp, loff_t *ppos) | |
2522 | { | |
8d65af78 | 2523 | return do_proc_doulongvec_minmax(table, write, buffer, |
1da177e4 LT |
2524 | lenp, ppos, HZ, 1000l); |
2525 | } | |
2526 | ||
2527 | ||
00b7c339 | 2528 | static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, |
1da177e4 LT |
2529 | int *valp, |
2530 | int write, void *data) | |
2531 | { | |
2532 | if (write) { | |
cba9f33d BS |
2533 | if (*lvalp > LONG_MAX / HZ) |
2534 | return 1; | |
1da177e4 LT |
2535 | *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); |
2536 | } else { | |
2537 | int val = *valp; | |
2538 | unsigned long lval; | |
2539 | if (val < 0) { | |
00b7c339 | 2540 | *negp = true; |
9a5bc726 | 2541 | lval = -(unsigned long)val; |
1da177e4 | 2542 | } else { |
00b7c339 | 2543 | *negp = false; |
1da177e4 LT |
2544 | lval = (unsigned long)val; |
2545 | } | |
2546 | *lvalp = lval / HZ; | |
2547 | } | |
2548 | return 0; | |
2549 | } | |
2550 | ||
00b7c339 | 2551 | static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, |
1da177e4 LT |
2552 | int *valp, |
2553 | int write, void *data) | |
2554 | { | |
2555 | if (write) { | |
cba9f33d BS |
2556 | if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) |
2557 | return 1; | |
1da177e4 LT |
2558 | *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); |
2559 | } else { | |
2560 | int val = *valp; | |
2561 | unsigned long lval; | |
2562 | if (val < 0) { | |
00b7c339 | 2563 | *negp = true; |
9a5bc726 | 2564 | lval = -(unsigned long)val; |
1da177e4 | 2565 | } else { |
00b7c339 | 2566 | *negp = false; |
1da177e4 LT |
2567 | lval = (unsigned long)val; |
2568 | } | |
2569 | *lvalp = jiffies_to_clock_t(lval); | |
2570 | } | |
2571 | return 0; | |
2572 | } | |
2573 | ||
00b7c339 | 2574 | static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, |
1da177e4 LT |
2575 | int *valp, |
2576 | int write, void *data) | |
2577 | { | |
2578 | if (write) { | |
d738ce8f FF |
2579 | unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); |
2580 | ||
2581 | if (jif > INT_MAX) | |
2582 | return 1; | |
2583 | *valp = (int)jif; | |
1da177e4 LT |
2584 | } else { |
2585 | int val = *valp; | |
2586 | unsigned long lval; | |
2587 | if (val < 0) { | |
00b7c339 | 2588 | *negp = true; |
9a5bc726 | 2589 | lval = -(unsigned long)val; |
1da177e4 | 2590 | } else { |
00b7c339 | 2591 | *negp = false; |
1da177e4 LT |
2592 | lval = (unsigned long)val; |
2593 | } | |
2594 | *lvalp = jiffies_to_msecs(lval); | |
2595 | } | |
2596 | return 0; | |
2597 | } | |
2598 | ||
2599 | /** | |
2600 | * proc_dointvec_jiffies - read a vector of integers as seconds | |
2601 | * @table: the sysctl table | |
2602 | * @write: %TRUE if this is a write to the sysctl file | |
1da177e4 LT |
2603 | * @buffer: the user buffer |
2604 | * @lenp: the size of the user buffer | |
2605 | * @ppos: file position | |
2606 | * | |
2607 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | |
2608 | * values from/to the user buffer, treated as an ASCII string. | |
2609 | * The values read are assumed to be in seconds, and are converted into | |
2610 | * jiffies. | |
2611 | * | |
2612 | * Returns 0 on success. | |
2613 | */ | |
8d65af78 | 2614 | int proc_dointvec_jiffies(struct ctl_table *table, int write, |
1da177e4 LT |
2615 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2616 | { | |
8d65af78 | 2617 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
1da177e4 LT |
2618 | do_proc_dointvec_jiffies_conv,NULL); |
2619 | } | |
2620 | ||
2621 | /** | |
2622 | * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds | |
2623 | * @table: the sysctl table | |
2624 | * @write: %TRUE if this is a write to the sysctl file | |
1da177e4 LT |
2625 | * @buffer: the user buffer |
2626 | * @lenp: the size of the user buffer | |
1e5d5331 | 2627 | * @ppos: pointer to the file position |
1da177e4 LT |
2628 | * |
2629 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | |
2630 | * values from/to the user buffer, treated as an ASCII string. | |
2631 | * The values read are assumed to be in 1/USER_HZ seconds, and | |
2632 | * are converted into jiffies. | |
2633 | * | |
2634 | * Returns 0 on success. | |
2635 | */ | |
8d65af78 | 2636 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, |
1da177e4 LT |
2637 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2638 | { | |
8d65af78 | 2639 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
1da177e4 LT |
2640 | do_proc_dointvec_userhz_jiffies_conv,NULL); |
2641 | } | |
2642 | ||
2643 | /** | |
2644 | * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds | |
2645 | * @table: the sysctl table | |
2646 | * @write: %TRUE if this is a write to the sysctl file | |
1da177e4 LT |
2647 | * @buffer: the user buffer |
2648 | * @lenp: the size of the user buffer | |
67be2dd1 MW |
2649 | * @ppos: file position |
2650 | * @ppos: the current position in the file | |
1da177e4 LT |
2651 | * |
2652 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer | |
2653 | * values from/to the user buffer, treated as an ASCII string. | |
2654 | * The values read are assumed to be in 1/1000 seconds, and | |
2655 | * are converted into jiffies. | |
2656 | * | |
2657 | * Returns 0 on success. | |
2658 | */ | |
8d65af78 | 2659 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, |
1da177e4 LT |
2660 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2661 | { | |
8d65af78 | 2662 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
1da177e4 LT |
2663 | do_proc_dointvec_ms_jiffies_conv, NULL); |
2664 | } | |
2665 | ||
8d65af78 | 2666 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
9ec52099 CLG |
2667 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2668 | { | |
2669 | struct pid *new_pid; | |
2670 | pid_t tmp; | |
2671 | int r; | |
2672 | ||
6c5f3e7b | 2673 | tmp = pid_vnr(cad_pid); |
9ec52099 | 2674 | |
8d65af78 | 2675 | r = __do_proc_dointvec(&tmp, table, write, buffer, |
9ec52099 CLG |
2676 | lenp, ppos, NULL, NULL); |
2677 | if (r || !write) | |
2678 | return r; | |
2679 | ||
2680 | new_pid = find_get_pid(tmp); | |
2681 | if (!new_pid) | |
2682 | return -ESRCH; | |
2683 | ||
2684 | put_pid(xchg(&cad_pid, new_pid)); | |
2685 | return 0; | |
2686 | } | |
2687 | ||
9f977fb7 OP |
2688 | /** |
2689 | * proc_do_large_bitmap - read/write from/to a large bitmap | |
2690 | * @table: the sysctl table | |
2691 | * @write: %TRUE if this is a write to the sysctl file | |
2692 | * @buffer: the user buffer | |
2693 | * @lenp: the size of the user buffer | |
2694 | * @ppos: file position | |
2695 | * | |
2696 | * The bitmap is stored at table->data and the bitmap length (in bits) | |
2697 | * in table->maxlen. | |
2698 | * | |
2699 | * We use a range comma separated format (e.g. 1,3-4,10-10) so that | |
2700 | * large bitmaps may be represented in a compact manner. Writing into | |
2701 | * the file will clear the bitmap then update it with the given input. | |
2702 | * | |
2703 | * Returns 0 on success. | |
2704 | */ | |
2705 | int proc_do_large_bitmap(struct ctl_table *table, int write, | |
2706 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
2707 | { | |
2708 | int err = 0; | |
2709 | bool first = 1; | |
2710 | size_t left = *lenp; | |
2711 | unsigned long bitmap_len = table->maxlen; | |
122ff243 | 2712 | unsigned long *bitmap = *(unsigned long **) table->data; |
9f977fb7 OP |
2713 | unsigned long *tmp_bitmap = NULL; |
2714 | char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; | |
2715 | ||
122ff243 | 2716 | if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { |
9f977fb7 OP |
2717 | *lenp = 0; |
2718 | return 0; | |
2719 | } | |
2720 | ||
2721 | if (write) { | |
70f6cbb6 | 2722 | char *kbuf, *p; |
9f977fb7 OP |
2723 | |
2724 | if (left > PAGE_SIZE - 1) | |
2725 | left = PAGE_SIZE - 1; | |
2726 | ||
70f6cbb6 AV |
2727 | p = kbuf = memdup_user_nul(buffer, left); |
2728 | if (IS_ERR(kbuf)) | |
2729 | return PTR_ERR(kbuf); | |
9f977fb7 OP |
2730 | |
2731 | tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), | |
2732 | GFP_KERNEL); | |
2733 | if (!tmp_bitmap) { | |
70f6cbb6 | 2734 | kfree(kbuf); |
9f977fb7 OP |
2735 | return -ENOMEM; |
2736 | } | |
70f6cbb6 | 2737 | proc_skip_char(&p, &left, '\n'); |
9f977fb7 OP |
2738 | while (!err && left) { |
2739 | unsigned long val_a, val_b; | |
2740 | bool neg; | |
2741 | ||
70f6cbb6 | 2742 | err = proc_get_long(&p, &left, &val_a, &neg, tr_a, |
9f977fb7 OP |
2743 | sizeof(tr_a), &c); |
2744 | if (err) | |
2745 | break; | |
2746 | if (val_a >= bitmap_len || neg) { | |
2747 | err = -EINVAL; | |
2748 | break; | |
2749 | } | |
2750 | ||
2751 | val_b = val_a; | |
2752 | if (left) { | |
70f6cbb6 | 2753 | p++; |
9f977fb7 OP |
2754 | left--; |
2755 | } | |
2756 | ||
2757 | if (c == '-') { | |
70f6cbb6 | 2758 | err = proc_get_long(&p, &left, &val_b, |
9f977fb7 OP |
2759 | &neg, tr_b, sizeof(tr_b), |
2760 | &c); | |
2761 | if (err) | |
2762 | break; | |
2763 | if (val_b >= bitmap_len || neg || | |
2764 | val_a > val_b) { | |
2765 | err = -EINVAL; | |
2766 | break; | |
2767 | } | |
2768 | if (left) { | |
70f6cbb6 | 2769 | p++; |
9f977fb7 OP |
2770 | left--; |
2771 | } | |
2772 | } | |
2773 | ||
5a04cca6 | 2774 | bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); |
9f977fb7 | 2775 | first = 0; |
70f6cbb6 | 2776 | proc_skip_char(&p, &left, '\n'); |
9f977fb7 | 2777 | } |
70f6cbb6 | 2778 | kfree(kbuf); |
9f977fb7 OP |
2779 | } else { |
2780 | unsigned long bit_a, bit_b = 0; | |
2781 | ||
2782 | while (left) { | |
2783 | bit_a = find_next_bit(bitmap, bitmap_len, bit_b); | |
2784 | if (bit_a >= bitmap_len) | |
2785 | break; | |
2786 | bit_b = find_next_zero_bit(bitmap, bitmap_len, | |
2787 | bit_a + 1) - 1; | |
2788 | ||
2789 | if (!first) { | |
2790 | err = proc_put_char(&buffer, &left, ','); | |
2791 | if (err) | |
2792 | break; | |
2793 | } | |
2794 | err = proc_put_long(&buffer, &left, bit_a, false); | |
2795 | if (err) | |
2796 | break; | |
2797 | if (bit_a != bit_b) { | |
2798 | err = proc_put_char(&buffer, &left, '-'); | |
2799 | if (err) | |
2800 | break; | |
2801 | err = proc_put_long(&buffer, &left, bit_b, false); | |
2802 | if (err) | |
2803 | break; | |
2804 | } | |
2805 | ||
2806 | first = 0; bit_b++; | |
2807 | } | |
2808 | if (!err) | |
2809 | err = proc_put_char(&buffer, &left, '\n'); | |
2810 | } | |
2811 | ||
2812 | if (!err) { | |
2813 | if (write) { | |
2814 | if (*ppos) | |
2815 | bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); | |
2816 | else | |
5a04cca6 | 2817 | bitmap_copy(bitmap, tmp_bitmap, bitmap_len); |
9f977fb7 OP |
2818 | } |
2819 | kfree(tmp_bitmap); | |
2820 | *lenp -= left; | |
2821 | *ppos += *lenp; | |
2822 | return 0; | |
2823 | } else { | |
2824 | kfree(tmp_bitmap); | |
2825 | return err; | |
2826 | } | |
2827 | } | |
2828 | ||
55610500 | 2829 | #else /* CONFIG_PROC_SYSCTL */ |
1da177e4 | 2830 | |
8d65af78 | 2831 | int proc_dostring(struct ctl_table *table, int write, |
1da177e4 LT |
2832 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2833 | { | |
2834 | return -ENOSYS; | |
2835 | } | |
2836 | ||
8d65af78 | 2837 | int proc_dointvec(struct ctl_table *table, int write, |
1da177e4 | 2838 | void __user *buffer, size_t *lenp, loff_t *ppos) |
1da177e4 LT |
2839 | { |
2840 | return -ENOSYS; | |
2841 | } | |
2842 | ||
8d65af78 | 2843 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
1da177e4 LT |
2844 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2845 | { | |
2846 | return -ENOSYS; | |
2847 | } | |
2848 | ||
8d65af78 | 2849 | int proc_dointvec_jiffies(struct ctl_table *table, int write, |
1da177e4 LT |
2850 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2851 | { | |
2852 | return -ENOSYS; | |
2853 | } | |
2854 | ||
8d65af78 | 2855 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, |
1da177e4 LT |
2856 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2857 | { | |
2858 | return -ENOSYS; | |
2859 | } | |
2860 | ||
8d65af78 | 2861 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, |
1da177e4 LT |
2862 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2863 | { | |
2864 | return -ENOSYS; | |
2865 | } | |
2866 | ||
8d65af78 | 2867 | int proc_doulongvec_minmax(struct ctl_table *table, int write, |
1da177e4 LT |
2868 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2869 | { | |
2870 | return -ENOSYS; | |
2871 | } | |
2872 | ||
d8217f07 | 2873 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
1da177e4 LT |
2874 | void __user *buffer, |
2875 | size_t *lenp, loff_t *ppos) | |
2876 | { | |
2877 | return -ENOSYS; | |
2878 | } | |
2879 | ||
2880 | ||
55610500 | 2881 | #endif /* CONFIG_PROC_SYSCTL */ |
1da177e4 | 2882 | |
1da177e4 LT |
2883 | /* |
2884 | * No sense putting this after each symbol definition, twice, | |
2885 | * exception granted :-) | |
2886 | */ | |
2887 | EXPORT_SYMBOL(proc_dointvec); | |
2888 | EXPORT_SYMBOL(proc_dointvec_jiffies); | |
2889 | EXPORT_SYMBOL(proc_dointvec_minmax); | |
2890 | EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); | |
2891 | EXPORT_SYMBOL(proc_dointvec_ms_jiffies); | |
2892 | EXPORT_SYMBOL(proc_dostring); | |
2893 | EXPORT_SYMBOL(proc_doulongvec_minmax); | |
2894 | EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); |