提交 5e376613 编写于 作者: T Trent Piepho 提交者: Linus Torvalds

[PATCH] symbol_put_addr() locks kernel

Even since a previous patch:

Fix race between CONFIG_DEBUG_SLABALLOC and modules
Sun, 27 Jun 2004 17:55:19 +0000 (17:55 +0000)
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/old-2.6-bkcvs.git;a=commit;h=92b3db26d31cf21b70e3c1eadc56c179506d8fbe

The function symbol_put_addr() will deadlock the kernel.

symbol_put_addr() would acquire modlist_lock, then while holding the lock call
two functions kernel_text_address() and module_text_address() which also try
to acquire the same lock.  This deadlocks the kernel of course.

This patch changes symbol_put_addr() to not acquire the modlist_lock, it
doesn't need it since it never looks at the module list directly.  Also, it
now uses core_kernel_text() instead of kernel_text_address().  The latter has
an additional check for addr inside a module, but we don't need to do that
since we call module_text_address() (the same function kernel_text_address
uses) ourselves.
Signed-off-by: NTrent Piepho <xyzzy@speakeasy.org>
Cc: Zwane Mwaikambo <zwane@fsmlabs.com>
Acked-by: NRusty Russell <rusty@rustcorp.com.au>
Cc: Johannes Stezenbach <js@linuxtv.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 01596778
...@@ -124,6 +124,7 @@ extern int get_option(char **str, int *pint); ...@@ -124,6 +124,7 @@ extern int get_option(char **str, int *pint);
extern char *get_options(const char *str, int nints, int *ints); extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(char *ptr, char **retptr); extern unsigned long long memparse(char *ptr, char **retptr);
extern int core_kernel_text(unsigned long addr);
extern int __kernel_text_address(unsigned long addr); extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr); extern int kernel_text_address(unsigned long addr);
extern int session_of_pgrp(int pgrp); extern int session_of_pgrp(int pgrp);
......
...@@ -40,7 +40,7 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr) ...@@ -40,7 +40,7 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr)
return e; return e;
} }
static int core_kernel_text(unsigned long addr) int core_kernel_text(unsigned long addr)
{ {
if (addr >= (unsigned long)_stext && if (addr >= (unsigned long)_stext &&
addr <= (unsigned long)_etext) addr <= (unsigned long)_etext)
......
...@@ -705,14 +705,14 @@ EXPORT_SYMBOL(__symbol_put); ...@@ -705,14 +705,14 @@ EXPORT_SYMBOL(__symbol_put);
void symbol_put_addr(void *addr) void symbol_put_addr(void *addr)
{ {
unsigned long flags; struct module *modaddr;
spin_lock_irqsave(&modlist_lock, flags); if (core_kernel_text((unsigned long)addr))
if (!kernel_text_address((unsigned long)addr)) return;
BUG();
module_put(module_text_address((unsigned long)addr)); if (!(modaddr = module_text_address((unsigned long)addr)))
spin_unlock_irqrestore(&modlist_lock, flags); BUG();
module_put(modaddr);
} }
EXPORT_SYMBOL_GPL(symbol_put_addr); EXPORT_SYMBOL_GPL(symbol_put_addr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册