Blame view

kernel/sysctl.c 74.1 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  /*
   * sysctl.c: General linux system control interface
   *
   * Begun 24 March 1995, Stephen Tweedie
   * Added /proc support, Dec 1995
   * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
   * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
   * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
   * Dynamic registration fixes, Stephen Tweedie.
   * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
   * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
   *  Horn.
   * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
   * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
   * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
   *  Wendling.
   * The list_for_each() macro wasn't appropriate for the sysctl loop.
   *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20
  #include <linux/module.h>
e2e40f2c1   Christoph Hellwig   fs: move struct k...
21
  #include <linux/aio.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
24
25
  #include <linux/mm.h>
  #include <linux/swap.h>
  #include <linux/slab.h>
  #include <linux/sysctl.h>
5a04cca6c   Akinobu Mita   sysctl: use bitma...
26
  #include <linux/bitmap.h>
d33ed52d5   Dave Young   sysctl extern cle...
27
  #include <linux/signal.h>
455cd5ab3   Dan Rosenberg   kptr_restrict for...
28
  #include <linux/printk.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
  #include <linux/proc_fs.h>
72c2d5823   Andrew Morgan   V3 file capabilit...
30
  #include <linux/security.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
  #include <linux/ctype.h>
fd4b616b0   Steven Rostedt   sysctl: suppress ...
32
  #include <linux/kmemleak.h>
62239ac2b   Adrian Bunk   proper prototype ...
33
  #include <linux/fs.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
  #include <linux/init.h>
  #include <linux/kernel.h>
0296b2281   Kay Sievers   [PATCH] remove CO...
36
  #include <linux/kobject.h>
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
37
  #include <linux/net.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
39
40
  #include <linux/sysrq.h>
  #include <linux/highuid.h>
  #include <linux/writeback.h>
3fff4c42b   Ingo Molnar   printk: Remove ra...
41
  #include <linux/ratelimit.h>
76ab0f530   Mel Gorman   mm: compaction: a...
42
  #include <linux/compaction.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
  #include <linux/hugetlb.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
  #include <linux/initrd.h>
0b77f5bfb   David Howells   keys: make the ke...
45
  #include <linux/key.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
  #include <linux/times.h>
  #include <linux/limits.h>
  #include <linux/dcache.h>
6e006701c   Alexey Dobriyan   dnotify: move dir...
49
  #include <linux/dnotify.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
  #include <linux/syscalls.h>
c748e1340   Adrian Bunk   mm/vmstat.c: prop...
51
  #include <linux/vmstat.h>
c255d844d   Pavel Machek   [PATCH] suspend-t...
52
53
  #include <linux/nfs_fs.h>
  #include <linux/acpi.h>
10a0a8d4e   Jeremy Fitzhardinge   Add common orderl...
54
  #include <linux/reboot.h>
b0fc494fa   Steven Rostedt   ftrace: add ftrac...
55
  #include <linux/ftrace.h>
cdd6c482c   Ingo Molnar   perf: Do the big ...
56
  #include <linux/perf_event.h>
b2be84df9   Masami Hiramatsu   kprobes: Jump opt...
57
  #include <linux/kprobes.h>
b492e95be   Jens Axboe   pipe: set lower a...
58
  #include <linux/pipe_fs_i.h>
8e4228e1e   David Rientjes   oom: move sysctl ...
59
  #include <linux/oom.h>
17f60a7da   Eric Paris   capabilites: allo...
60
  #include <linux/kmod.h>
73efc0394   Dan Ballard   kernel/sysctl.c: ...
61
  #include <linux/capability.h>
404015308   Al Viro   security: trim se...
62
  #include <linux/binfmts.h>
cf4aebc29   Clark Williams   sched: Move sched...
63
  #include <linux/sched/sysctl.h>
f7ccbae45   Ingo Molnar   sched/headers: Pr...
64
  #include <linux/sched/coredump.h>
7984754b9   Kees Cook   kexec: add sysctl...
65
  #include <linux/kexec.h>
1be7f75d1   Alexei Starovoitov   bpf: enable non-r...
66
  #include <linux/bpf.h>
d29216842   Eric W. Biederman   mnt: Add a per mo...
67
  #include <linux/mount.h>
7a8d18194   Joe Lawrence   pipe: add proc_do...
68
  #include <linux/pipe_fs_i.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69

7c0f6ba68   Linus Torvalds   Replace <asm/uacc...
70
  #include <linux/uaccess.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
  #include <asm/processor.h>
29cbc78b9   Andi Kleen   [PATCH] x86: Clea...
72
73
  #ifdef CONFIG_X86
  #include <asm/nmi.h>
0741f4d20   Chuck Ebbert   [PATCH] x86: add ...
74
  #include <asm/stacktrace.h>
6e7c40259   Ingo Molnar   x86: various chan...
75
  #include <asm/io.h>
29cbc78b9   Andi Kleen   [PATCH] x86: Clea...
76
  #endif
d550bbd40   David Howells   Disintegrate asm/...
77
78
79
  #ifdef CONFIG_SPARC
  #include <asm/setup.h>
  #endif
c55b7c3e8   Dave Young   sysctl extern cle...
80
81
82
  #ifdef CONFIG_BSD_PROCESS_ACCT
  #include <linux/acct.h>
  #endif
4f0e056fd   Dave Young   sysctl extern cle...
83
84
85
  #ifdef CONFIG_RT_MUTEXES
  #include <linux/rtmutex.h>
  #endif
2edf5e498   Dave Young   sysctl extern cle...
86
87
88
  #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
  #include <linux/lockdep.h>
  #endif
15485a468   Dave Young   sysctl extern cle...
89
90
91
  #ifdef CONFIG_CHR_DEV_SG
  #include <scsi/sg.h>
  #endif
29cbc78b9   Andi Kleen   [PATCH] x86: Clea...
92

58687acba   Don Zickus   lockup_detector: ...
93
  #ifdef CONFIG_LOCKUP_DETECTOR
504d7cf10   Don Zickus   nmi_watchdog: Com...
94
95
  #include <linux/nmi.h>
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
97
98
  #if defined(CONFIG_SYSCTL)
  
  /* External variables not in a header file. */
d6e711448   Alan Cox   [PATCH] setuid co...
99
  extern int suid_dumpable;
046d662f4   Alex Kelly   coredump: make co...
100
101
  #ifdef CONFIG_COREDUMP
  extern int core_uses_pid;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
  extern char core_pattern[];
a293980c2   Neil Horman   exec: let do_core...
103
  extern unsigned int core_pipe_limit;
046d662f4   Alex Kelly   coredump: make co...
104
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
105
  extern int pid_max;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
  extern int pid_max_min, pid_max_max;
8ad4b1fb8   Rohit Seth   [PATCH] Make high...
107
  extern int percpu_pagelist_fraction;
9745512ce   Arjan van de Ven   sched: latencytop...
108
  extern int latencytop_enabled;
9b80a184e   Alexey Dobriyan   fs/file: more uns...
109
  extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
dd8632a12   Paul Mundt   NOMMU: Make mmap ...
110
111
112
  #ifndef CONFIG_MMU
  extern int sysctl_nr_trim_pages;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113

c4f3b63fe   Ravikiran G Thirumalai   softlockup: add a...
114
  /* Constants used for minimum and  maximum */
2508ce184   Don Zickus   lockup_detector: ...
115
  #ifdef CONFIG_LOCKUP_DETECTOR
c4f3b63fe   Ravikiran G Thirumalai   softlockup: add a...
116
117
  static int sixty = 60;
  #endif
270750dbc   Aaron Tomlin   hung_task: Displa...
118
  static int __maybe_unused neg_one = -1;
c4f3b63fe   Ravikiran G Thirumalai   softlockup: add a...
119
  static int zero;
cd5f9a4c3   Linus Torvalds   kernel/sysctl.c: ...
120
121
  static int __maybe_unused one = 1;
  static int __maybe_unused two = 2;
5509a5d27   Dave Hansen   drop_caches: add ...
122
  static int __maybe_unused four = 4;
fc3501d41   Sven Wegener   mm: fix dirty_byt...
123
  static unsigned long one_ul = 1;
c4f3b63fe   Ravikiran G Thirumalai   softlockup: add a...
124
  static int one_hundred = 100;
795ae7a0d   Johannes Weiner   mm: scale kswapd ...
125
  static int one_thousand = 1000;
af91322ef   Dave Young   printk: add print...
126
127
128
  #ifdef CONFIG_PRINTK
  static int ten_thousand = 10000;
  #endif
c5dfd78eb   Arnaldo Carvalho de Melo   perf core: Allow ...
129
130
131
  #ifdef CONFIG_PERF_EVENTS
  static int six_hundred_forty_kb = 640 * 1024;
  #endif
c4f3b63fe   Ravikiran G Thirumalai   softlockup: add a...
132

9e4a5bda8   Andrea Righi   mm: prevent divid...
133
134
  /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
  static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
135
136
137
138
139
  /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
  static int maxolduid = 65535;
  static int minolduid;
  
  static int ngroups_max = NGROUPS_MAX;
73efc0394   Dan Ballard   kernel/sysctl.c: ...
140
  static const int cap_last_cap = CAP_LAST_CAP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141

80df28476   Liu Hua   hung_task: check ...
142
143
144
145
  /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
  #ifdef CONFIG_DETECT_HUNG_TASK
  static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
  #endif
d14f17294   Dave Young   sysctl extern cle...
146
147
148
  #ifdef CONFIG_INOTIFY_USER
  #include <linux/inotify.h>
  #endif
72c57ed50   David S. Miller   sysctl: Use CONFI...
149
  #ifdef CONFIG_SPARC
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
150
151
152
153
  #endif
  
  #ifdef __hppa__
  extern int pwrsw_enabled;
bf14e3b97   Vineet Gupta   sysctl: Enable PA...
154
155
156
  #endif
  
  #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157
158
  extern int unaligned_enabled;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
159

d2b176ed8   Jes Sorensen   [IA64] sysctl opt...
160
  #ifdef CONFIG_IA64
88fc241f5   Doug Chapman   [IA64] dump stack...
161
  extern int unaligned_dump_stack;
d2b176ed8   Jes Sorensen   [IA64] sysctl opt...
162
  #endif
b6fca7253   Vineet Gupta   sysctl: Enable IA...
163
164
165
  #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
  extern int no_unaligned_warning;
  #endif
d6f8ff738   Randy Dunlap   [PATCH] cad_pid s...
166
  #ifdef CONFIG_PROC_SYSCTL
f4aacea2f   Kees Cook   sysctl: allow for...
167

a19ac3374   Luis R. Rodriguez   sysctl: kdoc'ify ...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
  /**
   * enum sysctl_writes_mode - supported sysctl write modes
   *
   * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
   * 	to be written, and multiple writes on the same sysctl file descriptor
   * 	will rewrite the sysctl value, regardless of file position. No warning
   * 	is issued when the initial position is not 0.
   * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
   * 	not 0.
   * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
   * 	file position 0 and the value must be fully contained in the buffer
   * 	sent to the write syscall. If dealing with strings respect the file
   * 	position, but restrict this to the max length of the buffer, anything
   * 	passed the max lenght will be ignored. Multiple writes will append
   * 	to the buffer.
   *
   * These write modes control how current file position affects the behavior of
   * updating sysctl values through the proc interface on each write.
   */
  enum sysctl_writes_mode {
  	SYSCTL_WRITES_LEGACY		= -1,
  	SYSCTL_WRITES_WARN		= 0,
  	SYSCTL_WRITES_STRICT		= 1,
  };
f4aacea2f   Kees Cook   sysctl: allow for...
192

a19ac3374   Luis R. Rodriguez   sysctl: kdoc'ify ...
193
  static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
f4aacea2f   Kees Cook   sysctl: allow for...
194

8d65af789   Alexey Dobriyan   sysctl: remove "s...
195
  static int proc_do_cad_pid(struct ctl_table *table, int write,
9ec52099e   Cedric Le Goater   [PATCH] replace c...
196
  		  void __user *buffer, size_t *lenp, loff_t *ppos);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
197
  static int proc_taint(struct ctl_table *table, int write,
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
198
  			       void __user *buffer, size_t *lenp, loff_t *ppos);
d6f8ff738   Randy Dunlap   [PATCH] cad_pid s...
199
  #endif
9ec52099e   Cedric Le Goater   [PATCH] replace c...
200

bfdc0b497   Richard Weinberger   sysctl: restrict ...
201
  #ifdef CONFIG_PRINTK
620f6e8e8   Kees Cook   sysctl: fix write...
202
  static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
bfdc0b497   Richard Weinberger   sysctl: restrict ...
203
204
  				void __user *buffer, size_t *lenp, loff_t *ppos);
  #endif
54b501992   Kees Cook   coredump: warn ab...
205
206
  static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
  		void __user *buffer, size_t *lenp, loff_t *ppos);
046d662f4   Alex Kelly   coredump: make co...
207
  #ifdef CONFIG_COREDUMP
54b501992   Kees Cook   coredump: warn ab...
208
209
  static int proc_dostring_coredump(struct ctl_table *table, int write,
  		void __user *buffer, size_t *lenp, loff_t *ppos);
046d662f4   Alex Kelly   coredump: make co...
210
  #endif
54b501992   Kees Cook   coredump: warn ab...
211

97f5f0cd8   Dmitry Torokhov   Input: implement ...
212
  #ifdef CONFIG_MAGIC_SYSRQ
8c6a98b22   Andy Whitcroft   Input: sysrq - en...
213
  /* Note: sysrq code uses it's own private copy */
8eaede49d   Ben Hutchings   sysrq: Allow magi...
214
  static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
97f5f0cd8   Dmitry Torokhov   Input: implement ...
215

6f8fd1d77   Joe Perches   sysctl: convert u...
216
  static int sysrq_sysctl_handler(struct ctl_table *table, int write,
97f5f0cd8   Dmitry Torokhov   Input: implement ...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
  				void __user *buffer, size_t *lenp,
  				loff_t *ppos)
  {
  	int error;
  
  	error = proc_dointvec(table, write, buffer, lenp, ppos);
  	if (error)
  		return error;
  
  	if (write)
  		sysrq_toggle_support(__sysrq_enabled);
  
  	return 0;
  }
  
  #endif
d8217f076   Eric W. Biederman   sysctl core: Stop...
233
234
235
236
237
238
  static struct ctl_table kern_table[];
  static struct ctl_table vm_table[];
  static struct ctl_table fs_table[];
  static struct ctl_table debug_table[];
  static struct ctl_table dev_table[];
  extern struct ctl_table random_table[];
7ef9964e6   Davide Libenzi   epoll: introduce ...
239
240
241
  #ifdef CONFIG_EPOLL
  extern struct ctl_table epoll_table[];
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
242
243
244
245
  
  #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  int sysctl_legacy_va_layout;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
246
  /* The default sysctl tables: */
de4e83bd6   Eric W. Biederman   sysctl: Register ...
247
  static struct ctl_table sysctl_base_table[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
248
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
249
250
251
252
253
  		.procname	= "kernel",
  		.mode		= 0555,
  		.child		= kern_table,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
254
255
256
257
  		.procname	= "vm",
  		.mode		= 0555,
  		.child		= vm_table,
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
258
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
259
260
261
262
263
  		.procname	= "fs",
  		.mode		= 0555,
  		.child		= fs_table,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
264
265
266
267
268
  		.procname	= "debug",
  		.mode		= 0555,
  		.child		= debug_table,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
269
270
271
272
  		.procname	= "dev",
  		.mode		= 0555,
  		.child		= dev_table,
  	},
6fce56ec9   Eric W. Biederman   sysctl: Remove re...
273
  	{ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
274
  };
77e54a1f8   Ingo Molnar   sched: add CFS de...
275
  #ifdef CONFIG_SCHED_DEBUG
73c4efd2c   Eric Dumazet   sched: sysctl, pr...
276
277
278
279
  static int min_sched_granularity_ns = 100000;		/* 100 usecs */
  static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
  static int min_wakeup_granularity_ns;			/* 0 usecs */
  static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
cbee9f88e   Peter Zijlstra   mm: numa: Add fau...
280
  #ifdef CONFIG_SMP
1983a922a   Christian Ehrhardt   sched: Make tunab...
281
282
  static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
  static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
cbee9f88e   Peter Zijlstra   mm: numa: Add fau...
283
284
  #endif /* CONFIG_SMP */
  #endif /* CONFIG_SCHED_DEBUG */
77e54a1f8   Ingo Molnar   sched: add CFS de...
285

5e7719058   Mel Gorman   mm: compaction: a...
286
287
288
289
  #ifdef CONFIG_COMPACTION
  static int min_extfrag_threshold;
  static int max_extfrag_threshold = 1000;
  #endif
