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