aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2009-03-25 15:48:06 -0400
committerAlexey Dobriyan <adobriyan@gmail.com>2009-03-30 17:14:44 -0400
commit99b76233803beab302123d243eea9e41149804f3 (patch)
tree398178210fe66845ccd6fa4258ba762a87e023ad /net
parent3dec7f59c370c7b58184d63293c3dc984d475840 (diff)
proc 2/2: remove struct proc_dir_entry::owner
Setting ->owner as done currently (pde->owner = THIS_MODULE) is racy as correctly noted at bug #12454. Someone can lookup entry with NULL ->owner, thus not pinning enything, and release it later resulting in module refcount underflow. We can keep ->owner and supply it at registration time like ->proc_fops and ->data. But this leaves ->owner as easy-manipulative field (just one C assignment) and somebody will forget to unpin previous/pin current module when switching ->owner. ->proc_fops is declared as "const" which should give some thoughts. ->read_proc/->write_proc were just fixed to not require ->owner for protection. rmmod'ed directories will be empty and return "." and ".." -- no harm. And directories with tricky enough readdir and lookup shouldn't be modular. We definitely don't want such modular code. Removing ->owner will also make PDE smaller. So, let's nuke it. Kudos to Jeff Layton for reminding about this, let's say, oversight. http://bugzilla.kernel.org/show_bug.cgi?id=12454 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Diffstat (limited to 'net')
-rw-r--r--net/appletalk/atalk_proc.c1
-rw-r--r--net/atm/mpoa_proc.c1
-rw-r--r--net/atm/proc.c1
-rw-r--r--net/can/bcm.c4
-rw-r--r--net/can/proc.c2
-rw-r--r--net/core/pktgen.c1
-rw-r--r--net/irda/irproc.c1
-rw-r--r--net/llc/llc_proc.c1
-rw-r--r--net/sctp/protocol.c8
-rw-r--r--net/sunrpc/cache.c4
-rw-r--r--net/sunrpc/stats.c10
11 files changed, 4 insertions, 30 deletions
diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
index 162199a2d74f..fd8e0847b254 100644
--- a/net/appletalk/atalk_proc.c
+++ b/net/appletalk/atalk_proc.c
@@ -281,7 +281,6 @@ int __init atalk_proc_init(void)
281 atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net); 281 atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net);
282 if (!atalk_proc_dir) 282 if (!atalk_proc_dir)
283 goto out; 283 goto out;
284 atalk_proc_dir->owner = THIS_MODULE;
285 284
286 p = proc_create("interface", S_IRUGO, atalk_proc_dir, 285 p = proc_create("interface", S_IRUGO, atalk_proc_dir,
287 &atalk_seq_interface_fops); 286 &atalk_seq_interface_fops);
diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 4990541ef5da..1a0f5ccea9c4 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -281,7 +281,6 @@ int mpc_proc_init(void)
281 printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME); 281 printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);
282 return -ENOMEM; 282 return -ENOMEM;
283 } 283 }
284 p->owner = THIS_MODULE;
285 return 0; 284 return 0;
286} 285}
287 286
diff --git a/net/atm/proc.c b/net/atm/proc.c
index 49487b313f22..e7b3b273907d 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -476,7 +476,6 @@ int __init atm_proc_init(void)
476 atm_proc_root, e->proc_fops); 476 atm_proc_root, e->proc_fops);
477 if (!dirent) 477 if (!dirent)
478 goto err_out_remove; 478 goto err_out_remove;
479 dirent->owner = THIS_MODULE;
480 e->dirent = dirent; 479 e->dirent = dirent;
481 } 480 }
482 ret = 0; 481 ret = 0;
diff --git a/net/can/bcm.c b/net/can/bcm.c
index b7c7d4651136..95d7f32643ae 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -1604,10 +1604,6 @@ static int __init bcm_module_init(void)
1604 1604
1605 /* create /proc/net/can-bcm directory */ 1605 /* create /proc/net/can-bcm directory */
1606 proc_dir = proc_mkdir("can-bcm", init_net.proc_net); 1606 proc_dir = proc_mkdir("can-bcm", init_net.proc_net);
1607
1608 if (proc_dir)
1609 proc_dir->owner = THIS_MODULE;
1610
1611 return 0; 1607 return 0;
1612} 1608}
1613 1609
diff --git a/net/can/proc.c b/net/can/proc.c
index 520fef5e5398..1463653dbe34 100644
--- a/net/can/proc.c
+++ b/net/can/proc.c
@@ -473,8 +473,6 @@ void can_init_proc(void)
473 return; 473 return;
474 } 474 }
475 475
476 can_dir->owner = THIS_MODULE;
477
478 /* own procfs entries from the AF_CAN core */ 476 /* own procfs entries from the AF_CAN core */
479 pde_version = can_create_proc_readentry(CAN_PROC_VERSION, 0644, 477 pde_version = can_create_proc_readentry(CAN_PROC_VERSION, 0644,
480 can_proc_read_version, NULL); 478 can_proc_read_version, NULL);
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 32d419f5ac98..3779c1438c11 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3806,7 +3806,6 @@ static int __init pg_init(void)
3806 pg_proc_dir = proc_mkdir(PG_PROC_DIR, init_net.proc_net); 3806 pg_proc_dir = proc_mkdir(PG_PROC_DIR, init_net.proc_net);
3807 if (!pg_proc_dir) 3807 if (!pg_proc_dir)
3808 return -ENODEV; 3808 return -ENODEV;
3809 pg_proc_dir->owner = THIS_MODULE;
3810 3809
3811 pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops); 3810 pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops);
3812 if (pe == NULL) { 3811 if (pe == NULL) {
diff --git a/net/irda/irproc.c b/net/irda/irproc.c
index 88e80a312732..8ff1861649e8 100644
--- a/net/irda/irproc.c
+++ b/net/irda/irproc.c
@@ -70,7 +70,6 @@ void __init irda_proc_register(void)
70 proc_irda = proc_mkdir("irda", init_net.proc_net); 70 proc_irda = proc_mkdir("irda", init_net.proc_net);
71 if (proc_irda == NULL) 71 if (proc_irda == NULL)
72 return; 72 return;
73 proc_irda->owner = THIS_MODULE;
74 73
75 for (i = 0; i < ARRAY_SIZE(irda_dirs); i++) 74 for (i = 0; i < ARRAY_SIZE(irda_dirs); i++)
76 d = proc_create(irda_dirs[i].name, 0, proc_irda, 75 d = proc_create(irda_dirs[i].name, 0, proc_irda,
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
index b58bd7c6cdf8..d208b3396d94 100644
--- a/net/llc/llc_proc.c
+++ b/net/llc/llc_proc.c
@@ -236,7 +236,6 @@ int __init llc_proc_init(void)
236 llc_proc_dir = proc_mkdir("llc", init_net.proc_net); 236 llc_proc_dir = proc_mkdir("llc", init_net.proc_net);
237 if (!llc_proc_dir) 237 if (!llc_proc_dir)
238 goto out; 238 goto out;
239 llc_proc_dir->owner = THIS_MODULE;
240 239
241 p = proc_create("socket", S_IRUGO, llc_proc_dir, &llc_seq_socket_fops); 240 p = proc_create("socket", S_IRUGO, llc_proc_dir, &llc_seq_socket_fops);
242 if (!p) 241 if (!p)
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index cb198af8887c..8eb3e61cb701 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -106,12 +106,8 @@ static __init int sctp_proc_init(void)
106 goto out_nomem; 106 goto out_nomem;
107#ifdef CONFIG_PROC_FS 107#ifdef CONFIG_PROC_FS
108 if (!proc_net_sctp) { 108 if (!proc_net_sctp) {
109 struct proc_dir_entry *ent; 109 proc_net_sctp = proc_mkdir("sctp", init_net.proc_net);
110 ent = proc_mkdir("sctp", init_net.proc_net); 110 if (!proc_net_sctp)
111 if (ent) {
112 ent->owner = THIS_MODULE;
113 proc_net_sctp = ent;
114 } else
115 goto out_free_percpu; 111 goto out_free_percpu;
116 } 112 }
117 113
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 4735caad26ed..20029a79a5de 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -313,7 +313,6 @@ static int create_cache_proc_entries(struct cache_detail *cd)
313 cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc); 313 cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc);
314 if (cd->proc_ent == NULL) 314 if (cd->proc_ent == NULL)
315 goto out_nomem; 315 goto out_nomem;
316 cd->proc_ent->owner = cd->owner;
317 cd->channel_ent = cd->content_ent = NULL; 316 cd->channel_ent = cd->content_ent = NULL;
318 317
319 p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR, 318 p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR,
@@ -321,7 +320,6 @@ static int create_cache_proc_entries(struct cache_detail *cd)
321 cd->flush_ent = p; 320 cd->flush_ent = p;
322 if (p == NULL) 321 if (p == NULL)
323 goto out_nomem; 322 goto out_nomem;
324 p->owner = cd->owner;
325 323
326 if (cd->cache_request || cd->cache_parse) { 324 if (cd->cache_request || cd->cache_parse) {
327 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, 325 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
@@ -329,7 +327,6 @@ static int create_cache_proc_entries(struct cache_detail *cd)
329 cd->channel_ent = p; 327 cd->channel_ent = p;
330 if (p == NULL) 328 if (p == NULL)
331 goto out_nomem; 329 goto out_nomem;
332 p->owner = cd->owner;
333 } 330 }
334 if (cd->cache_show) { 331 if (cd->cache_show) {
335 p = proc_create_data("content", S_IFREG|S_IRUSR|S_IWUSR, 332 p = proc_create_data("content", S_IFREG|S_IRUSR|S_IWUSR,
@@ -337,7 +334,6 @@ static int create_cache_proc_entries(struct cache_detail *cd)
337 cd->content_ent = p; 334 cd->content_ent = p;
338 if (p == NULL) 335 if (p == NULL)
339 goto out_nomem; 336 goto out_nomem;
340 p->owner = cd->owner;
341 } 337 }
342 return 0; 338 return 0;
343out_nomem: 339out_nomem:
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c
index 085372ef4feb..1ef6e46d9da2 100644
--- a/net/sunrpc/stats.c
+++ b/net/sunrpc/stats.c
@@ -262,14 +262,8 @@ void
262rpc_proc_init(void) 262rpc_proc_init(void)
263{ 263{
264 dprintk("RPC: registering /proc/net/rpc\n"); 264 dprintk("RPC: registering /proc/net/rpc\n");
265 if (!proc_net_rpc) { 265 if (!proc_net_rpc)
266 struct proc_dir_entry *ent; 266 proc_net_rpc = proc_mkdir("rpc", init_net.proc_net);
267 ent = proc_mkdir("rpc", init_net.proc_net);
268 if (ent) {
269 ent->owner = THIS_MODULE;
270 proc_net_rpc = ent;
271 }
272 }
273} 267}
274 268
275void 269void