d8217f076   Eric W. Biederman   sysctl core: Stop...
290
  static struct ctl_table kern_table[] = {
2bba22c50   Mike Galbraith   sched: Turn off c...
291
  	{
2bba22c50   Mike Galbraith   sched: Turn off c...
292
293
294
295
  		.procname	= "sched_child_runs_first",
  		.data		= &sysctl_sched_child_runs_first,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
296
  		.proc_handler	= proc_dointvec,
2bba22c50   Mike Galbraith   sched: Turn off c...
297
  	},
77e54a1f8   Ingo Molnar   sched: add CFS de...
298
299
  #ifdef CONFIG_SCHED_DEBUG
  	{
b2be5e96d   Peter Zijlstra   sched: reintroduc...
300
301
  		.procname	= "sched_min_granularity_ns",
  		.data		= &sysctl_sched_min_granularity,
77e54a1f8   Ingo Molnar   sched: add CFS de...
302
303
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
702a7c760   Linus Torvalds   Merge branch 'sch...
304
  		.proc_handler	= sched_proc_update_handler,
b2be5e96d   Peter Zijlstra   sched: reintroduc...
305
306
  		.extra1		= &min_sched_granularity_ns,
  		.extra2		= &max_sched_granularity_ns,
77e54a1f8   Ingo Molnar   sched: add CFS de...
307
308
  	},
  	{
218050855   Peter Zijlstra   sched: adaptive s...
309
310
311
312
  		.procname	= "sched_latency_ns",
  		.data		= &sysctl_sched_latency,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
702a7c760   Linus Torvalds   Merge branch 'sch...
313
  		.proc_handler	= sched_proc_update_handler,
218050855   Peter Zijlstra   sched: adaptive s...
314
315
316
317
  		.extra1		= &min_sched_granularity_ns,
  		.extra2		= &max_sched_granularity_ns,
  	},
  	{
77e54a1f8   Ingo Molnar   sched: add CFS de...
318
319
320
321
  		.procname	= "sched_wakeup_granularity_ns",
  		.data		= &sysctl_sched_wakeup_granularity,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
702a7c760   Linus Torvalds   Merge branch 'sch...
322
  		.proc_handler	= sched_proc_update_handler,
77e54a1f8   Ingo Molnar   sched: add CFS de...
323
324
325
  		.extra1		= &min_wakeup_granularity_ns,
  		.extra2		= &max_wakeup_granularity_ns,
  	},
cbee9f88e   Peter Zijlstra   mm: numa: Add fau...
326
  #ifdef CONFIG_SMP
77e54a1f8   Ingo Molnar   sched: add CFS de...
327
  	{
1983a922a   Christian Ehrhardt   sched: Make tunab...
328
329
330
331
  		.procname	= "sched_tunable_scaling",
  		.data		= &sysctl_sched_tunable_scaling,
  		.maxlen		= sizeof(enum sched_tunable_scaling),
  		.mode		= 0644,
702a7c760   Linus Torvalds   Merge branch 'sch...
332
  		.proc_handler	= sched_proc_update_handler,
1983a922a   Christian Ehrhardt   sched: Make tunab...
333
334
  		.extra1		= &min_sched_tunable_scaling,
  		.extra2		= &max_sched_tunable_scaling,
2398f2c6d   Peter Zijlstra   sched: update sha...
335
336
  	},
  	{
d00535db4   Namhyung Kim   sched: Add time u...
337
  		.procname	= "sched_migration_cost_ns",
da84d9617   Ingo Molnar   sched: reintroduc...
338
339
340
  		.data		= &sysctl_sched_migration_cost,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
341
  		.proc_handler	= proc_dointvec,
da84d9617   Ingo Molnar   sched: reintroduc...
342
  	},
b82d9fdd8   Peter Zijlstra   sched: avoid larg...
343
  	{
b82d9fdd8   Peter Zijlstra   sched: avoid larg...
344
345
346
  		.procname	= "sched_nr_migrate",
  		.data		= &sysctl_sched_nr_migrate,
  		.maxlen		= sizeof(unsigned int),
fa85ae241   Peter Zijlstra   sched: rt time limit
347
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
348
  		.proc_handler	= proc_dointvec,
fa85ae241   Peter Zijlstra   sched: rt time limit
349
  	},
cd1bb94b4   Arun R Bharadwaj   timers: /proc/sys...
350
  	{
d00535db4   Namhyung Kim   sched: Add time u...
351
  		.procname	= "sched_time_avg_ms",
e9e9250bc   Peter Zijlstra   sched: Scale down...
352
353
354
  		.data		= &sysctl_sched_time_avg,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
5ccba44ba   Ethan Zhao   sched/sysctl: Che...
355
356
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &one,
e9e9250bc   Peter Zijlstra   sched: Scale down...
357
  	},
cb2517653   Mel Gorman   sched/debug: Make...
358
359
360
361
362
363
364
365
366
367
368
  #ifdef CONFIG_SCHEDSTATS
  	{
  		.procname	= "sched_schedstats",
  		.data		= NULL,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
  		.proc_handler	= sysctl_schedstats,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  #endif /* CONFIG_SCHEDSTATS */
cbee9f88e   Peter Zijlstra   mm: numa: Add fau...
369
370
371
  #endif /* CONFIG_SMP */
  #ifdef CONFIG_NUMA_BALANCING
  	{
4b96a29ba   Peter Zijlstra   mm: sched: numa: ...
372
373
374
375
376
377
378
  		.procname	= "numa_balancing_scan_delay_ms",
  		.data		= &sysctl_numa_balancing_scan_delay,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
  	{
cbee9f88e   Peter Zijlstra   mm: numa: Add fau...
379
380
381
382
383
384
385
386
387
388
389
390
391
  		.procname	= "numa_balancing_scan_period_min_ms",
  		.data		= &sysctl_numa_balancing_scan_period_min,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
  	{
  		.procname	= "numa_balancing_scan_period_max_ms",
  		.data		= &sysctl_numa_balancing_scan_period_max,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
6e5fb223e   Peter Zijlstra   mm: sched: numa: ...
392
393
394
395
396
  	{
  		.procname	= "numa_balancing_scan_size_mb",
  		.data		= &sysctl_numa_balancing_scan_size,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
641926589   Kirill Tkhai   sched/fair: Fix d...
397
398
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &one,
6e5fb223e   Peter Zijlstra   mm: sched: numa: ...
399
  	},
3a7053b32   Mel Gorman   sched/numa: Favou...
400
  	{
54a43d549   Andi Kleen   numa: add a sysct...
401
402
403
404
405
406
407
408
  		.procname	= "numa_balancing",
  		.data		= NULL, /* filled in by handler */
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
  		.proc_handler	= sysctl_numa_balancing,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
cbee9f88e   Peter Zijlstra   mm: numa: Add fau...
409
410
  #endif /* CONFIG_NUMA_BALANCING */
  #endif /* CONFIG_SCHED_DEBUG */
1799e35d5   Ingo Molnar   sched: add /proc/...
411
  	{
9f0c1e560   Peter Zijlstra   sched: rt-group: ...
412
413
414
415
  		.procname	= "sched_rt_period_us",
  		.data		= &sysctl_sched_rt_period,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
416
  		.proc_handler	= sched_rt_handler,
9f0c1e560   Peter Zijlstra   sched: rt-group: ...
417
418
  	},
  	{
9f0c1e560   Peter Zijlstra   sched: rt-group: ...
419
420
421
422
  		.procname	= "sched_rt_runtime_us",
  		.data		= &sysctl_sched_rt_runtime,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
423
  		.proc_handler	= sched_rt_handler,
9f0c1e560   Peter Zijlstra   sched: rt-group: ...
424
  	},
ce0dbbbb3   Clark Williams   sched/rt: Add a t...
425
426
  	{
  		.procname	= "sched_rr_timeslice_ms",
975e155ed   Shile Zhang   sched/rt: Show th...
427
  		.data		= &sysctl_sched_rr_timeslice,
ce0dbbbb3   Clark Williams   sched/rt: Add a t...
428
429
430
431
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= sched_rr_handler,
  	},
5091faa44   Mike Galbraith   sched: Add 'autog...
432
433
434
435
436
437
  #ifdef CONFIG_SCHED_AUTOGROUP
  	{
  		.procname	= "sched_autogroup_enabled",
  		.data		= &sysctl_sched_autogroup_enabled,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
1747b21fe   Yong Zhang   sched, autogroup,...
438
  		.proc_handler	= proc_dointvec_minmax,
5091faa44   Mike Galbraith   sched: Add 'autog...
439
440
441
442
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  #endif
ec12cb7f3   Paul Turner   sched: Accumulate...
443
444
445
446
447
448
449
450
451
452
  #ifdef CONFIG_CFS_BANDWIDTH
  	{
  		.procname	= "sched_cfs_bandwidth_slice_us",
  		.data		= &sysctl_sched_cfs_bandwidth_slice,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &one,
  	},
  #endif
f20786ff4   Peter Zijlstra   lockstat: core in...
453
454
  #ifdef CONFIG_PROVE_LOCKING
  	{
f20786ff4   Peter Zijlstra   lockstat: core in...
455
456
457
458
  		.procname	= "prove_locking",
  		.data		= &prove_locking,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
459
  		.proc_handler	= proc_dointvec,
f20786ff4   Peter Zijlstra   lockstat: core in...
460
461
462
463
  	},
  #endif
  #ifdef CONFIG_LOCK_STAT
  	{
f20786ff4   Peter Zijlstra   lockstat: core in...
464
465
466
467
  		.procname	= "lock_stat",
  		.data		= &lock_stat,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
468
  		.proc_handler	= proc_dointvec,
f20786ff4   Peter Zijlstra   lockstat: core in...
469
470
  	},
  #endif
77e54a1f8   Ingo Molnar   sched: add CFS de...
471
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
472
473
474
475
  		.procname	= "panic",
  		.data		= &panic_timeout,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
476
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
477
  	},
046d662f4   Alex Kelly   coredump: make co...
478
  #ifdef CONFIG_COREDUMP
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
479
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
480
481
482
483
  		.procname	= "core_uses_pid",
  		.data		= &core_uses_pid,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
484
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
485
486
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
487
488
  		.procname	= "core_pattern",
  		.data		= core_pattern,
71ce92f3f   Dan Aloni   make sysctl/kerne...
489
  		.maxlen		= CORENAME_MAX_SIZE,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
490
  		.mode		= 0644,
54b501992   Kees Cook   coredump: warn ab...
491
  		.proc_handler	= proc_dostring_coredump,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
492
  	},
a293980c2   Neil Horman   exec: let do_core...
493
  	{
a293980c2   Neil Horman   exec: let do_core...
494
495
496
497
  		.procname	= "core_pipe_limit",
  		.data		= &core_pipe_limit,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
498
  		.proc_handler	= proc_dointvec,
a293980c2   Neil Horman   exec: let do_core...
499
  	},
046d662f4   Alex Kelly   coredump: make co...
500
  #endif
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
501
  #ifdef CONFIG_PROC_SYSCTL
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
502
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
503
  		.procname	= "tainted",
25ddbb18a   Andi Kleen   Make the taint fl...
504
  		.maxlen 	= sizeof(long),
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
505
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
506
  		.proc_handler	= proc_taint,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
507
  	},
f4aacea2f   Kees Cook   sysctl: allow for...
508
509
510
511
512
513
514
515
516
  	{
  		.procname	= "sysctl_writes_strict",
  		.data		= &sysctl_writes_strict,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &neg_one,
  		.extra2		= &one,
  	},
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
517
  #endif
9745512ce   Arjan van de Ven   sched: latencytop...
518
519
520
521
522
523
  #ifdef CONFIG_LATENCYTOP
  	{
  		.procname	= "latencytop",
  		.data		= &latencytop_enabled,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
cb2517653   Mel Gorman   sched/debug: Make...
524
  		.proc_handler	= sysctl_latencytop,
9745512ce   Arjan van de Ven   sched: latencytop...
525
526
  	},
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
527
528
  #ifdef CONFIG_BLK_DEV_INITRD
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
529
530
531
532
  		.procname	= "real-root-dev",
  		.data		= &real_root_dev,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
533
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
534
535
  	},
  #endif
45807a1df   Ingo Molnar   vdso: print fatal...
536
  	{
45807a1df   Ingo Molnar   vdso: print fatal...
537
538
539
540
  		.procname	= "print-fatal-signals",
  		.data		= &print_fatal_signals,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
541
  		.proc_handler	= proc_dointvec,
45807a1df   Ingo Molnar   vdso: print fatal...
542
  	},
72c57ed50   David S. Miller   sysctl: Use CONFI...
543
  #ifdef CONFIG_SPARC
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
544
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
545
546
547
548
  		.procname	= "reboot-cmd",
  		.data		= reboot_command,
  		.maxlen		= 256,
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
549
  		.proc_handler	= proc_dostring,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
550
551
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
552
553
554
555
  		.procname	= "stop-a",
  		.data		= &stop_a_enabled,
  		.maxlen		= sizeof (int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
556
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
557
558
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
559
560
561
562
  		.procname	= "scons-poweroff",
  		.data		= &scons_pwroff,
  		.maxlen		= sizeof (int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
563
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
564
565
  	},
  #endif
0871420fa   David S. Miller   sparc64: Add tsb-...
566
567
  #ifdef CONFIG_SPARC64
  	{
0871420fa   David S. Miller   sparc64: Add tsb-...
568
569
570
571
  		.procname	= "tsb-ratio",
  		.data		= &sysctl_tsb_ratio,
  		.maxlen		= sizeof (int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
572
  		.proc_handler	= proc_dointvec,
0871420fa   David S. Miller   sparc64: Add tsb-...
573
574
  	},
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
575
576
  #ifdef __hppa__
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
577
578
579
580
  		.procname	= "soft-power",
  		.data		= &pwrsw_enabled,
  		.maxlen		= sizeof (int),
  	 	.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
581
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
582
  	},
bf14e3b97   Vineet Gupta   sysctl: Enable PA...
583
584
  #endif
  #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
585
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
586
587
588
589
  		.procname	= "unaligned-trap",
  		.data		= &unaligned_enabled,
  		.maxlen		= sizeof (int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
590
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
591
592
593
  	},
  #endif
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
594
595
596
597
  		.procname	= "ctrl-alt-del",
  		.data		= &C_A_D,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
598
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
599
  	},
606576ce8   Steven Rostedt   ftrace: rename FT...
600
  #ifdef CONFIG_FUNCTION_TRACER
b0fc494fa   Steven Rostedt   ftrace: add ftrac...
601
  	{
b0fc494fa   Steven Rostedt   ftrace: add ftrac...
602
603
604
605
  		.procname	= "ftrace_enabled",
  		.data		= &ftrace_enabled,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
606
  		.proc_handler	= ftrace_enable_sysctl,
b0fc494fa   Steven Rostedt   ftrace: add ftrac...
607
608
  	},
  #endif
f38f1d2aa   Steven Rostedt   trace: add a way ...
609
610
  #ifdef CONFIG_STACK_TRACER
  	{
f38f1d2aa   Steven Rostedt   trace: add a way ...
611
612
613
614
  		.procname	= "stack_tracer_enabled",
  		.data		= &stack_tracer_enabled,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
615
  		.proc_handler	= stack_trace_sysctl,
f38f1d2aa   Steven Rostedt   trace: add a way ...
616
617
  	},
  #endif
944ac4259   Steven Rostedt   ftrace: ftrace du...
618
619
  #ifdef CONFIG_TRACING
  	{
3299b4dd1   Peter Zijlstra   ftrace: sysctl typo
620
  		.procname	= "ftrace_dump_on_oops",
944ac4259   Steven Rostedt   ftrace: ftrace du...
621
622
623
  		.data		= &ftrace_dump_on_oops,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
624
  		.proc_handler	= proc_dointvec,
944ac4259   Steven Rostedt   ftrace: ftrace du...
625
  	},
de7edd314   Steven Rostedt (Red Hat)   tracing: Disable ...
626
627
628
629
630
631
632
  	{
  		.procname	= "traceoff_on_warning",
  		.data		= &__disable_trace_on_warning,
  		.maxlen		= sizeof(__disable_trace_on_warning),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
0daa23029   Steven Rostedt (Red Hat)   tracing: Add tp_p...
633
634
635
636
637
  	{
  		.procname	= "tracepoint_printk",
  		.data		= &tracepoint_printk,
  		.maxlen		= sizeof(tracepoint_printk),
  		.mode		= 0644,
423917457   Steven Rostedt (Red Hat)   tracing: Make tra...
638
  		.proc_handler	= tracepoint_printk_sysctl,
0daa23029   Steven Rostedt (Red Hat)   tracing: Add tp_p...
639
  	},
944ac4259   Steven Rostedt   ftrace: ftrace du...
640
  #endif
2965faa5e   Dave Young   kexec: split kexe...
641
  #ifdef CONFIG_KEXEC_CORE
7984754b9   Kees Cook   kexec: add sysctl...
642
643
644
645
646
647
648
649
650
651
652
  	{
  		.procname	= "kexec_load_disabled",
  		.data		= &kexec_load_disabled,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		/* only handle a transition from default "0" to "1" */
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &one,
  		.extra2		= &one,
  	},
  #endif
a1ef5adb4   Johannes Berg   remove CONFIG_KMO...
653
  #ifdef CONFIG_MODULES
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
654
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
655
656
657
658
  		.procname	= "modprobe",
  		.data		= &modprobe_path,
  		.maxlen		= KMOD_PATH_LEN,
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
659
  		.proc_handler	= proc_dostring,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
660
  	},
3d43321b7   Kees Cook   modules: sysctl t...
661
  	{
3d43321b7   Kees Cook   modules: sysctl t...
662
663
664
665
666
  		.procname	= "modules_disabled",
  		.data		= &modules_disabled,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		/* only handle a transition from default "0" to "1" */
6d4561110   Eric W. Biederman   sysctl: Drop & in...
667
  		.proc_handler	= proc_dointvec_minmax,
3d43321b7   Kees Cook   modules: sysctl t...
668
669
670
  		.extra1		= &one,
  		.extra2		= &one,
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
671
  #endif
86d56134f   Michael Marineau   kobject: Make sup...
672
  #ifdef CONFIG_UEVENT_HELPER
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
673
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
674
  		.procname	= "hotplug",
312c004d3   Kay Sievers   [PATCH] driver co...
675
676
  		.data		= &uevent_helper,
  		.maxlen		= UEVENT_HELPER_PATH_LEN,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
677
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
678
  		.proc_handler	= proc_dostring,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
679
  	},
86d56134f   Michael Marineau   kobject: Make sup...
680
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
681
682
  #ifdef CONFIG_CHR_DEV_SG
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
683
684
685
686
  		.procname	= "sg-big-buff",
  		.data		= &sg_big_buff,
  		.maxlen		= sizeof (int),
  		.mode		= 0444,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
687
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
688
689
690
691
  	},
  #endif
  #ifdef CONFIG_BSD_PROCESS_ACCT
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
692
693
694
695
  		.procname	= "acct",
  		.data		= &acct_parm,
  		.maxlen		= 3*sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
696
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
697
698
  	},
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
699
700
  #ifdef CONFIG_MAGIC_SYSRQ
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
701
  		.procname	= "sysrq",
5d6f647fc   Ingo Molnar   [PATCH] debug: ad...
702
  		.data		= &__sysrq_enabled,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
703
704
  		.maxlen		= sizeof (int),
  		.mode		= 0644,
97f5f0cd8   Dmitry Torokhov   Input: implement ...
705
  		.proc_handler	= sysrq_sysctl_handler,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
706
707
  	},
  #endif
d6f8ff738   Randy Dunlap   [PATCH] cad_pid s...
708
  #ifdef CONFIG_PROC_SYSCTL
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
709
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
710
  		.procname	= "cad_pid",
