diff options
author | Denis V. Lunev <den@openvz.org> | 2008-04-29 04:02:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:22 -0400 |
commit | 667471386d4068e75a6a55b615701ced61eb6333 (patch) | |
tree | 2bf51dfa6209ca6637c1cff084b15c132b280ab0 /arch/powerpc | |
parent | 6f1c86ec315711d21666751b0bdae69ce2c6d589 (diff) |
powerpc: use non-racy method for proc entries creation
Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.
Add correct ->owner to proc_fops to fix reading/module unloading race.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/lparcfg.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/proc_ppc64.c | 5 | ||||
-rw-r--r-- | arch/powerpc/kernel/rtas-proc.c | 45 | ||||
-rw-r--r-- | arch/powerpc/kernel/rtas_flash.c | 13 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/sched.c | 3 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/sputrace.c | 3 | ||||
-rw-r--r-- | arch/powerpc/platforms/iseries/lpevents.c | 8 | ||||
-rw-r--r-- | arch/powerpc/platforms/iseries/mf.c | 6 | ||||
-rw-r--r-- | arch/powerpc/platforms/iseries/proc.c | 8 | ||||
-rw-r--r-- | arch/powerpc/platforms/iseries/viopath.c | 7 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/eeh.c | 10 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/reconfig.c | 7 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/rtasd.c | 7 |
13 files changed, 39 insertions, 89 deletions
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c index 1ffacc698ffb..1e656b43ad7f 100644 --- a/arch/powerpc/kernel/lparcfg.c +++ b/arch/powerpc/kernel/lparcfg.c | |||
@@ -591,10 +591,8 @@ int __init lparcfg_init(void) | |||
591 | !firmware_has_feature(FW_FEATURE_ISERIES)) | 591 | !firmware_has_feature(FW_FEATURE_ISERIES)) |
592 | mode |= S_IWUSR; | 592 | mode |= S_IWUSR; |
593 | 593 | ||
594 | ent = create_proc_entry("ppc64/lparcfg", mode, NULL); | 594 | ent = proc_create("ppc64/lparcfg", mode, NULL, &lparcfg_fops); |
595 | if (ent) { | 595 | if (!ent) { |
596 | ent->proc_fops = &lparcfg_fops; | ||
597 | } else { | ||
598 | printk(KERN_ERR "Failed to create ppc64/lparcfg\n"); | 596 | printk(KERN_ERR "Failed to create ppc64/lparcfg\n"); |
599 | return -EIO; | 597 | return -EIO; |
600 | } | 598 | } |
diff --git a/arch/powerpc/kernel/proc_ppc64.c b/arch/powerpc/kernel/proc_ppc64.c index f78dfce1b771..c647ddef40dc 100644 --- a/arch/powerpc/kernel/proc_ppc64.c +++ b/arch/powerpc/kernel/proc_ppc64.c | |||
@@ -68,12 +68,11 @@ static int __init proc_ppc64_init(void) | |||
68 | { | 68 | { |
69 | struct proc_dir_entry *pde; | 69 | struct proc_dir_entry *pde; |
70 | 70 | ||
71 | pde = create_proc_entry("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL); | 71 | pde = proc_create_data("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL, |
72 | &page_map_fops, vdso_data); | ||
72 | if (!pde) | 73 | if (!pde) |
73 | return 1; | 74 | return 1; |
74 | pde->data = vdso_data; | ||
75 | pde->size = PAGE_SIZE; | 75 | pde->size = PAGE_SIZE; |
76 | pde->proc_fops = &page_map_fops; | ||
77 | 76 | ||
78 | return 0; | 77 | return 0; |
79 | } | 78 | } |
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c index f2e3bc714d76..f9c6abc84a94 100644 --- a/arch/powerpc/kernel/rtas-proc.c +++ b/arch/powerpc/kernel/rtas-proc.c | |||
@@ -255,8 +255,6 @@ static void check_location(struct seq_file *m, const char *c); | |||
255 | 255 | ||
256 | static int __init proc_rtas_init(void) | 256 | static int __init proc_rtas_init(void) |
257 | { | 257 | { |
258 | struct proc_dir_entry *entry; | ||
259 | |||
260 | if (!machine_is(pseries)) | 258 | if (!machine_is(pseries)) |
261 | return -ENODEV; | 259 | return -ENODEV; |
262 | 260 | ||
@@ -264,35 +262,20 @@ static int __init proc_rtas_init(void) | |||
264 | if (rtas_node == NULL) | 262 | if (rtas_node == NULL) |
265 | return -ENODEV; | 263 | return -ENODEV; |
266 | 264 | ||
267 | entry = create_proc_entry("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL); | 265 | proc_create("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL, |
268 | if (entry) | 266 | &ppc_rtas_progress_operations); |
269 | entry->proc_fops = &ppc_rtas_progress_operations; | 267 | proc_create("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL, |
270 | 268 | &ppc_rtas_clock_operations); | |
271 | entry = create_proc_entry("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL); | 269 | proc_create("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL, |
272 | if (entry) | 270 | &ppc_rtas_poweron_operations); |
273 | entry->proc_fops = &ppc_rtas_clock_operations; | 271 | proc_create("ppc64/rtas/sensors", S_IRUGO, NULL, |
274 | 272 | &ppc_rtas_sensors_operations); | |
275 | entry = create_proc_entry("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL); | 273 | proc_create("ppc64/rtas/frequency", S_IWUSR|S_IRUGO, NULL, |
276 | if (entry) | 274 | &ppc_rtas_tone_freq_operations); |
277 | entry->proc_fops = &ppc_rtas_poweron_operations; | 275 | proc_create("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL, |
278 | 276 | &ppc_rtas_tone_volume_operations); | |
279 | entry = create_proc_entry("ppc64/rtas/sensors", S_IRUGO, NULL); | 277 | proc_create("ppc64/rtas/rmo_buffer", S_IRUSR, NULL, |
280 | if (entry) | 278 | &ppc_rtas_rmo_buf_ops); |
281 | entry->proc_fops = &ppc_rtas_sensors_operations; | ||
282 | |||
283 | entry = create_proc_entry("ppc64/rtas/frequency", S_IWUSR|S_IRUGO, | ||
284 | NULL); | ||
285 | if (entry) | ||
286 | entry->proc_fops = &ppc_rtas_tone_freq_operations; | ||
287 | |||
288 | entry = create_proc_entry("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL); | ||
289 | if (entry) | ||
290 | entry->proc_fops = &ppc_rtas_tone_volume_operations; | ||
291 | |||
292 | entry = create_proc_entry("ppc64/rtas/rmo_buffer", S_IRUSR, NULL); | ||
293 | if (entry) | ||
294 | entry->proc_fops = &ppc_rtas_rmo_buf_ops; | ||
295 | |||
296 | return 0; | 279 | return 0; |
297 | } | 280 | } |
298 | 281 | ||
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c index 627f126d1848..0a5e22b22729 100644 --- a/arch/powerpc/kernel/rtas_flash.c +++ b/arch/powerpc/kernel/rtas_flash.c | |||
@@ -704,18 +704,11 @@ static int initialize_flash_pde_data(const char *rtas_call_name, | |||
704 | static struct proc_dir_entry *create_flash_pde(const char *filename, | 704 | static struct proc_dir_entry *create_flash_pde(const char *filename, |
705 | const struct file_operations *fops) | 705 | const struct file_operations *fops) |
706 | { | 706 | { |
707 | struct proc_dir_entry *ent = NULL; | 707 | return proc_create(filename, S_IRUSR | S_IWUSR, NULL, fops); |
708 | |||
709 | ent = create_proc_entry(filename, S_IRUSR | S_IWUSR, NULL); | ||
710 | if (ent != NULL) { | ||
711 | ent->proc_fops = fops; | ||
712 | ent->owner = THIS_MODULE; | ||
713 | } | ||
714 | |||
715 | return ent; | ||
716 | } | 708 | } |
717 | 709 | ||
718 | static const struct file_operations rtas_flash_operations = { | 710 | static const struct file_operations rtas_flash_operations = { |
711 | .owner = THIS_MODULE, | ||
719 | .read = rtas_flash_read, | 712 | .read = rtas_flash_read, |
720 | .write = rtas_flash_write, | 713 | .write = rtas_flash_write, |
721 | .open = rtas_excl_open, | 714 | .open = rtas_excl_open, |
@@ -723,6 +716,7 @@ static const struct file_operations rtas_flash_operations = { | |||
723 | }; | 716 | }; |
724 | 717 | ||
725 | static const struct file_operations manage_flash_operations = { | 718 | static const struct file_operations manage_flash_operations = { |
719 | .owner = THIS_MODULE, | ||
726 | .read = manage_flash_read, | 720 | .read = manage_flash_read, |
727 | .write = manage_flash_write, | 721 | .write = manage_flash_write, |
728 | .open = rtas_excl_open, | 722 | .open = rtas_excl_open, |
@@ -730,6 +724,7 @@ static const struct file_operations manage_flash_operations = { | |||
730 | }; | 724 | }; |
731 | 725 | ||
732 | static const struct file_operations validate_flash_operations = { | 726 | static const struct file_operations validate_flash_operations = { |
727 | .owner = THIS_MODULE, | ||
733 | .read = validate_flash_read, | 728 | .read = validate_flash_read, |
734 | .write = validate_flash_write, | 729 | .write = validate_flash_write, |
735 | .open = rtas_excl_open, | 730 | .open = rtas_excl_open, |
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c index 00528ef84ad2..45dcd2693502 100644 --- a/arch/powerpc/platforms/cell/spufs/sched.c +++ b/arch/powerpc/platforms/cell/spufs/sched.c | |||
@@ -1063,10 +1063,9 @@ int __init spu_sched_init(void) | |||
1063 | 1063 | ||
1064 | mod_timer(&spuloadavg_timer, 0); | 1064 | mod_timer(&spuloadavg_timer, 0); |
1065 | 1065 | ||
1066 | entry = create_proc_entry("spu_loadavg", 0, NULL); | 1066 | entry = proc_create("spu_loadavg", 0, NULL, &spu_loadavg_fops); |
1067 | if (!entry) | 1067 | if (!entry) |
1068 | goto out_stop_kthread; | 1068 | goto out_stop_kthread; |
1069 | entry->proc_fops = &spu_loadavg_fops; | ||
1070 | 1069 | ||
1071 | pr_debug("spusched: tick: %d, min ticks: %d, default ticks: %d\n", | 1070 | pr_debug("spusched: tick: %d, min ticks: %d, default ticks: %d\n", |
1072 | SPUSCHED_TICK, MIN_SPU_TIMESLICE, DEF_SPU_TIMESLICE); | 1071 | SPUSCHED_TICK, MIN_SPU_TIMESLICE, DEF_SPU_TIMESLICE); |
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.c b/arch/powerpc/platforms/cell/spufs/sputrace.c index 79aa773f3c99..aea5286f1245 100644 --- a/arch/powerpc/platforms/cell/spufs/sputrace.c +++ b/arch/powerpc/platforms/cell/spufs/sputrace.c | |||
@@ -201,10 +201,9 @@ static int __init sputrace_init(void) | |||
201 | if (!sputrace_log) | 201 | if (!sputrace_log) |
202 | goto out; | 202 | goto out; |
203 | 203 | ||
204 | entry = create_proc_entry("sputrace", S_IRUSR, NULL); | 204 | entry = proc_create("sputrace", S_IRUSR, NULL, &sputrace_fops); |
205 | if (!entry) | 205 | if (!entry) |
206 | goto out_free_log; | 206 | goto out_free_log; |
207 | entry->proc_fops = &sputrace_fops; | ||
208 | 207 | ||
209 | for (i = 0; i < ARRAY_SIZE(spu_probes); i++) { | 208 | for (i = 0; i < ARRAY_SIZE(spu_probes); i++) { |
210 | struct spu_probe *p = &spu_probes[i]; | 209 | struct spu_probe *p = &spu_probes[i]; |
diff --git a/arch/powerpc/platforms/iseries/lpevents.c b/arch/powerpc/platforms/iseries/lpevents.c index e5b40e3e0082..b0f8a857ec02 100644 --- a/arch/powerpc/platforms/iseries/lpevents.c +++ b/arch/powerpc/platforms/iseries/lpevents.c | |||
@@ -330,15 +330,11 @@ static const struct file_operations proc_lpevents_operations = { | |||
330 | 330 | ||
331 | static int __init proc_lpevents_init(void) | 331 | static int __init proc_lpevents_init(void) |
332 | { | 332 | { |
333 | struct proc_dir_entry *e; | ||
334 | |||
335 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) | 333 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) |
336 | return 0; | 334 | return 0; |
337 | 335 | ||
338 | e = create_proc_entry("iSeries/lpevents", S_IFREG|S_IRUGO, NULL); | 336 | proc_create("iSeries/lpevents", S_IFREG|S_IRUGO, NULL, |
339 | if (e) | 337 | &proc_lpevents_operations); |
340 | e->proc_fops = &proc_lpevents_operations; | ||
341 | |||
342 | return 0; | 338 | return 0; |
343 | } | 339 | } |
344 | __initcall(proc_lpevents_init); | 340 | __initcall(proc_lpevents_init); |
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c index c0f2433bc16e..1dc7295746da 100644 --- a/arch/powerpc/platforms/iseries/mf.c +++ b/arch/powerpc/platforms/iseries/mf.c | |||
@@ -1255,11 +1255,11 @@ static int __init mf_proc_init(void) | |||
1255 | if (i == 3) /* no vmlinux entry for 'D' */ | 1255 | if (i == 3) /* no vmlinux entry for 'D' */ |
1256 | continue; | 1256 | continue; |
1257 | 1257 | ||
1258 | ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf); | 1258 | ent = proc_create_data("vmlinux", S_IFREG|S_IWUSR, mf, |
1259 | &proc_vmlinux_operations, | ||
1260 | (void *)(long)i); | ||
1259 | if (!ent) | 1261 | if (!ent) |
1260 | return 1; | 1262 | return 1; |
1261 | ent->data = (void *)(long)i; | ||
1262 | ent->proc_fops = &proc_vmlinux_operations; | ||
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root); | 1265 | ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root); |
diff --git a/arch/powerpc/platforms/iseries/proc.c b/arch/powerpc/platforms/iseries/proc.c index f2cde4180204..91f4c6cd4b99 100644 --- a/arch/powerpc/platforms/iseries/proc.c +++ b/arch/powerpc/platforms/iseries/proc.c | |||
@@ -110,15 +110,11 @@ static const struct file_operations proc_titantod_operations = { | |||
110 | 110 | ||
111 | static int __init iseries_proc_init(void) | 111 | static int __init iseries_proc_init(void) |
112 | { | 112 | { |
113 | struct proc_dir_entry *e; | ||
114 | |||
115 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) | 113 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) |
116 | return 0; | 114 | return 0; |
117 | 115 | ||
118 | e = create_proc_entry("iSeries/titanTod", S_IFREG|S_IRUGO, NULL); | 116 | proc_create("iSeries/titanTod", S_IFREG|S_IRUGO, NULL, |
119 | if (e) | 117 | &proc_titantod_operations); |
120 | e->proc_fops = &proc_titantod_operations; | ||
121 | |||
122 | return 0; | 118 | return 0; |
123 | } | 119 | } |
124 | __initcall(iseries_proc_init); | 120 | __initcall(iseries_proc_init); |
diff --git a/arch/powerpc/platforms/iseries/viopath.c b/arch/powerpc/platforms/iseries/viopath.c index df23331eb25c..49ff4dc422b7 100644 --- a/arch/powerpc/platforms/iseries/viopath.c +++ b/arch/powerpc/platforms/iseries/viopath.c | |||
@@ -180,15 +180,10 @@ static const struct file_operations proc_viopath_operations = { | |||
180 | 180 | ||
181 | static int __init vio_proc_init(void) | 181 | static int __init vio_proc_init(void) |
182 | { | 182 | { |
183 | struct proc_dir_entry *e; | ||
184 | |||
185 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) | 183 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) |
186 | return 0; | 184 | return 0; |
187 | 185 | ||
188 | e = create_proc_entry("iSeries/config", 0, NULL); | 186 | proc_create("iSeries/config", 0, NULL, &proc_viopath_operations); |
189 | if (e) | ||
190 | e->proc_fops = &proc_viopath_operations; | ||
191 | |||
192 | return 0; | 187 | return 0; |
193 | } | 188 | } |
194 | __initcall(vio_proc_init); | 189 | __initcall(vio_proc_init); |
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c index a3fd56b186e6..6f544ba4b37f 100644 --- a/arch/powerpc/platforms/pseries/eeh.c +++ b/arch/powerpc/platforms/pseries/eeh.c | |||
@@ -1259,14 +1259,8 @@ static const struct file_operations proc_eeh_operations = { | |||
1259 | 1259 | ||
1260 | static int __init eeh_init_proc(void) | 1260 | static int __init eeh_init_proc(void) |
1261 | { | 1261 | { |
1262 | struct proc_dir_entry *e; | 1262 | if (machine_is(pseries)) |
1263 | 1263 | proc_create("ppc64/eeh", 0, NULL, &proc_eeh_operations); | |
1264 | if (machine_is(pseries)) { | ||
1265 | e = create_proc_entry("ppc64/eeh", 0, NULL); | ||
1266 | if (e) | ||
1267 | e->proc_fops = &proc_eeh_operations; | ||
1268 | } | ||
1269 | |||
1270 | return 0; | 1264 | return 0; |
1271 | } | 1265 | } |
1272 | __initcall(eeh_init_proc); | 1266 | __initcall(eeh_init_proc); |
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index ac75c10de278..75769aae41d5 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c | |||
@@ -512,12 +512,9 @@ static int proc_ppc64_create_ofdt(void) | |||
512 | if (!machine_is(pseries)) | 512 | if (!machine_is(pseries)) |
513 | return 0; | 513 | return 0; |
514 | 514 | ||
515 | ent = create_proc_entry("ppc64/ofdt", S_IWUSR, NULL); | 515 | ent = proc_create("ppc64/ofdt", S_IWUSR, NULL, &ofdt_fops); |
516 | if (ent) { | 516 | if (ent) |
517 | ent->data = NULL; | ||
518 | ent->size = 0; | 517 | ent->size = 0; |
519 | ent->proc_fops = &ofdt_fops; | ||
520 | } | ||
521 | 518 | ||
522 | return 0; | 519 | return 0; |
523 | } | 520 | } |
diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c index befadd4f9524..7d3e2b0bd4d2 100644 --- a/arch/powerpc/platforms/pseries/rtasd.c +++ b/arch/powerpc/platforms/pseries/rtasd.c | |||
@@ -468,10 +468,9 @@ static int __init rtas_init(void) | |||
468 | return -ENOMEM; | 468 | return -ENOMEM; |
469 | } | 469 | } |
470 | 470 | ||
471 | entry = create_proc_entry("ppc64/rtas/error_log", S_IRUSR, NULL); | 471 | entry = proc_create("ppc64/rtas/error_log", S_IRUSR, NULL, |
472 | if (entry) | 472 | &proc_rtas_log_operations); |
473 | entry->proc_fops = &proc_rtas_log_operations; | 473 | if (!entry) |
474 | else | ||
475 | printk(KERN_ERR "Failed to create error_log proc entry\n"); | 474 | printk(KERN_ERR "Failed to create error_log proc entry\n"); |
476 | 475 | ||
477 | if (kernel_thread(rtasd, NULL, CLONE_FS) < 0) | 476 | if (kernel_thread(rtasd, NULL, CLONE_FS) < 0) |