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