9ec52099e   Cedric Le Goater   [PATCH] replace c...
711
  		.data		= NULL,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
712
713
  		.maxlen		= sizeof (int),
  		.mode		= 0600,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
714
  		.proc_handler	= proc_do_cad_pid,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
715
  	},
d6f8ff738   Randy Dunlap   [PATCH] cad_pid s...
716
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
717
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
718
  		.procname	= "threads-max",
16db3d3f1   Heinrich Schuchardt   kernel/sysctl.c: ...
719
  		.data		= NULL,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
720
721
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
16db3d3f1   Heinrich Schuchardt   kernel/sysctl.c: ...
722
  		.proc_handler	= sysctl_max_threads,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
723
724
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
725
726
727
728
  		.procname	= "random",
  		.mode		= 0555,
  		.child		= random_table,
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
729
  	{
17f60a7da   Eric Paris   capabilites: allo...
730
731
732
733
734
  		.procname	= "usermodehelper",
  		.mode		= 0555,
  		.child		= usermodehelper_table,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
735
736
737
738
  		.procname	= "overflowuid",
  		.data		= &overflowuid,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
739
  		.proc_handler	= proc_dointvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
740
741
742
743
  		.extra1		= &minolduid,
  		.extra2		= &maxolduid,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
744
745
746
747
  		.procname	= "overflowgid",
  		.data		= &overflowgid,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
748
  		.proc_handler	= proc_dointvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
749
750
751
  		.extra1		= &minolduid,
  		.extra2		= &maxolduid,
  	},
347a8dc3b   Martin Schwidefsky   [PATCH] s390: cle...
752
  #ifdef CONFIG_S390
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
753
754
  #ifdef CONFIG_MATHEMU
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
755
756
757
758
  		.procname	= "ieee_emulation_warnings",
  		.data		= &sysctl_ieee_emulation_warnings,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
759
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
760
761
  	},
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
762
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
763
  		.procname	= "userprocess_debug",
ab3c68ee5   Heiko Carstens   [S390] debug: ena...
764
  		.data		= &show_unhandled_signals,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
765
766
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
767
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
768
769
770
  	},
  #endif
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
771
772
773
774
  		.procname	= "pid_max",
  		.data		= &pid_max,
  		.maxlen		= sizeof (int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
775
  		.proc_handler	= proc_dointvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
776
777
778
779
  		.extra1		= &pid_max_min,
  		.extra2		= &pid_max_max,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
780
781
782
783
  		.procname	= "panic_on_oops",
  		.data		= &panic_on_oops,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
784
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
785
  	},
7ef3d2fd1   Joe Perches   printk_ratelimit(...
786
787
  #if defined CONFIG_PRINTK
  	{
7ef3d2fd1   Joe Perches   printk_ratelimit(...
788
789
790
791
  		.procname	= "printk",
  		.data		= &console_loglevel,
  		.maxlen		= 4*sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
792
  		.proc_handler	= proc_dointvec,
7ef3d2fd1   Joe Perches   printk_ratelimit(...
793
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
794
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
795
  		.procname	= "printk_ratelimit",
717115e1a   Dave Young   printk ratelimiti...
796
  		.data		= &printk_ratelimit_state.interval,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
797
798
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
799
  		.proc_handler	= proc_dointvec_jiffies,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
800
801
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
802
  		.procname	= "printk_ratelimit_burst",
717115e1a   Dave Young   printk ratelimiti...
803
  		.data		= &printk_ratelimit_state.burst,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
804
805
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
806
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
807
  	},
af91322ef   Dave Young   printk: add print...
808
  	{
af91322ef   Dave Young   printk: add print...
809
810
811
812
  		.procname	= "printk_delay",
  		.data		= &printk_delay_msec,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
813
  		.proc_handler	= proc_dointvec_minmax,
af91322ef   Dave Young   printk: add print...
814
815
816
  		.extra1		= &zero,
  		.extra2		= &ten_thousand,
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
817
  	{
750afe7ba   Borislav Petkov   printk: add kerne...
818
819
820
821
822
823
824
  		.procname	= "printk_devkmsg",
  		.data		= devkmsg_log_str,
  		.maxlen		= DEVKMSG_STR_MAX_SIZE,
  		.mode		= 0644,
  		.proc_handler	= devkmsg_sysctl_set_loglvl,
  	},
  	{
eaf06b241   Dan Rosenberg   Restrict unprivil...
825
826
827
828
  		.procname	= "dmesg_restrict",
  		.data		= &dmesg_restrict,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
620f6e8e8   Kees Cook   sysctl: fix write...
829
  		.proc_handler	= proc_dointvec_minmax_sysadmin,
eaf06b241   Dan Rosenberg   Restrict unprivil...
830
831
832
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
455cd5ab3   Dan Rosenberg   kptr_restrict for...
833
834
835
836
837
  	{
  		.procname	= "kptr_restrict",
  		.data		= &kptr_restrict,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
620f6e8e8   Kees Cook   sysctl: fix write...
838
  		.proc_handler	= proc_dointvec_minmax_sysadmin,
455cd5ab3   Dan Rosenberg   kptr_restrict for...
839
840
841
  		.extra1		= &zero,
  		.extra2		= &two,
  	},
df6e61d4c   Joe Perches   kernel/sysctl.c: ...
842
  #endif
eaf06b241   Dan Rosenberg   Restrict unprivil...
843
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
844
845
846
847
  		.procname	= "ngroups_max",
  		.data		= &ngroups_max,
  		.maxlen		= sizeof (int),
  		.mode		= 0444,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
848
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
849
  	},
73efc0394   Dan Ballard   kernel/sysctl.c: ...
850
851
852
853
854
855
856
  	{
  		.procname	= "cap_last_cap",
  		.data		= (void *)&cap_last_cap,
  		.maxlen		= sizeof(int),
  		.mode		= 0444,
  		.proc_handler	= proc_dointvec,
  	},
58687acba   Don Zickus   lockup_detector: ...
857
  #if defined(CONFIG_LOCKUP_DETECTOR)
504d7cf10   Don Zickus   nmi_watchdog: Com...
858
  	{
58687acba   Don Zickus   lockup_detector: ...
859
  		.procname       = "watchdog",
7feeb9cd4   Thomas Gleixner   watchdog/sysctl: ...
860
861
862
  		.data		= &watchdog_user_enabled,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
195daf665   Ulrich Obergfell   watchdog: enable ...
863
  		.proc_handler   = proc_watchdog,
586692a5a   Mandeep Singh Baines   watchdog: Disable...
864
865
  		.extra1		= &zero,
  		.extra2		= &one,
58687acba   Don Zickus   lockup_detector: ...
866
867
868
  	},
  	{
  		.procname	= "watchdog_thresh",
586692a5a   Mandeep Singh Baines   watchdog: Disable...
869
  		.data		= &watchdog_thresh,
58687acba   Don Zickus   lockup_detector: ...
870
871
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
195daf665   Ulrich Obergfell   watchdog: enable ...
872
  		.proc_handler	= proc_watchdog_thresh,
a6572f84c   Li Zefan   watchdog: Disallo...
873
  		.extra1		= &zero,
58687acba   Don Zickus   lockup_detector: ...
874
  		.extra2		= &sixty,
504d7cf10   Don Zickus   nmi_watchdog: Com...
875
  	},
2508ce184   Don Zickus   lockup_detector: ...
876
  	{
195daf665   Ulrich Obergfell   watchdog: enable ...
877
  		.procname       = "nmi_watchdog",
7feeb9cd4   Thomas Gleixner   watchdog/sysctl: ...
878
879
  		.data		= &nmi_watchdog_user_enabled,
  		.maxlen		= sizeof(int),
51d4052b0   Thomas Gleixner   watchdog/sysctl: ...
880
  		.mode		= NMI_WATCHDOG_SYSCTL_PERM,
195daf665   Ulrich Obergfell   watchdog: enable ...
881
882
  		.proc_handler   = proc_nmi_watchdog,
  		.extra1		= &zero,
195daf665   Ulrich Obergfell   watchdog: enable ...
883
  		.extra2		= &one,
195daf665   Ulrich Obergfell   watchdog: enable ...
884
885
  	},
  	{
05a4a9527   Nicholas Piggin   kernel/watchdog: ...
886
887
888
889
890
891
892
893
  		.procname	= "watchdog_cpumask",
  		.data		= &watchdog_cpumask_bits,
  		.maxlen		= NR_CPUS,
  		.mode		= 0644,
  		.proc_handler	= proc_watchdog_cpumask,
  	},
  #ifdef CONFIG_SOFTLOCKUP_DETECTOR
  	{
195daf665   Ulrich Obergfell   watchdog: enable ...
894
  		.procname       = "soft_watchdog",
7feeb9cd4   Thomas Gleixner   watchdog/sysctl: ...
895
896
897
  		.data		= &soft_watchdog_user_enabled,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
195daf665   Ulrich Obergfell   watchdog: enable ...
898
899
900
901
902
  		.proc_handler   = proc_soft_watchdog,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  	{
2508ce184   Don Zickus   lockup_detector: ...
903
904
905
906
907
908
909
910
  		.procname	= "softlockup_panic",
  		.data		= &softlockup_panic,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
05a4a9527   Nicholas Piggin   kernel/watchdog: ...
911
  #ifdef CONFIG_SMP
ac1f59124   Don Zickus   kernel/watchdog.c...
912
  	{
05a4a9527   Nicholas Piggin   kernel/watchdog: ...
913
914
  		.procname	= "softlockup_all_cpu_backtrace",
  		.data		= &sysctl_softlockup_all_cpu_backtrace,
ac1f59124   Don Zickus   kernel/watchdog.c...
915
916
917
918
919
920
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
05a4a9527   Nicholas Piggin   kernel/watchdog: ...
921
  #endif /* CONFIG_SMP */
ac1f59124   Don Zickus   kernel/watchdog.c...
922
  #endif
05a4a9527   Nicholas Piggin   kernel/watchdog: ...
923
  #ifdef CONFIG_HARDLOCKUP_DETECTOR
ed235875e   Aaron Tomlin   kernel/watchdog.c...
924
  	{
05a4a9527   Nicholas Piggin   kernel/watchdog: ...
925
926
  		.procname	= "hardlockup_panic",
  		.data		= &hardlockup_panic,
ed235875e   Aaron Tomlin   kernel/watchdog.c...
927
928
929
930
931
932
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
05a4a9527   Nicholas Piggin   kernel/watchdog: ...
933
  #ifdef CONFIG_SMP
55537871e   Jiri Kosina   kernel/watchdog.c...
934
935
936
937
938
939
940
941
942
  	{
  		.procname	= "hardlockup_all_cpu_backtrace",
  		.data		= &sysctl_hardlockup_all_cpu_backtrace,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
ed235875e   Aaron Tomlin   kernel/watchdog.c...
943
  #endif /* CONFIG_SMP */
5dc305587   Don Zickus   x86, NMI: Add bac...
944
  #endif
05a4a9527   Nicholas Piggin   kernel/watchdog: ...
945
  #endif
5dc305587   Don Zickus   x86, NMI: Add bac...
946
947
948
949
950
951
952
953
  #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
  	{
  		.procname       = "unknown_nmi_panic",
  		.data           = &unknown_nmi_panic,
  		.maxlen         = sizeof (int),
  		.mode           = 0644,
  		.proc_handler   = proc_dointvec,
  	},
504d7cf10   Don Zickus   nmi_watchdog: Com...
954
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
955
956
  #if defined(CONFIG_X86)
  	{
8da5adda9   Don Zickus   [PATCH] x86: Allo...
957
958
959
960
  		.procname	= "panic_on_unrecovered_nmi",
  		.data		= &panic_on_unrecovered_nmi,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
961
  		.proc_handler	= proc_dointvec,
8da5adda9   Don Zickus   [PATCH] x86: Allo...
962
963
  	},
  	{
5211a242d   Kurt Garloff   x86: Add sysctl t...
964
965
966
967
  		.procname	= "panic_on_io_nmi",
  		.data		= &panic_on_io_nmi,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
968
  		.proc_handler	= proc_dointvec,
5211a242d   Kurt Garloff   x86: Add sysctl t...
969
  	},
55af77969   Mitsuo Hayasaka   x86: Panic on det...
970
971
972
973
974
975
976
977
978
  #ifdef CONFIG_DEBUG_STACKOVERFLOW
  	{
  		.procname	= "panic_on_stackoverflow",
  		.data		= &sysctl_panic_on_stackoverflow,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
  #endif
5211a242d   Kurt Garloff   x86: Add sysctl t...
979
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
980
981
982
983
  		.procname	= "bootloader_type",
  		.data		= &bootloader_type,
  		.maxlen		= sizeof (int),
  		.mode		= 0444,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
984
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
985
  	},
0741f4d20   Chuck Ebbert   [PATCH] x86: add ...
986
  	{
5031296c5   H. Peter Anvin   x86: add extensio...
987
988
989
990
  		.procname	= "bootloader_version",
  		.data		= &bootloader_version,
  		.maxlen		= sizeof (int),
  		.mode		= 0444,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
991
  		.proc_handler	= proc_dointvec,
5031296c5   H. Peter Anvin   x86: add extensio...
992
993
  	},
  	{
6e7c40259   Ingo Molnar   x86: various chan...
994
995
996
997
  		.procname	= "io_delay_type",
  		.data		= &io_delay_type,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
998
  		.proc_handler	= proc_dointvec,
6e7c40259   Ingo Molnar   x86: various chan...
999
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1000
  #endif
7a9166e3b   Luke Yang   [PATCH] Fix undef...
1001
  #if defined(CONFIG_MMU)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1002
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1003
1004
1005
1006
  		.procname	= "randomize_va_space",
  		.data		= &randomize_va_space,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1007
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1008
  	},
7a9166e3b   Luke Yang   [PATCH] Fix undef...
1009
  #endif
0152fb376   Martin Schwidefsky   [PATCH] s390: spi...
1010
  #if defined(CONFIG_S390) && defined(CONFIG_SMP)
951f22d5b   Martin Schwidefsky   [PATCH] s390: spi...
1011
  	{
951f22d5b   Martin Schwidefsky   [PATCH] s390: spi...
1012
1013
1014
1015
  		.procname	= "spin_retry",
  		.data		= &spin_retry,
  		.maxlen		= sizeof (int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1016
  		.proc_handler	= proc_dointvec,
951f22d5b   Martin Schwidefsky   [PATCH] s390: spi...
1017
1018
  	},
  #endif
673d5b43d   Len Brown   ACPI: restore CON...
1019
  #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
c255d844d   Pavel Machek   [PATCH] suspend-t...
1020
  	{
c255d844d   Pavel Machek   [PATCH] suspend-t...
1021
  		.procname	= "acpi_video_flags",
77afcf78a   Pavel Machek   PM: Integrate bee...
1022
  		.data		= &acpi_realmode_flags,
c255d844d   Pavel Machek   [PATCH] suspend-t...
1023
1024
  		.maxlen		= sizeof (unsigned long),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1025
  		.proc_handler	= proc_doulongvec_minmax,
c255d844d   Pavel Machek   [PATCH] suspend-t...
1026
1027
  	},
  #endif
b6fca7253   Vineet Gupta   sysctl: Enable IA...
1028
  #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
d2b176ed8   Jes Sorensen   [IA64] sysctl opt...
1029
  	{
d2b176ed8   Jes Sorensen   [IA64] sysctl opt...
1030
1031
1032
1033
  		.procname	= "ignore-unaligned-usertrap",
  		.data		= &no_unaligned_warning,
  		.maxlen		= sizeof (int),
  	 	.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1034
  		.proc_handler	= proc_dointvec,
d2b176ed8   Jes Sorensen   [IA64] sysctl opt...
1035
  	},
b6fca7253   Vineet Gupta   sysctl: Enable IA...
1036
1037
  #endif
  #ifdef CONFIG_IA64
88fc241f5   Doug Chapman   [IA64] dump stack...
1038
  	{
88fc241f5   Doug Chapman   [IA64] dump stack...
1039
1040
1041
1042
  		.procname	= "unaligned-dump-stack",
  		.data		= &unaligned_dump_stack,
  		.maxlen		= sizeof (int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1043
  		.proc_handler	= proc_dointvec,
88fc241f5   Doug Chapman   [IA64] dump stack...
1044
  	},
d2b176ed8   Jes Sorensen   [IA64] sysctl opt...
1045
  #endif
e162b39a3   Mandeep Singh Baines   softlockup: decou...
1046
1047
  #ifdef CONFIG_DETECT_HUNG_TASK
  	{
e162b39a3   Mandeep Singh Baines   softlockup: decou...
1048
1049
1050
1051
  		.procname	= "hung_task_panic",
  		.data		= &sysctl_hung_task_panic,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1052
  		.proc_handler	= proc_dointvec_minmax,
e162b39a3   Mandeep Singh Baines   softlockup: decou...
1053
1054
1055
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
82a1fcb90   Ingo Molnar   softlockup: autom...
1056
  	{
82a1fcb90   Ingo Molnar   softlockup: autom...
1057
1058
  		.procname	= "hung_task_check_count",
  		.data		= &sysctl_hung_task_check_count,
cd64647f0   Li Zefan   hung_task: Change...
1059
  		.maxlen		= sizeof(int),
82a1fcb90   Ingo Molnar   softlockup: autom...
1060
  		.mode		= 0644,
cd64647f0   Li Zefan   hung_task: Change...
1061
1062
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
82a1fcb90   Ingo Molnar   softlockup: autom...
1063
1064
  	},
  	{
82a1fcb90   Ingo Molnar   softlockup: autom...
1065
1066
  		.procname	= "hung_task_timeout_secs",
  		.data		= &sysctl_hung_task_timeout_secs,
90739081e   Ingo Molnar   softlockup: fix s...
1067
  		.maxlen		= sizeof(unsigned long),
82a1fcb90   Ingo Molnar   softlockup: autom...
1068
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1069
  		.proc_handler	= proc_dohung_task_timeout_secs,
80df28476   Liu Hua   hung_task: check ...
1070
  		.extra2		= &hung_task_timeout_max,
82a1fcb90   Ingo Molnar   softlockup: autom...
1071
1072
  	},
  	{
82a1fcb90   Ingo Molnar   softlockup: autom...
1073
1074
  		.procname	= "hung_task_warnings",
  		.data		= &sysctl_hung_task_warnings,
270750dbc   Aaron Tomlin   hung_task: Displa...
1075
  		.maxlen		= sizeof(int),
82a1fcb90   Ingo Molnar   softlockup: autom...
1076
  		.mode		= 0644,
270750dbc   Aaron Tomlin   hung_task: Displa...
1077
1078
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &neg_one,
82a1fcb90   Ingo Molnar   softlockup: autom...
1079
  	},
c4f3b63fe   Ravikiran G Thirumalai   softlockup: add a...
1080
  #endif
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
1081
1082
  #ifdef CONFIG_RT_MUTEXES
  	{
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
1083
1084
1085
1086
  		.procname	= "max_lock_depth",
  		.data		= &max_lock_depth,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1087
  		.proc_handler	= proc_dointvec,
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
1088
1089
  	},
  #endif
10a0a8d4e   Jeremy Fitzhardinge   Add common orderl...
1090
  	{
10a0a8d4e   Jeremy Fitzhardinge   Add common orderl...
1091
1092
1093
1094
  		.procname	= "poweroff_cmd",
  		.data		= &poweroff_cmd,
  		.maxlen		= POWEROFF_CMD_PATH_LEN,
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1095
  		.proc_handler	= proc_dostring,
10a0a8d4e   Jeremy Fitzhardinge   Add common orderl...
1096
  	},
0b77f5bfb   David Howells   keys: make the ke...
1097
1098
  #ifdef CONFIG_KEYS
  	{
0b77f5bfb   David Howells   keys: make the ke...
1099
1100
1101
1102
1103
  		.procname	= "keys",
  		.mode		= 0555,
  		.child		= key_sysctls,
  	},
  #endif
cdd6c482c   Ingo Molnar   perf: Do the big ...
1104
  #ifdef CONFIG_PERF_EVENTS
aa4a22187   Vince Weaver   perf: Comment /pr...
1105
1106
1107
1108
1109
1110
  	/*
  	 * User-space scripts rely on the existence of this file
  	 * as a feature check for perf_events being enabled.
  	 *
  	 * So it's an ABI, do not remove!
  	 */
1ccd15497   Peter Zijlstra   perf_counter: sys...
1111
  	{
cdd6c482c   Ingo Molnar   perf: Do the big ...
1112
1113
1114
  		.procname	= "perf_event_paranoid",
  		.data		= &sysctl_perf_event_paranoid,
  		.maxlen		= sizeof(sysctl_perf_event_paranoid),
1ccd15497   Peter Zijlstra   perf_counter: sys...
1115
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1116
  		.proc_handler	= proc_dointvec,
1ccd15497   Peter Zijlstra   perf_counter: sys...
1117
  	},
c5078f78b   Peter Zijlstra   perf_counter: pro...
1118
  	{
cdd6c482c   Ingo Molnar   perf: Do the big ...
1119
1120
1121
  		.procname	= "perf_event_mlock_kb",
  		.data		= &sysctl_perf_event_mlock,
  		.maxlen		= sizeof(sysctl_perf_event_mlock),
c5078f78b   Peter Zijlstra   perf_counter: pro...
1122
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1123
  		.proc_handler	= proc_dointvec,
c5078f78b   Peter Zijlstra   perf_counter: pro...
1124
  	},
a78ac3258   Peter Zijlstra   perf_counter: Gen...
1125
  	{
cdd6c482c   Ingo Molnar   perf: Do the big ...
1126
1127
1128
  		.procname	= "perf_event_max_sample_rate",
  		.data		= &sysctl_perf_event_sample_rate,
  		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
a78ac3258   Peter Zijlstra   perf_counter: Gen...
1129
  		.mode		= 0644,
163ec4354   Peter Zijlstra   perf: Optimize th...
1130
  		.proc_handler	= perf_proc_update_handler,
723478c8a   Knut Petersen   perf: Enforce 1 a...
1131
  		.extra1		= &one,
a78ac3258   Peter Zijlstra   perf_counter: Gen...
1132
  	},
14c63f17b   Dave Hansen   perf: Drop sample...
1133
1134
1135
1136
1137
1138
1139
1140
1141
  	{
  		.procname	= "perf_cpu_time_max_percent",
  		.data		= &sysctl_perf_cpu_time_max_percent,
  		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
  		.mode		= 0644,
  		.proc_handler	= perf_cpu_time_max_percent_handler,
  		.extra1		= &zero,
  		.extra2		= &one_hundred,
  	},
c5dfd78eb   Arnaldo Carvalho de Melo   perf core: Allow ...
1142
1143
  	{
  		.procname	= "perf_event_max_stack",
a831100ae   Arnaldo Carvalho de Melo   perf core: Genera...
1144
  		.data		= &sysctl_perf_event_max_stack,
c5dfd78eb   Arnaldo Carvalho de Melo   perf core: Allow ...
1145
1146
1147
1148
1149
1150
  		.maxlen		= sizeof(sysctl_perf_event_max_stack),
  		.mode		= 0644,
  		.proc_handler	= perf_event_max_stack_handler,
  		.extra1		= &zero,
  		.extra2		= &six_hundred_forty_kb,
  	},
c85b03349   Arnaldo Carvalho de Melo   perf core: Separa...
1151
1152
1153
1154
1155
1156
1157
1158
1159
  	{
  		.procname	= "perf_event_max_contexts_per_stack",
  		.data		= &sysctl_perf_event_max_contexts_per_stack,
  		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
  		.mode		= 0644,
  		.proc_handler	= perf_event_max_stack_handler,
  		.extra1		= &zero,
  		.extra2		= &one_thousand,
  	},
1ccd15497   Peter Zijlstra   perf_counter: sys...
1160
  #endif
9e3961a09   Prarit Bhargava   kernel: add panic...
1161
1162
1163
1164
1165
1166
1167
1168
1169
  	{
  		.procname	= "panic_on_warn",
  		.data		= &panic_on_warn,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
bc7a34b8b   Thomas Gleixner   timer: Reduce tim...
1170
1171
1172
1173
1174
1175
1176
  #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
  	{
  		.procname	= "timer_migration",
  		.data		= &sysctl_timer_migration,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
  		.proc_handler	= timer_migration_handler,
b94bf594c   Myungho Jung   timer/sysclt: Res...
1177
1178
  		.extra1		= &zero,
  		.extra2		= &one,
bc7a34b8b   Thomas Gleixner   timer: Reduce tim...
1179
1180
  	},
  #endif
1be7f75d1   Alexei Starovoitov   bpf: enable non-r...
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
  #ifdef CONFIG_BPF_SYSCALL
  	{
  		.procname	= "unprivileged_bpf_disabled",
  		.data		= &sysctl_unprivileged_bpf_disabled,
  		.maxlen		= sizeof(sysctl_unprivileged_bpf_disabled),
  		.mode		= 0644,
  		/* only handle a transition from default "0" to "1" */
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &one,
  		.extra2		= &one,
  	},
  #endif
088e9d253   Daniel Bristot de Oliveira   rcu: sysctl: Pani...
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
  #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
  	{
  		.procname	= "panic_on_rcu_stall",
  		.data		= &sysctl_panic_on_rcu_stall,
  		.maxlen		= sizeof(sysctl_panic_on_rcu_stall),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  #endif
6fce56ec9   Eric W. Biederman   sysctl: Remove re...
1204
  	{ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1205
  };
d8217f076   Eric W. Biederman   sysctl core: Stop...
1206
  static struct ctl_table vm_table[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1207
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1208
1209
1210
1211
  		.procname	= "overcommit_memory",
  		.data		= &sysctl_overcommit_memory,
  		.maxlen		= sizeof(sysctl_overcommit_memory),
  		.mode		= 0644,
cb16e95fa   Petr Holasek   sysctl: add some ...
1212
1213
1214
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &two,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1215
1216
  	},
  	{
fadd8fbd1   KAMEZAWA Hiroyuki   [PATCH] support f...
1217
1218
1219
1220
  		.procname	= "panic_on_oom",
  		.data		= &sysctl_panic_on_oom,
  		.maxlen		= sizeof(sysctl_panic_on_oom),
  		.mode		= 0644,
cb16e95fa   Petr Holasek   sysctl: add some ...
1221
1222
1223
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &two,
fadd8fbd1   KAMEZAWA Hiroyuki   [PATCH] support f...
1224
1225
  	},
  	{
fe071d7e8   David Rientjes   oom: add oom_kill...
1226
1227
1228
1229
  		.procname	= "oom_kill_allocating_task",
  		.data		= &sysctl_oom_kill_allocating_task,
  		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1230
  		.proc_handler	= proc_dointvec,
fe071d7e8   David Rientjes   oom: add oom_kill...
1231
1232
  	},
  	{
fef1bdd68   David Rientjes   oom: add sysctl t...
1233
1234
1235
1236
  		.procname	= "oom_dump_tasks",
  		.data		= &sysctl_oom_dump_tasks,
  		.maxlen		= sizeof(sysctl_oom_dump_tasks),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1237
  		.proc_handler	= proc_dointvec,
fef1bdd68   David Rientjes   oom: add sysctl t...
1238
1239
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1240
1241
1242
1243
  		.procname	= "overcommit_ratio",
  		.data		= &sysctl_overcommit_ratio,
  		.maxlen		= sizeof(sysctl_overcommit_ratio),
  		.mode		= 0644,
49f0ce5f9   Jerome Marchand   mm: add overcommi...
1244
1245
1246
1247
1248
1249
1250
1251
  		.proc_handler	= overcommit_ratio_handler,
  	},
  	{
  		.procname	= "overcommit_kbytes",
  		.data		= &sysctl_overcommit_kbytes,
  		.maxlen		= sizeof(sysctl_overcommit_kbytes),
  		.mode		= 0644,
  		.proc_handler	= overcommit_kbytes_handler,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1252
1253
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1254
1255
1256
1257
  		.procname	= "page-cluster", 
  		.data		= &page_cluster,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
cb16e95fa   Petr Holasek   sysctl: add some ...
1258
1259
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1260
1261
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1262
1263
1264
1265
  		.procname	= "dirty_background_ratio",
  		.data		= &dirty_background_ratio,
  		.maxlen		= sizeof(dirty_background_ratio),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1266
  		.proc_handler	= dirty_background_ratio_handler,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1267
1268
1269
1270
  		.extra1		= &zero,
  		.extra2		= &one_hundred,
  	},
  	{
2da02997e   David Rientjes   mm: add dirty_bac...
1271
1272
1273
1274
  		.procname	= "dirty_background_bytes",
  		.data		= &dirty_background_bytes,
  		.maxlen		= sizeof(dirty_background_bytes),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1275
  		.proc_handler	= dirty_background_bytes_handler,
fc3501d41   Sven Wegener   mm: fix dirty_byt...
1276
  		.extra1		= &one_ul,
2da02997e   David Rientjes   mm: add dirty_bac...
1277
1278
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1279
1280
1281
1282
  		.procname	= "dirty_ratio",
  		.data		= &vm_dirty_ratio,
  		.maxlen		= sizeof(vm_dirty_ratio),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1283
  		.proc_handler	= dirty_ratio_handler,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1284
1285
1286
1287
  		.extra1		= &zero,
  		.extra2		= &one_hundred,
  	},
  	{
2da02997e   David Rientjes   mm: add dirty_bac...
1288
1289
1290
1291
  		.procname	= "dirty_bytes",
  		.data		= &vm_dirty_bytes,
  		.maxlen		= sizeof(vm_dirty_bytes),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1292
  		.proc_handler	= dirty_bytes_handler,
9e4a5bda8   Andrea Righi   mm: prevent divid...
1293
  		.extra1		= &dirty_bytes_min,
2da02997e   David Rientjes   mm: add dirty_bac...
1294
1295
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1296
  		.procname	= "dirty_writeback_centisecs",
f6ef94381   Bart Samwel   [PATCH] Represent...
1297
1298
  		.data		= &dirty_writeback_interval,
  		.maxlen		= sizeof(dirty_writeback_interval),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1299
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1300
  		.proc_handler	= dirty_writeback_centisecs_handler,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1301
1302
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1303
  		.procname	= "dirty_expire_centisecs",
f6ef94381   Bart Samwel   [PATCH] Represent...
1304
1305
  		.data		= &dirty_expire_interval,
  		.maxlen		= sizeof(dirty_expire_interval),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1306
  		.mode		= 0644,
cb16e95fa   Petr Holasek   sysctl: add some ...
1307
1308
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1309
1310
  	},
  	{
1efff914a   Theodore Ts'o   fs: add dirtytime...
1311
1312
1313
1314
1315
1316
1317
1318
  		.procname	= "dirtytime_expire_seconds",
  		.data		= &dirtytime_expire_interval,
  		.maxlen		= sizeof(dirty_expire_interval),
  		.mode		= 0644,
  		.proc_handler	= dirtytime_interval_handler,
  		.extra1		= &zero,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1319
1320
1321
1322
  		.procname	= "swappiness",
  		.data		= &vm_swappiness,
  		.maxlen		= sizeof(vm_swappiness),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1323
  		.proc_handler	= proc_dointvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1324
1325
1326
1327
  		.extra1		= &zero,
  		.extra2		= &one_hundred,
  	},
  #ifdef CONFIG_HUGETLB_PAGE
06808b082   Lee Schermerhorn   hugetlb: derive h...
1328
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1329
  		.procname	= "nr_hugepages",
e5ff21594   Andi Kleen   hugetlb: multiple...
1330
  		.data		= NULL,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1331
1332
  		.maxlen		= sizeof(unsigned long),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1333
  		.proc_handler	= hugetlb_sysctl_handler,
06808b082   Lee Schermerhorn   hugetlb: derive h...
1334
1335
1336
1337
1338
1339
1340
1341
  	},
  #ifdef CONFIG_NUMA
  	{
  		.procname       = "nr_hugepages_mempolicy",
  		.data           = NULL,
  		.maxlen         = sizeof(unsigned long),
  		.mode           = 0644,
  		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
06808b082   Lee Schermerhorn   hugetlb: derive h...
1342
  	},
4518085e1   Kemi Wang   mm, sysctl: make ...
1343
1344
1345
1346
1347
1348
1349
1350
1351
  	{
  		.procname		= "numa_stat",
  		.data			= &sysctl_vm_numa_stat,
  		.maxlen			= sizeof(int),
  		.mode			= 0644,
  		.proc_handler	= sysctl_vm_numa_stat_handler,
  		.extra1			= &zero,
  		.extra2			= &one,
  	},
06808b082   Lee Schermerhorn   hugetlb: derive h...
1352
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1353
  	 {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1354
1355
1356
1357
  		.procname	= "hugetlb_shm_group",
  		.data		= &sysctl_hugetlb_shm_group,
  		.maxlen		= sizeof(gid_t),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1358
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1359
  	 },
396faf030   Mel Gorman   Allow huge page a...
1360
  	 {
396faf030   Mel Gorman   Allow huge page a...
1361
1362
1363
1364
  		.procname	= "hugepages_treat_as_movable",
  		.data		= &hugepages_treat_as_movable,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
86cdb465c   Naoya Horiguchi   mm: prepare to re...
1365
  		.proc_handler	= proc_dointvec,
396faf030   Mel Gorman   Allow huge page a...
1366
  	},
54f9f80d6   Adam Litke   hugetlb: Add huge...
1367
  	{
d1c3fb1f8   Nishanth Aravamudan   hugetlb: introduc...
1368
  		.procname	= "nr_overcommit_hugepages",
e5ff21594   Andi Kleen   hugetlb: multiple...
1369
1370
  		.data		= NULL,
  		.maxlen		= sizeof(unsigned long),
d1c3fb1f8   Nishanth Aravamudan   hugetlb: introduc...
1371
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1372
  		.proc_handler	= hugetlb_overcommit_handler,
d1c3fb1f8   Nishanth Aravamudan   hugetlb: introduc...
1373
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1374
1375
  #endif
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1376
1377
1378
1379
  		.procname	= "lowmem_reserve_ratio",
  		.data		= &sysctl_lowmem_reserve_ratio,
  		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1380
  		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1381
1382
  	},
  	{
9d0243bca   Andrew Morton   [PATCH] drop-page...
1383
1384
1385
1386
1387
  		.procname	= "drop_caches",
  		.data		= &sysctl_drop_caches,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= drop_caches_sysctl_handler,
cb16e95fa   Petr Holasek   sysctl: add some ...
1388
  		.extra1		= &one,
5509a5d27   Dave Hansen   drop_caches: add ...
1389
  		.extra2		= &four,
9d0243bca   Andrew Morton   [PATCH] drop-page...
1390
  	},
76ab0f530   Mel Gorman   mm: compaction: a...
1391
1392
1393
1394
1395
1396
1397
1398
  #ifdef CONFIG_COMPACTION
  	{
  		.procname	= "compact_memory",
  		.data		= &sysctl_compact_memory,
  		.maxlen		= sizeof(int),
  		.mode		= 0200,
  		.proc_handler	= sysctl_compaction_handler,
  	},
5e7719058   Mel Gorman   mm: compaction: a...
1399
1400
1401
1402
1403
1404
1405
1406
1407
  	{
  		.procname	= "extfrag_threshold",
  		.data		= &sysctl_extfrag_threshold,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= sysctl_extfrag_handler,
  		.extra1		= &min_extfrag_threshold,
  		.extra2		= &max_extfrag_threshold,
  	},
5bbe3547a   Eric B Munson   mm: allow compact...
1408
1409
1410
1411
1412
1413
1414
1415
1416
  	{
  		.procname	= "compact_unevictable_allowed",
  		.data		= &sysctl_compact_unevictable_allowed,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
5e7719058   Mel Gorman   mm: compaction: a...
1417

76ab0f530   Mel Gorman   mm: compaction: a...
1418
  #endif /* CONFIG_COMPACTION */
9d0243bca   Andrew Morton   [PATCH] drop-page...
1419
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1420
1421
1422
1423
  		.procname	= "min_free_kbytes",
  		.data		= &min_free_kbytes,
  		.maxlen		= sizeof(min_free_kbytes),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1424
  		.proc_handler	= min_free_kbytes_sysctl_handler,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1425
1426
  		.extra1		= &zero,
  	},
8ad4b1fb8   Rohit Seth   [PATCH] Make high...
1427
  	{
795ae7a0d   Johannes Weiner   mm: scale kswapd ...
1428
1429
1430
1431
1432
1433
1434
1435
1436
  		.procname	= "watermark_scale_factor",
  		.data		= &watermark_scale_factor,
  		.maxlen		= sizeof(watermark_scale_factor),
  		.mode		= 0644,
  		.proc_handler	= watermark_scale_factor_sysctl_handler,
  		.extra1		= &one,
  		.extra2		= &one_thousand,
  	},
  	{
8ad4b1fb8   Rohit Seth   [PATCH] Make high...
1437
1438
1439
1440
  		.procname	= "percpu_pagelist_fraction",
  		.data		= &percpu_pagelist_fraction,
  		.maxlen		= sizeof(percpu_pagelist_fraction),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1441
  		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
7cd2b0a34   David Rientjes   mm, pcp: allow re...
1442
  		.extra1		= &zero,
8ad4b1fb8   Rohit Seth   [PATCH] Make high...
1443
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1444
1445
  #ifdef CONFIG_MMU
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1446
1447
1448
1449
  		.procname	= "max_map_count",
  		.data		= &sysctl_max_map_count,
  		.maxlen		= sizeof(sysctl_max_map_count),
  		.mode		= 0644,
3e26120cc   WANG Cong   kernel/sysctl.c: ...
1450
  		.proc_handler	= proc_dointvec_minmax,
70da2340f   Amerigo Wang   'sysctl_max_map_c...
1451
  		.extra1		= &zero,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1452
  	},
dd8632a12   Paul Mundt   NOMMU: Make mmap ...
1453
1454
  #else
  	{
dd8632a12   Paul Mundt   NOMMU: Make mmap ...
1455
1456
1457
1458
  		.procname	= "nr_trim_pages",
  		.data		= &sysctl_nr_trim_pages,
  		.maxlen		= sizeof(sysctl_nr_trim_pages),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1459
  		.proc_handler	= proc_dointvec_minmax,
dd8632a12   Paul Mundt   NOMMU: Make mmap ...
1460
1461
  		.extra1		= &zero,
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1462
1463
  #endif
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1464
1465
1466
1467
  		.procname	= "laptop_mode",
  		.data		= &laptop_mode,
  		.maxlen		= sizeof(laptop_mode),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1468
  		.proc_handler	= proc_dointvec_jiffies,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1469
1470
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1471
1472
1473
1474
  		.procname	= "block_dump",
  		.data		= &block_dump,
  		.maxlen		= sizeof(block_dump),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1475
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1476
1477
1478
  		.extra1		= &zero,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1479
1480
1481
1482
  		.procname	= "vfs_cache_pressure",
  		.data		= &sysctl_vfs_cache_pressure,
  		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1483
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1484
1485
1486
1487
  		.extra1		= &zero,
  	},
  #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1488
1489
1490
1491
  		.procname	= "legacy_va_layout",
  		.data		= &sysctl_legacy_va_layout,
  		.maxlen		= sizeof(sysctl_legacy_va_layout),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1492
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1493
1494
1495
  		.extra1		= &zero,
  	},
  #endif
1743660b9   Christoph Lameter   [PATCH] Zone recl...
1496
1497
  #ifdef CONFIG_NUMA
  	{
1743660b9   Christoph Lameter   [PATCH] Zone recl...
1498
  		.procname	= "zone_reclaim_mode",
a5f5f91da   Mel Gorman   mm: convert zone_...
1499
1500
  		.data		= &node_reclaim_mode,
  		.maxlen		= sizeof(node_reclaim_mode),
1743660b9   Christoph Lameter   [PATCH] Zone recl...
1501
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1502
  		.proc_handler	= proc_dointvec,
c84db23c6   Christoph Lameter   [PATCH] zone_recl...
1503
  		.extra1		= &zero,
1743660b9   Christoph Lameter   [PATCH] Zone recl...
1504
  	},
9614634fe   Christoph Lameter   [PATCH] ZVC/zone_...
1505
  	{
9614634fe   Christoph Lameter   [PATCH] ZVC/zone_...
1506
1507
1508
1509
  		.procname	= "min_unmapped_ratio",
  		.data		= &sysctl_min_unmapped_ratio,
  		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1510
  		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
9614634fe   Christoph Lameter   [PATCH] ZVC/zone_...
1511
1512
1513
  		.extra1		= &zero,
  		.extra2		= &one_hundred,
  	},
0ff38490c   Christoph Lameter   [PATCH] zone_recl...
1514
  	{
0ff38490c   Christoph Lameter   [PATCH] zone_recl...
1515
1516
1517
1518
  		.procname	= "min_slab_ratio",
  		.data		= &sysctl_min_slab_ratio,
  		.maxlen		= sizeof(sysctl_min_slab_ratio),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1519
  		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
0ff38490c   Christoph Lameter   [PATCH] zone_recl...
1520
1521
1522
  		.extra1		= &zero,
  		.extra2		= &one_hundred,
  	},
1743660b9   Christoph Lameter   [PATCH] Zone recl...
1523
  #endif
77461ab33   Christoph Lameter   Make vm statistic...
1524
1525
  #ifdef CONFIG_SMP
  	{
77461ab33   Christoph Lameter   Make vm statistic...
1526
1527
1528
1529
  		.procname	= "stat_interval",
  		.data		= &sysctl_stat_interval,
  		.maxlen		= sizeof(sysctl_stat_interval),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1530
  		.proc_handler	= proc_dointvec_jiffies,
77461ab33   Christoph Lameter   Make vm statistic...
1531
  	},
52b6f46bc   Hugh Dickins   mm: /proc/sys/vm/...
1532
1533
1534
1535
1536
1537
1538
  	{
  		.procname	= "stat_refresh",
  		.data		= NULL,
  		.maxlen		= 0,
  		.mode		= 0600,
  		.proc_handler	= vmstat_refresh,
  	},
77461ab33   Christoph Lameter   Make vm statistic...
1539
  #endif
6e1415467   David Howells   NOMMU: Optimise a...
1540
  #ifdef CONFIG_MMU
ed0321895   Eric Paris   security: Protect...
1541
  	{
ed0321895   Eric Paris   security: Protect...
1542
  		.procname	= "mmap_min_addr",
788084aba   Eric Paris   Security/SELinux:...
1543
1544
  		.data		= &dac_mmap_min_addr,
  		.maxlen		= sizeof(unsigned long),
ed0321895   Eric Paris   security: Protect...
1545
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1546
  		.proc_handler	= mmap_min_addr_handler,
ed0321895   Eric Paris   security: Protect...
1547
  	},
6e1415467   David Howells   NOMMU: Optimise a...
1548
  #endif
f0c0b2b80   KAMEZAWA Hiroyuki   change zonelist o...
1549
1550
  #ifdef CONFIG_NUMA
  	{
f0c0b2b80   KAMEZAWA Hiroyuki   change zonelist o...
1551
1552
1553
1554
  		.procname	= "numa_zonelist_order",
  		.data		= &numa_zonelist_order,
  		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1555
  		.proc_handler	= numa_zonelist_order_handler,
f0c0b2b80   KAMEZAWA Hiroyuki   change zonelist o...
1556
1557
  	},
  #endif
2b8232ce5   Al Viro   minimal build fix...
1558
  #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
5c36e6578   Paul Mundt   sysctl: Support v...
1559
     (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
e6e5494cb   Ingo Molnar   [PATCH] vdso: ran...
1560
  	{
e6e5494cb   Ingo Molnar   [PATCH] vdso: ran...
1561
  		.procname	= "vdso_enabled",
3d7ee969b   Andy Lutomirski   x86, vdso: Clean ...
1562
1563
1564
1565
  #ifdef CONFIG_X86_32
  		.data		= &vdso32_enabled,
  		.maxlen		= sizeof(vdso32_enabled),
  #else
e6e5494cb   Ingo Molnar   [PATCH] vdso: ran...
1566
1567
  		.data		= &vdso_enabled,
  		.maxlen		= sizeof(vdso_enabled),
3d7ee969b   Andy Lutomirski   x86, vdso: Clean ...
1568
  #endif
e6e5494cb   Ingo Molnar   [PATCH] vdso: ran...
1569
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1570
  		.proc_handler	= proc_dointvec,
e6e5494cb   Ingo Molnar   [PATCH] vdso: ran...
1571
1572
1573
  		.extra1		= &zero,
  	},
  #endif
195cf453d   Bron Gondwana   mm/page-writeback...
1574
1575
  #ifdef CONFIG_HIGHMEM
  	{
195cf453d   Bron Gondwana   mm/page-writeback...
1576
1577
1578
1579
  		.procname	= "highmem_is_dirtyable",
  		.data		= &vm_highmem_is_dirtyable,
  		.maxlen		= sizeof(vm_highmem_is_dirtyable),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1580
  		.proc_handler	= proc_dointvec_minmax,
195cf453d   Bron Gondwana   mm/page-writeback...
1581
1582
1583
1584
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  #endif
6a46079cf   Andi Kleen   HWPOISON: The hig...
1585
1586
  #ifdef CONFIG_MEMORY_FAILURE
  	{
6a46079cf   Andi Kleen   HWPOISON: The hig...
1587
1588
1589
1590
  		.procname	= "memory_failure_early_kill",
  		.data		= &sysctl_memory_failure_early_kill,
  		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1591
  		.proc_handler	= proc_dointvec_minmax,
6a46079cf   Andi Kleen   HWPOISON: The hig...
1592
1593
1594
1595
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  	{
6a46079cf   Andi Kleen   HWPOISON: The hig...
1596
1597
1598
1599
  		.procname	= "memory_failure_recovery",
  		.data		= &sysctl_memory_failure_recovery,
  		.maxlen		= sizeof(sysctl_memory_failure_recovery),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1600
  		.proc_handler	= proc_dointvec_minmax,
6a46079cf   Andi Kleen   HWPOISON: The hig...
1601
1602
1603
1604
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  #endif
c9b1d0981   Andrew Shewmaker   mm: limit growth ...
1605
1606
1607
1608
1609
1610
1611
  	{
  		.procname	= "user_reserve_kbytes",
  		.data		= &sysctl_user_reserve_kbytes,
  		.maxlen		= sizeof(sysctl_user_reserve_kbytes),
  		.mode		= 0644,
  		.proc_handler	= proc_doulongvec_minmax,
  	},
4eeab4f55   Andrew Shewmaker   mm: replace hardc...
1612
1613
1614
1615
1616
1617
1618
  	{
  		.procname	= "admin_reserve_kbytes",
  		.data		= &sysctl_admin_reserve_kbytes,
  		.maxlen		= sizeof(sysctl_admin_reserve_kbytes),
  		.mode		= 0644,
  		.proc_handler	= proc_doulongvec_minmax,
  	},
d07e22597   Daniel Cashman   mm: mmap: add new...
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
  #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
  	{
  		.procname	= "mmap_rnd_bits",
  		.data		= &mmap_rnd_bits,
  		.maxlen		= sizeof(mmap_rnd_bits),
  		.mode		= 0600,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= (void *)&mmap_rnd_bits_min,
  		.extra2		= (void *)&mmap_rnd_bits_max,
  	},
  #endif
  #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
  	{
  		.procname	= "mmap_rnd_compat_bits",
  		.data		= &mmap_rnd_compat_bits,
  		.maxlen		= sizeof(mmap_rnd_compat_bits),
  		.mode		= 0600,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= (void *)&mmap_rnd_compat_bits_min,
  		.extra2		= (void *)&mmap_rnd_compat_bits_max,
  	},
  #endif
6fce56ec9   Eric W. Biederman   sysctl: Remove re...
1641
  	{ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1642
  };
d8217f076   Eric W. Biederman   sysctl core: Stop...
1643
  static struct ctl_table fs_table[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1644
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1645
1646
  		.procname	= "inode-nr",
  		.data		= &inodes_stat,
3942c07cc   Glauber Costa   fs: bump inode an...
1647
  		.maxlen		= 2*sizeof(long),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1648
  		.mode		= 0444,
cffbc8aa3   Dave Chinner   fs: Convert nr_in...
1649
  		.proc_handler	= proc_nr_inodes,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1650
1651
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1652
1653
  		.procname	= "inode-state",
  		.data		= &inodes_stat,
3942c07cc   Glauber Costa   fs: bump inode an...
1654
  		.maxlen		= 7*sizeof(long),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1655
  		.mode		= 0444,
cffbc8aa3   Dave Chinner   fs: Convert nr_in...
1656
  		.proc_handler	= proc_nr_inodes,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1657
1658
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1659
1660
  		.procname	= "file-nr",
  		.data		= &files_stat,
518de9b39   Eric Dumazet   fs: allow for mor...
1661
  		.maxlen		= sizeof(files_stat),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1662
  		.mode		= 0444,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1663
  		.proc_handler	= proc_nr_files,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1664
1665
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1666
1667
  		.procname	= "file-max",
  		.data		= &files_stat.max_files,
518de9b39   Eric Dumazet   fs: allow for mor...
1668
  		.maxlen		= sizeof(files_stat.max_files),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1669
  		.mode		= 0644,
518de9b39   Eric Dumazet   fs: allow for mor...
1670
  		.proc_handler	= proc_doulongvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1671
1672
  	},
  	{
9cfe015aa   Eric Dumazet   get rid of NR_OPE...
1673
1674
  		.procname	= "nr_open",
  		.data		= &sysctl_nr_open,
9b80a184e   Alexey Dobriyan   fs/file: more uns...
1675
  		.maxlen		= sizeof(unsigned int),
9cfe015aa   Eric Dumazet   get rid of NR_OPE...
1676
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1677
  		.proc_handler	= proc_dointvec_minmax,
eceea0b3d   Al Viro   [PATCH] avoid mul...
1678
1679
  		.extra1		= &sysctl_nr_open_min,
  		.extra2		= &sysctl_nr_open_max,
9cfe015aa   Eric Dumazet   get rid of NR_OPE...
1680
1681
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1682
1683
  		.procname	= "dentry-state",
  		.data		= &dentry_stat,
3942c07cc   Glauber Costa   fs: bump inode an...
1684
  		.maxlen		= 6*sizeof(long),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1685
  		.mode		= 0444,
312d3ca85   Christoph Hellwig   fs: use percpu co...
1686
  		.proc_handler	= proc_nr_dentry,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1687
1688
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1689
1690
1691
1692
  		.procname	= "overflowuid",
  		.data		= &fs_overflowuid,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1693
  		.proc_handler	= proc_dointvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1694
1695
1696
1697
  		.extra1		= &minolduid,
  		.extra2		= &maxolduid,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1698
1699
1700
1701
  		.procname	= "overflowgid",
  		.data		= &fs_overflowgid,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1702
  		.proc_handler	= proc_dointvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1703
1704
1705
  		.extra1		= &minolduid,
  		.extra2		= &maxolduid,
  	},
bfcd17a6c   Thomas Petazzoni   Configure out fil...
1706
  #ifdef CONFIG_FILE_LOCKING
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1707
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1708
1709
1710
1711
  		.procname	= "leases-enable",
  		.data		= &leases_enable,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1712
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1713
  	},
bfcd17a6c   Thomas Petazzoni   Configure out fil...
1714
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1715
1716
  #ifdef CONFIG_DNOTIFY
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1717
1718
1719
1720
  		.procname	= "dir-notify-enable",
  		.data		= &dir_notify_enable,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1721
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1722
1723
1724
  	},
  #endif
  #ifdef CONFIG_MMU
bfcd17a6c   Thomas Petazzoni   Configure out fil...
1725
  #ifdef CONFIG_FILE_LOCKING
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1726
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1727
1728
1729
1730
  		.procname	= "lease-break-time",
  		.data		= &lease_break_time,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1731
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1732
  	},
bfcd17a6c   Thomas Petazzoni   Configure out fil...
1733
  #endif
ebf3f09c6   Thomas Petazzoni   Configure out AIO...
1734
  #ifdef CONFIG_AIO
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1735
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1736
1737
1738
1739
  		.procname	= "aio-nr",
  		.data		= &aio_nr,
  		.maxlen		= sizeof(aio_nr),
  		.mode		= 0444,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1740
  		.proc_handler	= proc_doulongvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1741
1742
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1743
1744
1745
1746
  		.procname	= "aio-max-nr",
  		.data		= &aio_max_nr,
  		.maxlen		= sizeof(aio_max_nr),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
1747
  		.proc_handler	= proc_doulongvec_minmax,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1748
  	},
ebf3f09c6   Thomas Petazzoni   Configure out AIO...
1749
  #endif /* CONFIG_AIO */
2d9048e20   Amy Griffis   [PATCH] inotify (...
1750
  #ifdef CONFIG_INOTIFY_USER
0399cb08c   Robert Love   [PATCH] inotify: ...
1751
  	{
0399cb08c   Robert Love   [PATCH] inotify: ...
1752
1753
1754
1755
1756
  		.procname	= "inotify",
  		.mode		= 0555,
  		.child		= inotify_table,
  	},
  #endif	
7ef9964e6   Davide Libenzi   epoll: introduce ...
1757
1758
1759
1760
1761
1762
1763
  #ifdef CONFIG_EPOLL
  	{
  		.procname	= "epoll",
  		.mode		= 0555,
  		.child		= epoll_table,
  	},
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1764
  #endif
d6e711448   Alan Cox   [PATCH] setuid co...
1765
  	{
800179c9b   Kees Cook   fs: add link rest...
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
  		.procname	= "protected_symlinks",
  		.data		= &sysctl_protected_symlinks,
  		.maxlen		= sizeof(int),
  		.mode		= 0600,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  	{
  		.procname	= "protected_hardlinks",
  		.data		= &sysctl_protected_hardlinks,
  		.maxlen		= sizeof(int),
  		.mode		= 0600,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  	{
d6e711448   Alan Cox   [PATCH] setuid co...
1784
1785
1786
1787
  		.procname	= "suid_dumpable",
  		.data		= &suid_dumpable,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
54b501992   Kees Cook   coredump: warn ab...
1788
  		.proc_handler	= proc_dointvec_minmax_coredump,
8e654fba4   Matthew Wilcox   sysctl: fix suid_...
1789
1790
  		.extra1		= &zero,
  		.extra2		= &two,
d6e711448   Alan Cox   [PATCH] setuid co...
1791
  	},
2abc26fc6   Eric W. Biederman   [PATCH] sysctl: c...
1792
1793
  #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  	{
2abc26fc6   Eric W. Biederman   [PATCH] sysctl: c...
1794
1795
  		.procname	= "binfmt_misc",
  		.mode		= 0555,
f9bd6733d   Eric W. Biederman   sysctl: Allow cre...
1796
  		.child		= sysctl_mount_point,
2abc26fc6   Eric W. Biederman   [PATCH] sysctl: c...
1797
1798
  	},
  #endif
b492e95be   Jens Axboe   pipe: set lower a...
1799
  	{
ff9da691c   Jens Axboe   pipe: change /pro...
1800
1801
  		.procname	= "pipe-max-size",
  		.data		= &pipe_max_size,
98159d977   Joe Lawrence   pipe: match pipe_...
1802
  		.maxlen		= sizeof(pipe_max_size),
b492e95be   Jens Axboe   pipe: set lower a...
1803
  		.mode		= 0644,
ff9da691c   Jens Axboe   pipe: change /pro...
1804
1805
  		.proc_handler	= &pipe_proc_fn,
  		.extra1		= &pipe_min_size,
b492e95be   Jens Axboe   pipe: set lower a...
1806
  	},
759c01142   Willy Tarreau   pipe: limit the p...
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
  	{
  		.procname	= "pipe-user-pages-hard",
  		.data		= &pipe_user_pages_hard,
  		.maxlen		= sizeof(pipe_user_pages_hard),
  		.mode		= 0644,
  		.proc_handler	= proc_doulongvec_minmax,
  	},
  	{
  		.procname	= "pipe-user-pages-soft",
  		.data		= &pipe_user_pages_soft,
  		.maxlen		= sizeof(pipe_user_pages_soft),
  		.mode		= 0644,
  		.proc_handler	= proc_doulongvec_minmax,
  	},
d29216842   Eric W. Biederman   mnt: Add a per mo...
1821
1822
1823
1824
1825
1826
1827
1828
  	{
  		.procname	= "mount-max",
  		.data		= &sysctl_mount_max,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &one,
  	},
6fce56ec9   Eric W. Biederman   sysctl: Remove re...
1829
  	{ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1830
  };
d8217f076   Eric W. Biederman   sysctl core: Stop...
1831
  static struct ctl_table debug_table[] = {
7ac57a89d   Catalin Marinas   Kconfig: clean up...
1832
  #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
abd4f7505   Masoud Asgharifard Sharbiani   x86: i386-show-un...
1833
  	{
abd4f7505   Masoud Asgharifard Sharbiani   x86: i386-show-un...
1834
1835
1836
1837
1838
1839
1840
  		.procname	= "exception-trace",
  		.data		= &show_unhandled_signals,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  #endif
b2be84df9   Masami Hiramatsu   kprobes: Jump opt...
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
  #if defined(CONFIG_OPTPROBES)
  	{
  		.procname	= "kprobes-optimization",
  		.data		= &sysctl_kprobes_optimization,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_kprobes_optimization_handler,
  		.extra1		= &zero,
  		.extra2		= &one,
  	},
  #endif
6fce56ec9   Eric W. Biederman   sysctl: Remove re...
1852
  	{ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1853
  };
d8217f076   Eric W. Biederman   sysctl core: Stop...
1854
  static struct ctl_table dev_table[] = {
6fce56ec9   Eric W. Biederman   sysctl: Remove re...
1855
  	{ }
0eeca2830   Robert Love   [PATCH] inotify
1856
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1857

de4e83bd6   Eric W. Biederman   sysctl: Register ...
1858
  int __init sysctl_init(void)
d912b0cc1   Eric W. Biederman   [PATCH] sysctl: a...
1859
  {
fd4b616b0   Steven Rostedt   sysctl: suppress ...
1860
1861
1862
1863
  	struct ctl_table_header *hdr;
  
  	hdr = register_sysctl_table(sysctl_base_table);
  	kmemleak_not_leak(hdr);
d912b0cc1   Eric W. Biederman   [PATCH] sysctl: a...
1864
1865
  	return 0;
  }
b89a81712   Eric W. Biederman   [PATCH] sysctl: A...
1866
  #endif /* CONFIG_SYSCTL */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1867
1868
1869
  /*
   * /proc/sys support
   */
b89a81712   Eric W. Biederman   [PATCH] sysctl: A...
1870
  #ifdef CONFIG_PROC_SYSCTL
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1871

f88083005   Kees Cook   sysctl: clean up ...
1872
1873
  static int _proc_do_string(char *data, int maxlen, int write,
  			   char __user *buffer,
b1ba4ddde   Adrian Bunk   [PATCH] make kern...
1874
  			   size_t *lenp, loff_t *ppos)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1875
1876
1877
1878
  {
  	size_t len;
  	char __user *p;
  	char c;
8d0608771   Oleg Nesterov   [PATCH] _proc_do_...
1879
1880
  
  	if (!data || !maxlen || !*lenp) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1881
1882
1883
  		*lenp = 0;
  		return 0;
  	}
8d0608771   Oleg Nesterov   [PATCH] _proc_do_...
1884

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1885
  	if (write) {
f4aacea2f   Kees Cook   sysctl: allow for...
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
  		if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
  			/* Only continue writes not past the end of buffer. */
  			len = strlen(data);
  			if (len > maxlen - 1)
  				len = maxlen - 1;
  
  			if (*ppos > len)
  				return 0;
  			len = *ppos;
  		} else {
  			/* Start writing from beginning of buffer. */
  			len = 0;
  		}
2ca9bb456   Kees Cook   sysctl: refactor ...
1899
  		*ppos += *lenp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1900
  		p = buffer;
2ca9bb456   Kees Cook   sysctl: refactor ...
1901
  		while ((p - buffer) < *lenp && len < maxlen - 1) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1902
1903
1904
1905
1906
  			if (get_user(c, p++))
  				return -EFAULT;
  			if (c == 0 || c == '
  ')
  				break;
2ca9bb456   Kees Cook   sysctl: refactor ...
1907
  			data[len++] = c;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1908
  		}
f88083005   Kees Cook   sysctl: clean up ...
1909
  		data[len] = 0;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1910
  	} else {
f5dd3d6fa   Sam Vilain   [PATCH] proc: sys...
1911
1912
1913
  		len = strlen(data);
  		if (len > maxlen)
  			len = maxlen;
8d0608771   Oleg Nesterov   [PATCH] _proc_do_...
1914
1915
1916
1917
1918
1919
1920
1921
  
  		if (*ppos > len) {
  			*lenp = 0;
  			return 0;
  		}
  
  		data += *ppos;
  		len  -= *ppos;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1922
1923
1924
  		if (len > *lenp)
  			len = *lenp;
  		if (len)
f88083005   Kees Cook   sysctl: clean up ...
1925
  			if (copy_to_user(buffer, data, len))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1926
1927
  				return -EFAULT;
  		if (len < *lenp) {
f88083005   Kees Cook   sysctl: clean up ...
1928
1929
  			if (put_user('
  ', buffer + len))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1930
1931
1932
1933
1934
1935
1936
1937
  				return -EFAULT;
  			len++;
  		}
  		*lenp = len;
  		*ppos += len;
  	}
  	return 0;
  }
f4aacea2f   Kees Cook   sysctl: allow for...
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
  static void warn_sysctl_write(struct ctl_table *table)
  {
  	pr_warn_once("%s wrote to %s when file position was not 0!
  "
  		"This will not be supported in the future. To silence this
  "
  		"warning, set kernel.sysctl_writes_strict = -1
  ",
  		current->comm, table->procname);
  }
f5dd3d6fa   Sam Vilain   [PATCH] proc: sys...
1948
  /**
d383d4847   Luis R. Rodriguez   sysctl: fold sysc...
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
   * proc_first_pos_non_zero_ignore - check if firs position is allowed
   * @ppos: file position
   * @table: the sysctl table
   *
   * Returns true if the first position is non-zero and the sysctl_writes_strict
   * mode indicates this is not allowed for numeric input types. String proc
   * hadlers can ignore the return value.
   */
  static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
  					   struct ctl_table *table)
  {
  	if (!*ppos)
  		return false;
  
  	switch (sysctl_writes_strict) {
  	case SYSCTL_WRITES_STRICT:
  		return true;
  	case SYSCTL_WRITES_WARN:
  		warn_sysctl_write(table);
  		return false;
  	default:
  		return false;
  	}
  }
  
  /**
f5dd3d6fa   Sam Vilain   [PATCH] proc: sys...
1975
1976
1977
   * proc_dostring - read a string sysctl
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
f5dd3d6fa   Sam Vilain   [PATCH] proc: sys...
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * Reads/writes a string from/to the user buffer. If the kernel
   * buffer provided is not large enough to hold the string, the
   * string is truncated. The copied string is %NULL-terminated.
   * If the string is being read by the user process, it is copied
   * and a newline '
  ' is added. It is truncated if the buffer is
   * not large enough.
   *
   * Returns 0 on success.
   */
8d65af789   Alexey Dobriyan   sysctl: remove "s...
1992
  int proc_dostring(struct ctl_table *table, int write,
f5dd3d6fa   Sam Vilain   [PATCH] proc: sys...
1993
1994
  		  void __user *buffer, size_t *lenp, loff_t *ppos)
  {
d383d4847   Luis R. Rodriguez   sysctl: fold sysc...
1995
1996
  	if (write)
  		proc_first_pos_non_zero_ignore(ppos, table);
f4aacea2f   Kees Cook   sysctl: allow for...
1997

f88083005   Kees Cook   sysctl: clean up ...
1998
1999
  	return _proc_do_string((char *)(table->data), table->maxlen, write,
  			       (char __user *)buffer, lenp, ppos);
f5dd3d6fa   Sam Vilain   [PATCH] proc: sys...
2000
  }
00b7c3395   Amerigo Wang   sysctl: refactor ...
2001
2002
2003
2004
2005
2006
2007
2008
  static size_t proc_skip_spaces(char **buf)
  {
  	size_t ret;
  	char *tmp = skip_spaces(*buf);
  	ret = tmp - *buf;
  	*buf = tmp;
  	return ret;
  }
9f977fb7a   Octavian Purdila   sysctl: add proc_...
2009
2010
2011
2012
2013
2014
2015
2016
2017
  static void proc_skip_char(char **buf, size_t *size, const char v)
  {
  	while (*size) {
  		if (**buf != v)
  			break;
  		(*size)--;
  		(*buf)++;
  	}
  }
00b7c3395   Amerigo Wang   sysctl: refactor ...
2018
2019
  #define TMPBUFLEN 22
  /**
0fc377bd6   Randy Dunlap   sysctl: fix kerne...
2020
   * proc_get_long - reads an ASCII formatted integer from a user buffer
00b7c3395   Amerigo Wang   sysctl: refactor ...
2021
   *
0fc377bd6   Randy Dunlap   sysctl: fix kerne...
2022
2023
2024
2025
2026
2027
2028
   * @buf: a kernel buffer
   * @size: size of the kernel buffer
   * @val: this is where the number will be stored
   * @neg: set to %TRUE if number is negative
   * @perm_tr: a vector which contains the allowed trailers
   * @perm_tr_len: size of the perm_tr vector
   * @tr: pointer to store the trailer character
00b7c3395   Amerigo Wang   sysctl: refactor ...
2029
   *
0fc377bd6   Randy Dunlap   sysctl: fix kerne...
2030
2031
2032
2033
   * In case of success %0 is returned and @buf and @size are updated with
   * the amount of bytes read. If @tr is non-NULL and a trailing
   * character exists (size is non-zero after returning from this
   * function), @tr is updated with the trailing character.
00b7c3395   Amerigo Wang   sysctl: refactor ...
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
   */
  static int proc_get_long(char **buf, size_t *size,
  			  unsigned long *val, bool *neg,
  			  const char *perm_tr, unsigned perm_tr_len, char *tr)
  {
  	int len;
  	char *p, tmp[TMPBUFLEN];
  
  	if (!*size)
  		return -EINVAL;
  
  	len = *size;
  	if (len > TMPBUFLEN - 1)
  		len = TMPBUFLEN - 1;
  
  	memcpy(tmp, *buf, len);
  
  	tmp[len] = 0;
  	p = tmp;
  	if (*p == '-' && *size > 1) {
  		*neg = true;
  		p++;
  	} else
  		*neg = false;
  	if (!isdigit(*p))
  		return -EINVAL;
  
  	*val = simple_strtoul(p, &p, 0);
  
  	len = p - tmp;
  
  	/* We don't know if the next char is whitespace thus we may accept
  	 * invalid integers (e.g. 1234...a) or two integers instead of one
  	 * (e.g. 123...1). So lets not allow such large numbers. */
  	if (len == TMPBUFLEN - 1)
  		return -EINVAL;
  
  	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
  		return -EINVAL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2073

00b7c3395   Amerigo Wang   sysctl: refactor ...
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
  	if (tr && (len < *size))
  		*tr = *p;
  
  	*buf += len;
  	*size -= len;
  
  	return 0;
  }
  
  /**
0fc377bd6   Randy Dunlap   sysctl: fix kerne...
2084
   * proc_put_long - converts an integer to a decimal ASCII formatted string
00b7c3395   Amerigo Wang   sysctl: refactor ...
2085
   *
0fc377bd6   Randy Dunlap   sysctl: fix kerne...
2086
2087
2088
2089
   * @buf: the user buffer
   * @size: the size of the user buffer
   * @val: the integer to be converted
   * @neg: sign of the number, %TRUE for negative
00b7c3395   Amerigo Wang   sysctl: refactor ...
2090
   *
0fc377bd6   Randy Dunlap   sysctl: fix kerne...
2091
2092
   * In case of success %0 is returned and @buf and @size are updated with
   * the amount of bytes written.
00b7c3395   Amerigo Wang   sysctl: refactor ...
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
   */
  static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
  			  bool neg)
  {
  	int len;
  	char tmp[TMPBUFLEN], *p = tmp;
  
  	sprintf(p, "%s%lu", neg ? "-" : "", val);
  	len = strlen(tmp);
  	if (len > *size)
  		len = *size;
  	if (copy_to_user(*buf, tmp, len))
  		return -EFAULT;
  	*size -= len;
  	*buf += len;
  	return 0;
  }
  #undef TMPBUFLEN
  
  static int proc_put_char(void __user **buf, size_t *size, char c)
  {
  	if (*size) {
  		char __user **buffer = (char __user **)buf;
  		if (put_user(c, *buffer))
  			return -EFAULT;
  		(*size)--, (*buffer)++;
  		*buf = *buffer;
  	}
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2123

00b7c3395   Amerigo Wang   sysctl: refactor ...
2124
  static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2125
2126
2127
2128
  				 int *valp,
  				 int write, void *data)
  {
  	if (write) {
230633d10   Heinrich Schuchardt   kernel/sysctl.c: ...
2129
2130
2131
2132
2133
2134
2135
2136
2137
  		if (*negp) {
  			if (*lvalp > (unsigned long) INT_MAX + 1)
  				return -EINVAL;
  			*valp = -*lvalp;
  		} else {
  			if (*lvalp > (unsigned long) INT_MAX)
  				return -EINVAL;
  			*valp = *lvalp;
  		}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2138
2139
2140
  	} else {
  		int val = *valp;
  		if (val < 0) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2141
  			*negp = true;
9a5bc726d   Ilya Dryomov   sysctl: fix int -...
2142
  			*lvalp = -(unsigned long)val;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2143
  		} else {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2144
  			*negp = false;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2145
2146
2147
2148
2149
  			*lvalp = (unsigned long)val;
  		}
  	}
  	return 0;
  }
4f2fec00a   Luis R. Rodriguez   sysctl: simplify ...
2150
2151
2152
  static int do_proc_douintvec_conv(unsigned long *lvalp,
  				  unsigned int *valp,
  				  int write, void *data)
e7d316a02   Subash Abhinov Kasiviswanathan   sysctl: handle er...
2153
2154
  {
  	if (write) {
4f2fec00a   Luis R. Rodriguez   sysctl: simplify ...
2155
  		if (*lvalp > UINT_MAX)
e7d316a02   Subash Abhinov Kasiviswanathan   sysctl: handle er...
2156
2157
2158
2159
2160
2161
2162
2163
  			return -EINVAL;
  		*valp = *lvalp;
  	} else {
  		unsigned int val = *valp;
  		*lvalp = (unsigned long)val;
  	}
  	return 0;
  }
00b7c3395   Amerigo Wang   sysctl: refactor ...
2164
2165
  static const char proc_wspace_sep[] = { ' ', '\t', '
  ' };
d8217f076   Eric W. Biederman   sysctl core: Stop...
2166
  static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2167
  		  int write, void __user *buffer,
fcfbd547b   Kirill Korotaev   [PATCH] IPC names...
2168
  		  size_t *lenp, loff_t *ppos,
00b7c3395   Amerigo Wang   sysctl: refactor ...
2169
  		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2170
2171
2172
  			      int write, void *data),
  		  void *data)
  {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2173
  	int *i, vleft, first = 1, err = 0;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2174
  	size_t left;
70f6cbb6f   Al Viro   kernel/*: switch ...
2175
  	char *kbuf = NULL, *p;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2176
  	
00b7c3395   Amerigo Wang   sysctl: refactor ...
2177
  	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2178
2179
2180
2181
  		*lenp = 0;
  		return 0;
  	}
  	
fcfbd547b   Kirill Korotaev   [PATCH] IPC names...
2182
  	i = (int *) tbl_data;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2183
2184
2185
2186
2187
  	vleft = table->maxlen / sizeof(*i);
  	left = *lenp;
  
  	if (!conv)
  		conv = do_proc_dointvec_conv;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2188
  	if (write) {
d383d4847   Luis R. Rodriguez   sysctl: fold sysc...
2189
2190
  		if (proc_first_pos_non_zero_ignore(ppos, table))
  			goto out;
f4aacea2f   Kees Cook   sysctl: allow for...
2191

00b7c3395   Amerigo Wang   sysctl: refactor ...
2192
2193
  		if (left > PAGE_SIZE - 1)
  			left = PAGE_SIZE - 1;
70f6cbb6f   Al Viro   kernel/*: switch ...
2194
2195
2196
  		p = kbuf = memdup_user_nul(buffer, left);
  		if (IS_ERR(kbuf))
  			return PTR_ERR(kbuf);
00b7c3395   Amerigo Wang   sysctl: refactor ...
2197
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2198
  	for (; left && vleft--; i++, first=0) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2199
2200
  		unsigned long lval;
  		bool neg;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2201

00b7c3395   Amerigo Wang   sysctl: refactor ...
2202
  		if (write) {
70f6cbb6f   Al Viro   kernel/*: switch ...
2203
  			left -= proc_skip_spaces(&p);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2204

563b04671   J. R. Okajima   proc_dointvec: wr...
2205
2206
  			if (!left)
  				break;
70f6cbb6f   Al Viro   kernel/*: switch ...
2207
  			err = proc_get_long(&p, &left, &lval, &neg,
00b7c3395   Amerigo Wang   sysctl: refactor ...
2208
2209
2210
  					     proc_wspace_sep,
  					     sizeof(proc_wspace_sep), NULL);
  			if (err)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2211
  				break;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2212
2213
  			if (conv(&neg, &lval, i, 1, data)) {
  				err = -EINVAL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2214
  				break;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2215
  			}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2216
  		} else {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2217
2218
2219
2220
  			if (conv(&neg, &lval, i, 0, data)) {
  				err = -EINVAL;
  				break;
  			}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2221
  			if (!first)
00b7c3395   Amerigo Wang   sysctl: refactor ...
2222
2223
2224
2225
2226
  				err = proc_put_char(&buffer, &left, '\t');
  			if (err)
  				break;
  			err = proc_put_long(&buffer, &left, lval, neg);
  			if (err)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2227
  				break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2228
2229
  		}
  	}
00b7c3395   Amerigo Wang   sysctl: refactor ...
2230
2231
2232
  	if (!write && !first && left && !err)
  		err = proc_put_char(&buffer, &left, '
  ');
563b04671   J. R. Okajima   proc_dointvec: wr...
2233
  	if (write && !err && left)
70f6cbb6f   Al Viro   kernel/*: switch ...
2234
  		left -= proc_skip_spaces(&p);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2235
  	if (write) {
70f6cbb6f   Al Viro   kernel/*: switch ...
2236
  		kfree(kbuf);
00b7c3395   Amerigo Wang   sysctl: refactor ...
2237
2238
  		if (first)
  			return err ? : -EINVAL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2239
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2240
  	*lenp -= left;
f4aacea2f   Kees Cook   sysctl: allow for...
2241
  out:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2242
  	*ppos += *lenp;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2243
  	return err;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2244
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2245
  static int do_proc_dointvec(struct ctl_table *table, int write,
fcfbd547b   Kirill Korotaev   [PATCH] IPC names...
2246
  		  void __user *buffer, size_t *lenp, loff_t *ppos,
00b7c3395   Amerigo Wang   sysctl: refactor ...
2247
  		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
fcfbd547b   Kirill Korotaev   [PATCH] IPC names...
2248
2249
2250
  			      int write, void *data),
  		  void *data)
  {
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2251
  	return __do_proc_dointvec(table->data, table, write,
fcfbd547b   Kirill Korotaev   [PATCH] IPC names...
2252
2253
  			buffer, lenp, ppos, conv, data);
  }
4f2fec00a   Luis R. Rodriguez   sysctl: simplify ...
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
  static int do_proc_douintvec_w(unsigned int *tbl_data,
  			       struct ctl_table *table,
  			       void __user *buffer,
  			       size_t *lenp, loff_t *ppos,
  			       int (*conv)(unsigned long *lvalp,
  					   unsigned int *valp,
  					   int write, void *data),
  			       void *data)
  {
  	unsigned long lval;
  	int err = 0;
  	size_t left;
  	bool neg;
  	char *kbuf = NULL, *p;
  
  	left = *lenp;
  
  	if (proc_first_pos_non_zero_ignore(ppos, table))
  		goto bail_early;
  
  	if (left > PAGE_SIZE - 1)
  		left = PAGE_SIZE - 1;
  
  	p = kbuf = memdup_user_nul(buffer, left);
  	if (IS_ERR(kbuf))
  		return -EINVAL;
  
  	left -= proc_skip_spaces(&p);
  	if (!left) {
  		err = -EINVAL;
  		goto out_free;
  	}
  
  	err = proc_get_long(&p, &left, &lval, &neg,
  			     proc_wspace_sep,
  			     sizeof(proc_wspace_sep), NULL);
  	if (err || neg) {
  		err = -EINVAL;
  		goto out_free;
  	}
  
  	if (conv(&lval, tbl_data, 1, data)) {
  		err = -EINVAL;
  		goto out_free;
  	}
  
  	if (!err && left)
  		left -= proc_skip_spaces(&p);
  
  out_free:
  	kfree(kbuf);
  	if (err)
  		return -EINVAL;
  
  	return 0;
  
  	/* This is in keeping with old __do_proc_dointvec() */
  bail_early:
  	*ppos += *lenp;
  	return err;
  }
  
  static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
  			       size_t *lenp, loff_t *ppos,
  			       int (*conv)(unsigned long *lvalp,
  					   unsigned int *valp,
  					   int write, void *data),
  			       void *data)
  {
  	unsigned long lval;
  	int err = 0;
  	size_t left;
  
  	left = *lenp;
  
  	if (conv(&lval, tbl_data, 0, data)) {
  		err = -EINVAL;
  		goto out;
  	}
  
  	err = proc_put_long(&buffer, &left, lval, false);
  	if (err || !left)
  		goto out;
  
  	err = proc_put_char(&buffer, &left, '
  ');
  
  out:
  	*lenp -= left;
  	*ppos += *lenp;
  
  	return err;
  }
  
  static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
  			       int write, void __user *buffer,
  			       size_t *lenp, loff_t *ppos,
  			       int (*conv)(unsigned long *lvalp,
  					   unsigned int *valp,
  					   int write, void *data),
  			       void *data)
  {
  	unsigned int *i, vleft;
  
  	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
  		*lenp = 0;
  		return 0;
  	}
  
  	i = (unsigned int *) tbl_data;
  	vleft = table->maxlen / sizeof(*i);
  
  	/*
  	 * Arrays are not supported, keep this simple. *Do not* add
  	 * support for them.
  	 */
  	if (vleft != 1) {
  		*lenp = 0;
  		return -EINVAL;
  	}
  
  	if (!conv)
  		conv = do_proc_douintvec_conv;
  
  	if (write)
  		return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
  					   conv, data);
  	return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
  }
  
  static int do_proc_douintvec(struct ctl_table *table, int write,
  			     void __user *buffer, size_t *lenp, loff_t *ppos,
  			     int (*conv)(unsigned long *lvalp,
  					 unsigned int *valp,
  					 int write, void *data),
  			     void *data)
  {
  	return __do_proc_douintvec(table->data, table, write,
  				   buffer, lenp, ppos, conv, data);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2394
2395
2396
2397
  /**
   * proc_dointvec - read a vector of integers
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2398
2399
2400
2401
2402
2403
2404
2405
2406
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
   * values from/to the user buffer, treated as an ASCII string. 
   *
   * Returns 0 on success.
   */
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2407
  int proc_dointvec(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2408
2409
  		     void __user *buffer, size_t *lenp, loff_t *ppos)
  {
e7d316a02   Subash Abhinov Kasiviswanathan   sysctl: handle er...
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
  	return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
  }
  
  /**
   * proc_douintvec - read a vector of unsigned integers
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
   * values from/to the user buffer, treated as an ASCII string.
   *
   * Returns 0 on success.
   */
  int proc_douintvec(struct ctl_table *table, int write,
  		     void __user *buffer, size_t *lenp, loff_t *ppos)
  {
4f2fec00a   Luis R. Rodriguez   sysctl: simplify ...
2429
2430
  	return do_proc_douintvec(table, write, buffer, lenp, ppos,
  				 do_proc_douintvec_conv, NULL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2431
  }
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
2432
  /*
25ddbb18a   Andi Kleen   Make the taint fl...
2433
2434
   * Taint values can only be increased
   * This means we can safely use a temporary.
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
2435
   */
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2436
  static int proc_taint(struct ctl_table *table, int write,
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
2437
2438
  			       void __user *buffer, size_t *lenp, loff_t *ppos)
  {
25ddbb18a   Andi Kleen   Make the taint fl...
2439
2440
2441
  	struct ctl_table t;
  	unsigned long tmptaint = get_taint();
  	int err;
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
2442

91fcd412e   Bastian Blank   Allow reading tai...
2443
  	if (write && !capable(CAP_SYS_ADMIN))
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
2444
  		return -EPERM;
25ddbb18a   Andi Kleen   Make the taint fl...
2445
2446
  	t = *table;
  	t.data = &tmptaint;
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2447
  	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
25ddbb18a   Andi Kleen   Make the taint fl...
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
  	if (err < 0)
  		return err;
  
  	if (write) {
  		/*
  		 * Poor man's atomic or. Not worth adding a primitive
  		 * to everyone's atomic.h for this
  		 */
  		int i;
  		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
  			if ((tmptaint >> i) & 1)
373d4d099   Rusty Russell   taint: add explic...
2459
  				add_taint(i, LOCKDEP_STILL_OK);
25ddbb18a   Andi Kleen   Make the taint fl...
2460
2461
2462
2463
  		}
  	}
  
  	return err;
34f5a3989   Theodore Ts'o   [PATCH] Add TAINT...
2464
  }
bfdc0b497   Richard Weinberger   sysctl: restrict ...
2465
  #ifdef CONFIG_PRINTK
620f6e8e8   Kees Cook   sysctl: fix write...
2466
  static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
bfdc0b497   Richard Weinberger   sysctl: restrict ...
2467
2468
2469
2470
2471
2472
2473
2474
  				void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	if (write && !capable(CAP_SYS_ADMIN))
  		return -EPERM;
  
  	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2475
2476
2477
2478
  struct do_proc_dointvec_minmax_conv_param {
  	int *min;
  	int *max;
  };
00b7c3395   Amerigo Wang   sysctl: refactor ...
2479
2480
  static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
  					int *valp,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
  					int write, void *data)
  {
  	struct do_proc_dointvec_minmax_conv_param *param = data;
  	if (write) {
  		int val = *negp ? -*lvalp : *lvalp;
  		if ((param->min && *param->min > val) ||
  		    (param->max && *param->max < val))
  			return -EINVAL;
  		*valp = val;
  	} else {
  		int val = *valp;
  		if (val < 0) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2493
  			*negp = true;
9a5bc726d   Ilya Dryomov   sysctl: fix int -...
2494
  			*lvalp = -(unsigned long)val;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2495
  		} else {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2496
  			*negp = false;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
  			*lvalp = (unsigned long)val;
  		}
  	}
  	return 0;
  }
  
  /**
   * proc_dointvec_minmax - read a vector of integers with min/max values
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
   * values from/to the user buffer, treated as an ASCII string.
   *
   * This routine will ensure the values are within the range specified by
   * table->extra1 (min) and table->extra2 (max).
   *
   * Returns 0 on success.
   */
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2519
  int proc_dointvec_minmax(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2520
2521
2522
2523
2524
2525
  		  void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	struct do_proc_dointvec_minmax_conv_param param = {
  		.min = (int *) table->extra1,
  		.max = (int *) table->extra2,
  	};
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2526
  	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2527
2528
  				do_proc_dointvec_minmax_conv, &param);
  }
61d9b56a8   Luis R. Rodriguez   sysctl: add unsig...
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
  struct do_proc_douintvec_minmax_conv_param {
  	unsigned int *min;
  	unsigned int *max;
  };
  
  static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
  					 unsigned int *valp,
  					 int write, void *data)
  {
  	struct do_proc_douintvec_minmax_conv_param *param = data;
  
  	if (write) {
  		unsigned int val = *lvalp;
fb910c42c   Joe Lawrence   sysctl: check for...
2542
2543
  		if (*lvalp > UINT_MAX)
  			return -EINVAL;
61d9b56a8   Luis R. Rodriguez   sysctl: add unsig...
2544
2545
2546
  		if ((param->min && *param->min > val) ||
  		    (param->max && *param->max < val))
  			return -ERANGE;
61d9b56a8   Luis R. Rodriguez   sysctl: add unsig...
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
  		*valp = val;
  	} else {
  		unsigned int val = *valp;
  		*lvalp = (unsigned long) val;
  	}
  
  	return 0;
  }
  
  /**
   * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
   * values from/to the user buffer, treated as an ASCII string. Negative
   * strings are not allowed.
   *
   * This routine will ensure the values are within the range specified by
   * table->extra1 (min) and table->extra2 (max). There is a final sanity
   * check for UINT_MAX to avoid having to support wrap around uses from
   * userspace.
   *
   * Returns 0 on success.
   */
  int proc_douintvec_minmax(struct ctl_table *table, int write,
  			  void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	struct do_proc_douintvec_minmax_conv_param param = {
  		.min = (unsigned int *) table->extra1,
  		.max = (unsigned int *) table->extra2,
  	};
  	return do_proc_douintvec(table, write, buffer, lenp, ppos,
  				 do_proc_douintvec_minmax_conv, &param);
  }
7a8d18194   Joe Lawrence   pipe: add proc_do...
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
  struct do_proc_dopipe_max_size_conv_param {
  	unsigned int *min;
  };
  
  static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
  					unsigned int *valp,
  					int write, void *data)
  {
  	struct do_proc_dopipe_max_size_conv_param *param = data;
  
  	if (write) {
fb910c42c   Joe Lawrence   sysctl: check for...
2596
  		unsigned int val;
7a8d18194   Joe Lawrence   pipe: add proc_do...
2597

fb910c42c   Joe Lawrence   sysctl: check for...
2598
2599
2600
2601
  		if (*lvalp > UINT_MAX)
  			return -EINVAL;
  
  		val = round_pipe_size(*lvalp);
7a8d18194   Joe Lawrence   pipe: add proc_do...
2602
2603
2604
2605
2606
  		if (val == 0)
  			return -EINVAL;
  
  		if (param->min && *param->min > val)
  			return -ERANGE;
7a8d18194   Joe Lawrence   pipe: add proc_do...
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
  		*valp = val;
  	} else {
  		unsigned int val = *valp;
  		*lvalp = (unsigned long) val;
  	}
  
  	return 0;
  }
  
  int proc_dopipe_max_size(struct ctl_table *table, int write,
  			 void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	struct do_proc_dopipe_max_size_conv_param param = {
  		.min = (unsigned int *) table->extra1,
  	};
  	return do_proc_douintvec(table, write, buffer, lenp, ppos,
  				 do_proc_dopipe_max_size_conv, &param);
  }
54b501992   Kees Cook   coredump: warn ab...
2625
2626
  static void validate_coredump_safety(void)
  {
046d662f4   Alex Kelly   coredump: make co...
2627
  #ifdef CONFIG_COREDUMP
e579d2c25   Kees Cook   coredump: remove ...
2628
  	if (suid_dumpable == SUID_DUMP_ROOT &&
54b501992   Kees Cook   coredump: warn ab...
2629
  	    core_pattern[0] != '/' && core_pattern[0] != '|') {
760c6a913   Alexey Dobriyan   coredump: clarify...
2630
2631
2632
2633
2634
2635
2636
2637
  		printk(KERN_WARNING
  "Unsafe core_pattern used with fs.suid_dumpable=2.
  "
  "Pipe handler or fully qualified core dump path required.
  "
  "Set kernel.core_pattern before fs.suid_dumpable.
  "
  		);
54b501992   Kees Cook   coredump: warn ab...
2638
  	}
046d662f4   Alex Kelly   coredump: make co...
2639
  #endif
54b501992   Kees Cook   coredump: warn ab...
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
  }
  
  static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
  		void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  	if (!error)
  		validate_coredump_safety();
  	return error;
  }
046d662f4   Alex Kelly   coredump: make co...
2650
  #ifdef CONFIG_COREDUMP
54b501992   Kees Cook   coredump: warn ab...
2651
2652
2653
2654
2655
2656
2657
2658
  static int proc_dostring_coredump(struct ctl_table *table, int write,
  		  void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	int error = proc_dostring(table, write, buffer, lenp, ppos);
  	if (!error)
  		validate_coredump_safety();
  	return error;
  }
046d662f4   Alex Kelly   coredump: make co...
2659
  #endif
54b501992   Kees Cook   coredump: warn ab...
2660

d8217f076   Eric W. Biederman   sysctl core: Stop...
2661
  static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2662
2663
2664
2665
2666
  				     void __user *buffer,
  				     size_t *lenp, loff_t *ppos,
  				     unsigned long convmul,
  				     unsigned long convdiv)
  {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2667
2668
  	unsigned long *i, *min, *max;
  	int vleft, first = 1, err = 0;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2669
  	size_t left;
70f6cbb6f   Al Viro   kernel/*: switch ...
2670
  	char *kbuf = NULL, *p;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2671
2672
  
  	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2673
2674
2675
  		*lenp = 0;
  		return 0;
  	}
00b7c3395   Amerigo Wang   sysctl: refactor ...
2676

fcfbd547b   Kirill Korotaev   [PATCH] IPC names...
2677
  	i = (unsigned long *) data;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2678
2679
2680
2681
  	min = (unsigned long *) table->extra1;
  	max = (unsigned long *) table->extra2;
  	vleft = table->maxlen / sizeof(unsigned long);
  	left = *lenp;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2682
2683
  
  	if (write) {
d383d4847   Luis R. Rodriguez   sysctl: fold sysc...
2684
2685
  		if (proc_first_pos_non_zero_ignore(ppos, table))
  			goto out;
f4aacea2f   Kees Cook   sysctl: allow for...
2686

00b7c3395   Amerigo Wang   sysctl: refactor ...
2687
2688
  		if (left > PAGE_SIZE - 1)
  			left = PAGE_SIZE - 1;
70f6cbb6f   Al Viro   kernel/*: switch ...
2689
2690
2691
  		p = kbuf = memdup_user_nul(buffer, left);
  		if (IS_ERR(kbuf))
  			return PTR_ERR(kbuf);
00b7c3395   Amerigo Wang   sysctl: refactor ...
2692
  	}
27b3d80a7   Eric Dumazet   sysctl: fix min/m...
2693
  	for (; left && vleft--; i++, first = 0) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2694
  		unsigned long val;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2695
  		if (write) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2696
  			bool neg;
70f6cbb6f   Al Viro   kernel/*: switch ...
2697
  			left -= proc_skip_spaces(&p);
00b7c3395   Amerigo Wang   sysctl: refactor ...
2698

70f6cbb6f   Al Viro   kernel/*: switch ...
2699
  			err = proc_get_long(&p, &left, &val, &neg,
00b7c3395   Amerigo Wang   sysctl: refactor ...
2700
2701
2702
  					     proc_wspace_sep,
  					     sizeof(proc_wspace_sep), NULL);
  			if (err)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2703
2704
  				break;
  			if (neg)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2705
  				continue;
ff9f8a7cf   Eric Dumazet   sysctl: fix proc_...
2706
  			val = convmul * val / convdiv;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2707
2708
2709
2710
  			if ((min && val < *min) || (max && val > *max))
  				continue;
  			*i = val;
  		} else {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2711
  			val = convdiv * (*i) / convmul;
7833819d2   Chen Gang   kernel/sysctl.c: ...
2712
  			if (!first) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2713
  				err = proc_put_char(&buffer, &left, '\t');
7833819d2   Chen Gang   kernel/sysctl.c: ...
2714
2715
2716
  				if (err)
  					break;
  			}
00b7c3395   Amerigo Wang   sysctl: refactor ...
2717
2718
2719
  			err = proc_put_long(&buffer, &left, val, false);
  			if (err)
  				break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2720
2721
  		}
  	}
00b7c3395   Amerigo Wang   sysctl: refactor ...
2722
2723
2724
2725
  	if (!write && !first && left && !err)
  		err = proc_put_char(&buffer, &left, '
  ');
  	if (write && !err)
70f6cbb6f   Al Viro   kernel/*: switch ...
2726
  		left -= proc_skip_spaces(&p);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2727
  	if (write) {
70f6cbb6f   Al Viro   kernel/*: switch ...
2728
  		kfree(kbuf);
00b7c3395   Amerigo Wang   sysctl: refactor ...
2729
2730
  		if (first)
  			return err ? : -EINVAL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2731
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2732
  	*lenp -= left;
f4aacea2f   Kees Cook   sysctl: allow for...
2733
  out:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2734
  	*ppos += *lenp;
00b7c3395   Amerigo Wang   sysctl: refactor ...
2735
  	return err;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2736
  }
d8217f076   Eric W. Biederman   sysctl core: Stop...
2737
  static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
fcfbd547b   Kirill Korotaev   [PATCH] IPC names...
2738
2739
2740
2741
2742
2743
  				     void __user *buffer,
  				     size_t *lenp, loff_t *ppos,
  				     unsigned long convmul,
  				     unsigned long convdiv)
  {
  	return __do_proc_doulongvec_minmax(table->data, table, write,
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2744
  			buffer, lenp, ppos, convmul, convdiv);
fcfbd547b   Kirill Korotaev   [PATCH] IPC names...
2745
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2746
2747
2748
2749
  /**
   * proc_doulongvec_minmax - read a vector of long integers with min/max values
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
   * values from/to the user buffer, treated as an ASCII string.
   *
   * This routine will ensure the values are within the range specified by
   * table->extra1 (min) and table->extra2 (max).
   *
   * Returns 0 on success.
   */
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2762
  int proc_doulongvec_minmax(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2763
2764
  			   void __user *buffer, size_t *lenp, loff_t *ppos)
  {
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2765
      return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2766
2767
2768
2769
2770
2771
  }
  
  /**
   * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
   * values from/to the user buffer, treated as an ASCII string. The values
   * are treated as milliseconds, and converted to jiffies when they are stored.
   *
   * This routine will ensure the values are within the range specified by
   * table->extra1 (min) and table->extra2 (max).
   *
   * Returns 0 on success.
   */
d8217f076   Eric W. Biederman   sysctl core: Stop...
2785
  int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2786
2787
2788
  				      void __user *buffer,
  				      size_t *lenp, loff_t *ppos)
  {
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2789
      return do_proc_doulongvec_minmax(table, write, buffer,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2790
2791
  				     lenp, ppos, HZ, 1000l);
  }
00b7c3395   Amerigo Wang   sysctl: refactor ...
2792
  static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2793
2794
2795
2796
  					 int *valp,
  					 int write, void *data)
  {
  	if (write) {
63259457a   Gao Feng   proc/sysctl: fix ...
2797
  		if (*lvalp > INT_MAX / HZ)
cba9f33d1   Bart Samwel   [PATCH] Range che...
2798
  			return 1;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2799
2800
2801
2802
2803
  		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  	} else {
  		int val = *valp;
  		unsigned long lval;
  		if (val < 0) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2804
  			*negp = true;
9a5bc726d   Ilya Dryomov   sysctl: fix int -...
2805
  			lval = -(unsigned long)val;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2806
  		} else {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2807
  			*negp = false;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2808
2809
2810
2811
2812
2813
  			lval = (unsigned long)val;
  		}
  		*lvalp = lval / HZ;
  	}
  	return 0;
  }
00b7c3395   Amerigo Wang   sysctl: refactor ...
2814
  static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2815
2816
2817
2818
  						int *valp,
  						int write, void *data)
  {
  	if (write) {
cba9f33d1   Bart Samwel   [PATCH] Range che...
2819
2820
  		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  			return 1;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2821
2822
2823
2824
2825
  		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  	} else {
  		int val = *valp;
  		unsigned long lval;
  		if (val < 0) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2826
  			*negp = true;
9a5bc726d   Ilya Dryomov   sysctl: fix int -...
2827
  			lval = -(unsigned long)val;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2828
  		} else {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2829
  			*negp = false;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2830
2831
2832
2833
2834
2835
  			lval = (unsigned long)val;
  		}
  		*lvalp = jiffies_to_clock_t(lval);
  	}
  	return 0;
  }
00b7c3395   Amerigo Wang   sysctl: refactor ...
2836
  static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2837
2838
2839
2840
  					    int *valp,
  					    int write, void *data)
  {
  	if (write) {
d738ce8fd   Francesco Fusco   sysctl: range che...
2841
2842
2843
2844
2845
  		unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  
  		if (jif > INT_MAX)
  			return 1;
  		*valp = (int)jif;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2846
2847
2848
2849
  	} else {
  		int val = *valp;
  		unsigned long lval;
  		if (val < 0) {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2850
  			*negp = true;
9a5bc726d   Ilya Dryomov   sysctl: fix int -...
2851
  			lval = -(unsigned long)val;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2852
  		} else {
00b7c3395   Amerigo Wang   sysctl: refactor ...
2853
  			*negp = false;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
  			lval = (unsigned long)val;
  		}
  		*lvalp = jiffies_to_msecs(lval);
  	}
  	return 0;
  }
  
  /**
   * proc_dointvec_jiffies - read a vector of integers as seconds
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
   * values from/to the user buffer, treated as an ASCII string. 
   * The values read are assumed to be in seconds, and are converted into
   * jiffies.
   *
   * Returns 0 on success.
   */
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2876
  int proc_dointvec_jiffies(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2877
2878
  			  void __user *buffer, size_t *lenp, loff_t *ppos)
  {
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2879
      return do_proc_dointvec(table,write,buffer,lenp,ppos,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2880
2881
2882
2883
2884
2885
2886
  		    	    do_proc_dointvec_jiffies_conv,NULL);
  }
  
  /**
   * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2887
2888
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
1e5d53314   Randy Dunlap   [PATCH] more kern...
2889
   * @ppos: pointer to the file position
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2890
2891
2892
2893
2894
2895
2896
2897
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
   * values from/to the user buffer, treated as an ASCII string. 
   * The values read are assumed to be in 1/USER_HZ seconds, and 
   * are converted into jiffies.
   *
   * Returns 0 on success.
   */
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2898
  int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2899
2900
  				 void __user *buffer, size_t *lenp, loff_t *ppos)
  {
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2901
      return do_proc_dointvec(table,write,buffer,lenp,ppos,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2902
2903
2904
2905
2906
2907
2908
  		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
  }
  
  /**
   * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2909
2910
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
67be2dd1b   Martin Waitz   [PATCH] DocBook: ...
2911
2912
   * @ppos: file position
   * @ppos: the current position in the file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2913
2914
2915
2916
2917
2918
2919
2920
   *
   * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
   * values from/to the user buffer, treated as an ASCII string. 
   * The values read are assumed to be in 1/1000 seconds, and 
   * are converted into jiffies.
   *
   * Returns 0 on success.
   */
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2921
  int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2922
2923
  			     void __user *buffer, size_t *lenp, loff_t *ppos)
  {
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2924
  	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2925
2926
  				do_proc_dointvec_ms_jiffies_conv, NULL);
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
2927
  static int proc_do_cad_pid(struct ctl_table *table, int write,
9ec52099e   Cedric Le Goater   [PATCH] replace c...
2928
2929
2930
2931
2932
  			   void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	struct pid *new_pid;
  	pid_t tmp;
  	int r;
6c5f3e7b4   Pavel Emelyanov   Pidns: make full ...
2933
  	tmp = pid_vnr(cad_pid);
9ec52099e   Cedric Le Goater   [PATCH] replace c...
2934

8d65af789   Alexey Dobriyan   sysctl: remove "s...
2935
  	r = __do_proc_dointvec(&tmp, table, write, buffer,
9ec52099e   Cedric Le Goater   [PATCH] replace c...
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
  			       lenp, ppos, NULL, NULL);
  	if (r || !write)
  		return r;
  
  	new_pid = find_get_pid(tmp);
  	if (!new_pid)
  		return -ESRCH;
  
  	put_pid(xchg(&cad_pid, new_pid));
  	return 0;
  }
9f977fb7a   Octavian Purdila   sysctl: add proc_...
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
  /**
   * proc_do_large_bitmap - read/write from/to a large bitmap
   * @table: the sysctl table
   * @write: %TRUE if this is a write to the sysctl file
   * @buffer: the user buffer
   * @lenp: the size of the user buffer
   * @ppos: file position
   *
   * The bitmap is stored at table->data and the bitmap length (in bits)
   * in table->maxlen.
   *
   * We use a range comma separated format (e.g. 1,3-4,10-10) so that
   * large bitmaps may be represented in a compact manner. Writing into
   * the file will clear the bitmap then update it with the given input.
   *
   * Returns 0 on success.
   */
  int proc_do_large_bitmap(struct ctl_table *table, int write,
  			 void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	int err = 0;
  	bool first = 1;
  	size_t left = *lenp;
  	unsigned long bitmap_len = table->maxlen;
122ff243f   WANG Cong   ipv4: make ip_loc...
2971
  	unsigned long *bitmap = *(unsigned long **) table->data;
9f977fb7a   Octavian Purdila   sysctl: add proc_...
2972
2973
2974
2975
  	unsigned long *tmp_bitmap = NULL;
  	char tr_a[] = { '-', ',', '
  ' }, tr_b[] = { ',', '
  ', 0 }, c;
122ff243f   WANG Cong   ipv4: make ip_loc...
2976
  	if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
9f977fb7a   Octavian Purdila   sysctl: add proc_...
2977
2978
2979
2980
2981
  		*lenp = 0;
  		return 0;
  	}
  
  	if (write) {
70f6cbb6f   Al Viro   kernel/*: switch ...
2982
  		char *kbuf, *p;
9f977fb7a   Octavian Purdila   sysctl: add proc_...
2983
2984
2985
  
  		if (left > PAGE_SIZE - 1)
  			left = PAGE_SIZE - 1;
70f6cbb6f   Al Viro   kernel/*: switch ...
2986
2987
2988
  		p = kbuf = memdup_user_nul(buffer, left);
  		if (IS_ERR(kbuf))
  			return PTR_ERR(kbuf);
9f977fb7a   Octavian Purdila   sysctl: add proc_...
2989
2990
2991
2992
  
  		tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
  				     GFP_KERNEL);
  		if (!tmp_bitmap) {
70f6cbb6f   Al Viro   kernel/*: switch ...
2993
  			kfree(kbuf);
9f977fb7a   Octavian Purdila   sysctl: add proc_...
2994
2995
  			return -ENOMEM;
  		}
70f6cbb6f   Al Viro   kernel/*: switch ...
2996
2997
  		proc_skip_char(&p, &left, '
  ');
9f977fb7a   Octavian Purdila   sysctl: add proc_...
2998
2999
3000
  		while (!err && left) {
  			unsigned long val_a, val_b;
  			bool neg;
70f6cbb6f   Al Viro   kernel/*: switch ...
3001
  			err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
  					     sizeof(tr_a), &c);
  			if (err)
  				break;
  			if (val_a >= bitmap_len || neg) {
  				err = -EINVAL;
  				break;
  			}
  
  			val_b = val_a;
  			if (left) {
70f6cbb6f   Al Viro   kernel/*: switch ...
3012
  				p++;
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3013
3014
3015
3016
  				left--;
  			}
  
  			if (c == '-') {
70f6cbb6f   Al Viro   kernel/*: switch ...
3017
  				err = proc_get_long(&p, &left, &val_b,
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
  						     &neg, tr_b, sizeof(tr_b),
  						     &c);
  				if (err)
  					break;
  				if (val_b >= bitmap_len || neg ||
  				    val_a > val_b) {
  					err = -EINVAL;
  					break;
  				}
  				if (left) {
70f6cbb6f   Al Viro   kernel/*: switch ...
3028
  					p++;
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3029
3030
3031
  					left--;
  				}
  			}
5a04cca6c   Akinobu Mita   sysctl: use bitma...
3032
  			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3033
  			first = 0;
70f6cbb6f   Al Viro   kernel/*: switch ...
3034
3035
  			proc_skip_char(&p, &left, '
  ');
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3036
  		}
70f6cbb6f   Al Viro   kernel/*: switch ...
3037
  		kfree(kbuf);
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
  	} else {
  		unsigned long bit_a, bit_b = 0;
  
  		while (left) {
  			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
  			if (bit_a >= bitmap_len)
  				break;
  			bit_b = find_next_zero_bit(bitmap, bitmap_len,
  						   bit_a + 1) - 1;
  
  			if (!first) {
  				err = proc_put_char(&buffer, &left, ',');
  				if (err)
  					break;
  			}
  			err = proc_put_long(&buffer, &left, bit_a, false);
  			if (err)
  				break;
  			if (bit_a != bit_b) {
  				err = proc_put_char(&buffer, &left, '-');
  				if (err)
  					break;
  				err = proc_put_long(&buffer, &left, bit_b, false);
  				if (err)
  					break;
  			}
  
  			first = 0; bit_b++;
  		}
  		if (!err)
  			err = proc_put_char(&buffer, &left, '
  ');
  	}
  
  	if (!err) {
  		if (write) {
  			if (*ppos)
  				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
  			else
5a04cca6c   Akinobu Mita   sysctl: use bitma...
3077
  				bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3078
  		}
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3079
3080
  		*lenp -= left;
  		*ppos += *lenp;
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3081
  	}
f9eb2fdd0   Ola N. Kaldestad   kernel/sysctl.c: ...
3082
3083
3084
  
  	kfree(tmp_bitmap);
  	return err;
9f977fb7a   Octavian Purdila   sysctl: add proc_...
3085
  }
556105000   Jovi Zhang   sysctl: fix #ifde...
3086
  #else /* CONFIG_PROC_SYSCTL */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3087

8d65af789   Alexey Dobriyan   sysctl: remove "s...
3088
  int proc_dostring(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3089
3090
3091
3092
  		  void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
3093
  int proc_dointvec(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3094
  		  void __user *buffer, size_t *lenp, loff_t *ppos)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3095
3096
3097
  {
  	return -ENOSYS;
  }
e7d316a02   Subash Abhinov Kasiviswanathan   sysctl: handle er...
3098
3099
3100
3101
3102
  int proc_douintvec(struct ctl_table *table, int write,
  		  void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
3103
  int proc_dointvec_minmax(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3104
3105
3106
3107
  		    void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
61d9b56a8   Luis R. Rodriguez   sysctl: add unsig...
3108
3109
3110
3111
3112
  int proc_douintvec_minmax(struct ctl_table *table, int write,
  			  void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
7a8d18194   Joe Lawrence   pipe: add proc_do...
3113
3114
3115
3116
3117
  int proc_dopipe_max_size(struct ctl_table *table, int write,
  			 void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
3118
  int proc_dointvec_jiffies(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3119
3120
3121
3122
  		    void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
3123
  int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3124
3125
3126
3127
  		    void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
3128
  int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3129
3130
3131
3132
  			     void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
8d65af789   Alexey Dobriyan   sysctl: remove "s...
3133
  int proc_doulongvec_minmax(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3134
3135
3136
3137
  		    void __user *buffer, size_t *lenp, loff_t *ppos)
  {
  	return -ENOSYS;
  }
d8217f076   Eric W. Biederman   sysctl core: Stop...
3138
  int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3139
3140
3141
3142
3143
  				      void __user *buffer,
  				      size_t *lenp, loff_t *ppos)
  {
      return -ENOSYS;
  }
556105000   Jovi Zhang   sysctl: fix #ifde...
3144
  #endif /* CONFIG_PROC_SYSCTL */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3145

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3146
3147
3148
3149
3150
  /*
   * No sense putting this after each symbol definition, twice,
   * exception granted :-)
   */
  EXPORT_SYMBOL(proc_dointvec);
e7d316a02   Subash Abhinov Kasiviswanathan   sysctl: handle er...
3151
  EXPORT_SYMBOL(proc_douintvec);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3152
3153
  EXPORT_SYMBOL(proc_dointvec_jiffies);
  EXPORT_SYMBOL(proc_dointvec_minmax);
61d9b56a8   Luis R. Rodriguez   sysctl: add unsig...
3154
  EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
7a8d18194   Joe Lawrence   pipe: add proc_do...
3155
  EXPORT_SYMBOL_GPL(proc_dopipe_max_size);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3156
3157
3158
3159
3160
  EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  EXPORT_SYMBOL(proc_dostring);
  EXPORT_SYMBOL(proc_doulongvec_minmax);
  EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);