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