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