public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] module: fix BUG_ON() for powerpc (and other function descriptor archs)
@ 2009-08-26 12:32 Rusty Russell
  2009-08-26 12:34 ` [PATCH 2/2] module: workaround duplicate section names Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2009-08-26 12:32 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, Paul Mackerras

The rarely-used symbol_put_addr() needs to use dereference_function_descriptor
on powerpc.

Reported-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au.

diff --git a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -909,16 +909,18 @@ void __symbol_put(const char *symbol)
 }
 EXPORT_SYMBOL(__symbol_put);
 
+/* Note this assumes addr is a function, which it currently always is. */
 void symbol_put_addr(void *addr)
 {
 	struct module *modaddr;
+	unsigned long a = (unsigned long)dereference_function_descriptor(addr);
 
-	if (core_kernel_text((unsigned long)addr))
+	if (core_kernel_text(a))
 		return;
 
 	/* module_text_address is safe here: we're supposed to have reference
 	 * to module from symbol_get, so it can't go away. */
-	modaddr = __module_text_address((unsigned long)addr);
+	modaddr = __module_text_address(a);
 	BUG_ON(!modaddr);
 	module_put(modaddr);
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] module: workaround duplicate section names
  2009-08-26 12:32 [PATCH 1/2] module: fix BUG_ON() for powerpc (and other function descriptor archs) Rusty Russell
@ 2009-08-26 12:34 ` Rusty Russell
  2009-08-27  4:53   ` Amerigo Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2009-08-26 12:34 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, James Bottomley, Helge Deller

From: James Bottomley <James.Bottomley@HansenPartnership.com>

(This patch leaves other problems, particularly the sections
 directory, but recent parisc toolchains seem to produce these
 modules and this prevents a crash and is a minimal change -- RR).

The root cause is a duplicate section name (.text); is this legal?

However, there's a problem with commit
6d76013381ed28979cd122eb4b249a88b5e384fa in that if you fail to allocate
a mod->sect_attrs (in this case it's null because of the duplication),
it still gets used without checking in add_notes_attrs()

This should fix it

Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Tested-by: Helge Deller <deller@gmx.de>
---

diff --git a/kernel/module.c b/kernel/module.c
index fd14114..a703c49 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2353,7 +2353,8 @@ static noinline struct module *load_module(void __user *umod,
 	if (err < 0)
 		goto unlink;
 	add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
-	add_notes_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
+	if (mod->sect_attrs)
+		add_notes_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
 
 	/* Get rid of temporary copy */
 	vfree(hdr);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] module: workaround duplicate section names
  2009-08-26 12:34 ` [PATCH 2/2] module: workaround duplicate section names Rusty Russell
@ 2009-08-27  4:53   ` Amerigo Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Amerigo Wang @ 2009-08-27  4:53 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Linus Torvalds, linux-kernel, James Bottomley, Helge Deller

On Wed, Aug 26, 2009 at 10:04:12PM +0930, Rusty Russell wrote:
>From: James Bottomley <James.Bottomley@HansenPartnership.com>
>
>(This patch leaves other problems, particularly the sections
> directory, but recent parisc toolchains seem to produce these
> modules and this prevents a crash and is a minimal change -- RR).
>
>The root cause is a duplicate section name (.text); is this legal?

AFAIK, yes.


>
>However, there's a problem with commit
>6d76013381ed28979cd122eb4b249a88b5e384fa in that if you fail to allocate
>a mod->sect_attrs (in this case it's null because of the duplication),
>it still gets used without checking in add_notes_attrs()
>
>This should fix it
>
>Signed-off-by: James Bottomley <James.Bottomley@suse.de>
>Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>Tested-by: Helge Deller <deller@gmx.de>

Looks fine for me.

Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>

Thanks.


>---
>
>diff --git a/kernel/module.c b/kernel/module.c
>index fd14114..a703c49 100644
>--- a/kernel/module.c
>+++ b/kernel/module.c
>@@ -2353,7 +2353,8 @@ static noinline struct module *load_module(void __user *umod,
> 	if (err < 0)
> 		goto unlink;
> 	add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
>-	add_notes_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
>+	if (mod->sect_attrs)
>+		add_notes_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
> 
> 	/* Get rid of temporary copy */
> 	vfree(hdr);
>--
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-27  4:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26 12:32 [PATCH 1/2] module: fix BUG_ON() for powerpc (and other function descriptor archs) Rusty Russell
2009-08-26 12:34 ` [PATCH 2/2] module: workaround duplicate section names Rusty Russell
2009-08-27  4:53   ` Amerigo Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox