aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2004-06-26 20:55:19 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-06-26 20:55:19 -0700
commit969eb7b840c13a73190d98a608b8fec50dc31971 (patch)
treeb0af0354e990cb82bfa1e9ceeaf46ca9be9567e7 /kernel
parent12d9986b3c8acda935906514c593ea806e1736bd (diff)
downloadhistory-969eb7b840c13a73190d98a608b8fec50dc31971.tar.gz
[PATCH] Fix race between CONFIG_DEBUG_SLABALLOC and modules
store_stackinfo() does an unlocked module list walk during normal runtime which opens up a race with the module load/unload code. This can be triggered by simply unloading and loading a module in a loop with CONFIG_DEBUG_PAGEALLOC resulting in store_stackinfo() tripping over bad list pointers. kernel_text_address doesn't take any locks, because during an OOPS we don't want to deadlock. Rename that to __kernel_text_address, and make kernel_text_address take the lock. Signed-off-by: Zwane Mwaikambo <zwane@fsmlabs.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (modified) Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/extable.c15
-rw-r--r--kernel/module.c14
2 files changed, 27 insertions, 2 deletions
diff --git a/kernel/extable.c b/kernel/extable.c
index fbbfbf4fd367c4..7501b531ceedab 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -40,7 +40,7 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr)
return e;
}
-int kernel_text_address(unsigned long addr)
+static int core_kernel_text(unsigned long addr)
{
if (addr >= (unsigned long)_stext &&
addr <= (unsigned long)_etext)
@@ -49,6 +49,19 @@ int kernel_text_address(unsigned long addr)
if (addr >= (unsigned long)_sinittext &&
addr <= (unsigned long)_einittext)
return 1;
+ return 0;
+}
+int __kernel_text_address(unsigned long addr)
+{
+ if (core_kernel_text(addr))
+ return 1;
+ return __module_text_address(addr) != NULL;
+}
+
+int kernel_text_address(unsigned long addr)
+{
+ if (core_kernel_text(addr))
+ return 1;
return module_text_address(addr) != NULL;
}
diff --git a/kernel/module.c b/kernel/module.c
index 71a0944bddb1cf..858b34f4c33b1b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2128,7 +2128,7 @@ const struct exception_table_entry *search_module_extables(unsigned long addr)
}
/* Is this a valid kernel address? We don't grab the lock: we are oopsing. */
-struct module *module_text_address(unsigned long addr)
+struct module *__module_text_address(unsigned long addr)
{
struct module *mod;
@@ -2139,6 +2139,18 @@ struct module *module_text_address(unsigned long addr)
return NULL;
}
+struct module *module_text_address(unsigned long addr)
+{
+ struct module *mod;
+ unsigned long flags;
+
+ spin_lock_irqsave(&modlist_lock, flags);
+ mod = __module_text_address(addr);
+ spin_unlock_irqrestore(&modlist_lock, flags);
+
+ return mod;
+}
+
/* Don't grab lock, we're oopsing. */
void print_modules(void)
{