+ symbol_put_addr-locks-kernel.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     symbol_put_addr() locks kernel

has been added to the -mm tree.  Its filename is

     symbol_put_addr-locks-kernel.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this


From: Trent Piepho <xyzzy@xxxxxxxxxxxxx>

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: Trent Piepho <xyzzy@xxxxxxxxxxxxx>
Cc: Zwane Mwaikambo <zwane@xxxxxxxxxxx>
Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 include/linux/kernel.h |    1 +
 kernel/extable.c       |    2 +-
 kernel/module.c        |   12 ++++++------
 3 files changed, 8 insertions(+), 7 deletions(-)

diff -puN include/linux/kernel.h~symbol_put_addr-locks-kernel include/linux/kernel.h
--- 25/include/linux/kernel.h~symbol_put_addr-locks-kernel	Mon May  8 12:31:30 2006
+++ 25-akpm/include/linux/kernel.h	Mon May  8 12:31:30 2006
@@ -128,6 +128,7 @@ extern int get_option(char **str, int *p
 extern char *get_options(const char *str, int nints, int *ints);
 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 session_of_pgrp(int pgrp);
diff -puN kernel/extable.c~symbol_put_addr-locks-kernel kernel/extable.c
--- 25/kernel/extable.c~symbol_put_addr-locks-kernel	Mon May  8 12:31:30 2006
+++ 25-akpm/kernel/extable.c	Mon May  8 12:31:30 2006
@@ -40,7 +40,7 @@ const struct exception_table_entry *sear
 	return e;
 }
 
-static int core_kernel_text(unsigned long addr)
+int core_kernel_text(unsigned long addr)
 {
 	if (addr >= (unsigned long)_stext &&
 	    addr <= (unsigned long)_etext)
diff -puN kernel/module.c~symbol_put_addr-locks-kernel kernel/module.c
--- 25/kernel/module.c~symbol_put_addr-locks-kernel	Mon May  8 12:31:30 2006
+++ 25-akpm/kernel/module.c	Mon May  8 12:31:30 2006
@@ -705,14 +705,14 @@ EXPORT_SYMBOL(__symbol_put);
 
 void symbol_put_addr(void *addr)
 {
-	unsigned long flags;
+	struct module *modaddr;
 
-	spin_lock_irqsave(&modlist_lock, flags);
-	if (!kernel_text_address((unsigned long)addr))
-		BUG();
+	if (core_kernel_text((unsigned long)addr))
+		return;
 
-	module_put(module_text_address((unsigned long)addr));
-	spin_unlock_irqrestore(&modlist_lock, flags);
+	if (!(modaddr = module_text_address((unsigned long)addr)))
+		BUG();
+	module_put(modaddr);
 }
 EXPORT_SYMBOL_GPL(symbol_put_addr);
 
_

Patches currently in -mm which might be from xyzzy@xxxxxxxxxxxxx are

git-dvb.patch
symbol_put_addr-locks-kernel.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux