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