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