Skip to contentSkip to conversation

module: fix BUG_ON() for powerpc (and other function descriptor archs)

PATCH In review Rusty Russell 2 participants 3 messages Aug 26, 2009 – Aug 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 module: fix BUG_ON() for powerpc (and other function descriptor archs)

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

kernel/module.c +4 -2
@@ -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);
 }
#1 lore raw

PATCH 2/2 module: workaround duplicate section names

From: James Bottomley <[email protected]>

(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

---

kernel/module.c +2 -1
index fd14114..a703c49 100644
@@ -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);
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] module: workaround duplicate section names

Quoted 7 lines · Rusty Russell

From: James Bottomley <[email protected]>

(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.

Quoted 11 lines

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

Looks fine for me.

Thanks.

Quoted 21 lines

---

kernel/module.c +2 -2
index fd14114..a703c49 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/