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