aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@hq.newdream.net>2010-07-02 23:07:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-07-04 23:17:22 -0400
commitff49d74ad383f54041378144ca1a229ee9aeaa59 (patch)
tree6f37335e313c9a680db8d4e4ce00d17aa11a099b /kernel
parente3668dd83ba5958429984286efbc3055be5344c4 (diff)
module: initialize module dynamic debug later
We should initialize the module dynamic debug datastructures only after determining that the module is not loaded yet. This fixes a bug that introduced in 2.6.35-rc2, where when a trying to load a module twice, we also load it's dynamic printing data twice which causes all sorts of nasty issues. Also handle the dynamic debug cleanup later on failure. Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (removed a #ifdef) Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 8c6b42840dd1..5d2d28197c82 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2062,6 +2062,12 @@ static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num)
2062#endif 2062#endif
2063} 2063}
2064 2064
2065static void dynamic_debug_remove(struct _ddebug *debug)
2066{
2067 if (debug)
2068 ddebug_remove_module(debug->modname);
2069}
2070
2065static void *module_alloc_update_bounds(unsigned long size) 2071static void *module_alloc_update_bounds(unsigned long size)
2066{ 2072{
2067 void *ret = module_alloc(size); 2073 void *ret = module_alloc(size);
@@ -2124,6 +2130,8 @@ static noinline struct module *load_module(void __user *umod,
2124 void *ptr = NULL; /* Stops spurious gcc warning */ 2130 void *ptr = NULL; /* Stops spurious gcc warning */
2125 unsigned long symoffs, stroffs, *strmap; 2131 unsigned long symoffs, stroffs, *strmap;
2126 void __percpu *percpu; 2132 void __percpu *percpu;
2133 struct _ddebug *debug = NULL;
2134 unsigned int num_debug = 0;
2127 2135
2128 mm_segment_t old_fs; 2136 mm_segment_t old_fs;
2129 2137
@@ -2476,15 +2484,9 @@ static noinline struct module *load_module(void __user *umod,
2476 kfree(strmap); 2484 kfree(strmap);
2477 strmap = NULL; 2485 strmap = NULL;
2478 2486
2479 if (!mod->taints) { 2487 if (!mod->taints)
2480 struct _ddebug *debug;
2481 unsigned int num_debug;
2482
2483 debug = section_objs(hdr, sechdrs, secstrings, "__verbose", 2488 debug = section_objs(hdr, sechdrs, secstrings, "__verbose",
2484 sizeof(*debug), &num_debug); 2489 sizeof(*debug), &num_debug);
2485 if (debug)
2486 dynamic_debug_setup(debug, num_debug);
2487 }
2488 2490
2489 err = module_finalize(hdr, sechdrs, mod); 2491 err = module_finalize(hdr, sechdrs, mod);
2490 if (err < 0) 2492 if (err < 0)
@@ -2526,10 +2528,13 @@ static noinline struct module *load_module(void __user *umod,
2526 goto unlock; 2528 goto unlock;
2527 } 2529 }
2528 2530
2531 if (debug)
2532 dynamic_debug_setup(debug, num_debug);
2533
2529 /* Find duplicate symbols */ 2534 /* Find duplicate symbols */
2530 err = verify_export_symbols(mod); 2535 err = verify_export_symbols(mod);
2531 if (err < 0) 2536 if (err < 0)
2532 goto unlock; 2537 goto ddebug;
2533 2538
2534 list_add_rcu(&mod->list, &modules); 2539 list_add_rcu(&mod->list, &modules);
2535 mutex_unlock(&module_mutex); 2540 mutex_unlock(&module_mutex);
@@ -2557,6 +2562,8 @@ static noinline struct module *load_module(void __user *umod,
2557 mutex_lock(&module_mutex); 2562 mutex_lock(&module_mutex);
2558 /* Unlink carefully: kallsyms could be walking list. */ 2563 /* Unlink carefully: kallsyms could be walking list. */
2559 list_del_rcu(&mod->list); 2564 list_del_rcu(&mod->list);
2565 ddebug:
2566 dynamic_debug_remove(debug);
2560 unlock: 2567 unlock:
2561 mutex_unlock(&module_mutex); 2568 mutex_unlock(&module_mutex);
2562 synchronize_sched(); 2569 synchronize_sched();