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