3 @@ -2620,6 +2620,8 @@ static const struct file_operations proc
5 static int __init proc_locks_init(void)
7 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
9 proc_create("locks", 0, NULL, &proc_locks_operations);
14 @@ -71,3 +71,8 @@ config PROC_PAGE_MONITOR
15 /proc/pid/smaps, /proc/pid/clear_refs, /proc/pid/pagemap,
16 /proc/kpagecount, and /proc/kpageflags. Disabling these
17 interfaces will reduce the size of the kernel by approximately 4kb.
22 + bool "Strip non-essential /proc functionality to reduce code size"
23 --- a/fs/proc/consoles.c
24 +++ b/fs/proc/consoles.c
25 @@ -106,6 +106,9 @@ static const struct file_operations proc
27 static int __init proc_consoles_init(void)
29 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
32 proc_create("consoles", 0, NULL, &proc_consoles_operations);
35 --- a/fs/proc/proc_tty.c
36 +++ b/fs/proc/proc_tty.c
37 @@ -144,7 +144,10 @@ static const struct file_operations proc
38 void proc_tty_register_driver(struct tty_driver *driver)
40 struct proc_dir_entry *ent;
43 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
46 if (!driver->driver_name || driver->proc_entry ||
47 !driver->ops->proc_fops)
49 @@ -161,6 +164,9 @@ void proc_tty_unregister_driver(struct t
51 struct proc_dir_entry *ent;
53 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
56 ent = driver->proc_entry;
59 @@ -175,6 +181,9 @@ void proc_tty_unregister_driver(struct t
61 void __init proc_tty_init(void)
63 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
66 if (!proc_mkdir("tty", NULL))
68 proc_mkdir("tty/ldisc", NULL); /* Preserved: it's userspace visible */
69 --- a/kernel/exec_domain.c
70 +++ b/kernel/exec_domain.c
71 @@ -176,6 +176,8 @@ static const struct file_operations exec
73 static int __init proc_execdomains_init(void)
75 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
77 proc_create("execdomains", 0, NULL, &execdomains_proc_fops);
80 --- a/kernel/irq/proc.c
81 +++ b/kernel/irq/proc.c
82 @@ -330,6 +330,9 @@ void register_irq_proc(unsigned int irq,
83 static DEFINE_MUTEX(register_lock);
84 char name [MAX_NAMELEN];
86 + if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP))
89 if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip))
92 @@ -379,6 +382,9 @@ void unregister_irq_proc(unsigned int ir
94 char name [MAX_NAMELEN];
96 + if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP))
99 if (!root_irq_dir || !desc->dir)
102 @@ -414,6 +420,9 @@ void init_irq_proc(void)
104 struct irq_desc *desc;
106 + if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP))
109 /* create /proc/irq */
110 root_irq_dir = proc_mkdir("irq", NULL);
112 --- a/kernel/time/timer_list.c
113 +++ b/kernel/time/timer_list.c
114 @@ -362,6 +362,9 @@ static int __init init_timer_list_procfs
116 struct proc_dir_entry *pe;
118 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
121 pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
126 @@ -2663,6 +2663,8 @@ static const struct file_operations proc
128 static int __init proc_vmalloc_init(void)
130 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
132 proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
137 @@ -1424,10 +1424,12 @@ static int __init setup_vmstat(void)
138 cpu_notifier_register_done();
140 #ifdef CONFIG_PROC_FS
141 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
142 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
143 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) {
144 + proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
145 + proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
146 + proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
148 proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
149 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
153 --- a/net/8021q/vlanproc.c
154 +++ b/net/8021q/vlanproc.c
155 @@ -127,6 +127,9 @@ void vlan_proc_cleanup(struct net *net)
157 struct vlan_net *vn = net_generic(net, vlan_net_id);
159 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
162 if (vn->proc_vlan_conf)
163 remove_proc_entry(name_conf, vn->proc_vlan_dir);
165 @@ -146,6 +149,9 @@ int __net_init vlan_proc_init(struct net
167 struct vlan_net *vn = net_generic(net, vlan_net_id);
169 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
172 vn->proc_vlan_dir = proc_net_mkdir(net, name_root, net->proc_net);
173 if (!vn->proc_vlan_dir)
175 --- a/net/core/sock.c
176 +++ b/net/core/sock.c
177 @@ -2945,6 +2945,8 @@ static __net_initdata struct pernet_oper
179 static int __init proto_init(void)
181 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
183 return register_pernet_subsys(&proto_net_ops);
186 --- a/net/ipv4/fib_trie.c
187 +++ b/net/ipv4/fib_trie.c
188 @@ -2490,10 +2490,12 @@ static const struct file_operations fib_
190 int __net_init fib_proc_init(struct net *net)
192 - if (!proc_create("fib_trie", S_IRUGO, net->proc_net, &fib_trie_fops))
193 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED) &&
194 + !proc_create("fib_trie", S_IRUGO, net->proc_net, &fib_trie_fops))
197 - if (!proc_create("fib_triestat", S_IRUGO, net->proc_net,
198 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED) &&
199 + !proc_create("fib_triestat", S_IRUGO, net->proc_net,
203 @@ -2503,17 +2505,21 @@ int __net_init fib_proc_init(struct net
207 - remove_proc_entry("fib_triestat", net->proc_net);
208 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED))
209 + remove_proc_entry("fib_triestat", net->proc_net);
211 - remove_proc_entry("fib_trie", net->proc_net);
212 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED))
213 + remove_proc_entry("fib_trie", net->proc_net);
218 void __net_exit fib_proc_exit(struct net *net)
220 - remove_proc_entry("fib_trie", net->proc_net);
221 - remove_proc_entry("fib_triestat", net->proc_net);
222 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) {
223 + remove_proc_entry("fib_trie", net->proc_net);
224 + remove_proc_entry("fib_triestat", net->proc_net);
226 remove_proc_entry("route", net->proc_net);
229 --- a/net/ipv4/proc.c
230 +++ b/net/ipv4/proc.c
231 @@ -524,6 +524,9 @@ static __net_initdata struct pernet_oper
233 int __init ip_misc_proc_init(void)
235 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
238 return register_pernet_subsys(&ip_proc_ops);
241 --- a/net/ipv4/route.c
242 +++ b/net/ipv4/route.c
243 @@ -418,6 +418,9 @@ static struct pernet_operations ip_rt_pr
245 static int __init ip_rt_proc_init(void)
247 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
250 return register_pernet_subsys(&ip_rt_proc_ops);
255 @@ -1075,6 +1075,9 @@ void __init msg_init(void)
256 printk(KERN_INFO "msgmni has been set to %d\n",
257 init_ipc_ns.msg_ctlmni);
259 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
262 ipc_init_proc_interface("sysvipc/msg",
263 " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n",
264 IPC_MSG_IDS, sysvipc_msg_proc_show);
267 @@ -191,6 +191,8 @@ void sem_exit_ns(struct ipc_namespace *n
268 void __init sem_init(void)
270 sem_init_ns(&init_ipc_ns);
271 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
273 ipc_init_proc_interface("sysvipc/sem",
274 " key semid perms nsems uid gid cuid cgid otime ctime\n",
275 IPC_SEM_IDS, sysvipc_sem_proc_show);
278 @@ -118,6 +118,8 @@ pure_initcall(ipc_ns_init);
280 void __init shm_init(void)
282 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
284 ipc_init_proc_interface("sysvipc/shm",
285 #if BITS_PER_LONG <= 32
286 " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n",
289 @@ -161,6 +161,9 @@ void __init ipc_init_proc_interface(cons
290 struct proc_dir_entry *pde;
291 struct ipc_proc_iface *iface;
293 + if (IS_ENABLED(CONFIG_PROC_STRIPPED))
296 iface = kmalloc(sizeof(*iface), GFP_KERNEL);
299 --- a/net/core/net-procfs.c
300 +++ b/net/core/net-procfs.c
301 @@ -318,10 +318,12 @@ static int __net_init dev_proc_net_init(
303 if (!proc_create("dev", S_IRUGO, net->proc_net, &dev_seq_fops))
305 - if (!proc_create("softnet_stat", S_IRUGO, net->proc_net,
306 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED) &&
307 + !proc_create("softnet_stat", S_IRUGO, net->proc_net,
310 - if (!proc_create("ptype", S_IRUGO, net->proc_net, &ptype_seq_fops))
311 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED) &&
312 + !proc_create("ptype", S_IRUGO, net->proc_net, &ptype_seq_fops))
315 if (wext_proc_init(net))
316 @@ -330,9 +332,11 @@ static int __net_init dev_proc_net_init(
320 - remove_proc_entry("ptype", net->proc_net);
321 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED))
322 + remove_proc_entry("ptype", net->proc_net);
324 - remove_proc_entry("softnet_stat", net->proc_net);
325 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED))
326 + remove_proc_entry("softnet_stat", net->proc_net);
328 remove_proc_entry("dev", net->proc_net);
330 @@ -342,8 +346,10 @@ static void __net_exit dev_proc_net_exit
334 - remove_proc_entry("ptype", net->proc_net);
335 - remove_proc_entry("softnet_stat", net->proc_net);
336 + if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) {
337 + remove_proc_entry("ptype", net->proc_net);
338 + remove_proc_entry("softnet_stat", net->proc_net);
340 remove_proc_entry("dev", net->proc_net);