mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fix verify_export_symbols()
@ 2008-01-10 16:37 Jan Beulich
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2008-01-10 16:37 UTC (permalink / raw)
  To: linux-kernel

When the newer export flavors were added, it was apparently forgotten
to add respective code here.
In order to not double the (source) size of the function, add some
abstraction to reduce code duplication.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
---

 kernel/module.c |   37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

--- linux-2.6.24-rc7/kernel/module.c	2008-01-10 16:50:54.000000000 +0100
+++ 2.6.24-rc7-verify-export-symbols/kernel/module.c	2008-01-08 16:42:35.000000000 +0100
@@ -1344,31 +1344,32 @@ EXPORT_SYMBOL_GPL(__symbol_get);
  */
 static int verify_export_symbols(struct module *mod)
 {
-	const char *name = NULL;
-	unsigned long i, ret = 0;
+	const char *name;
+	unsigned int i;
 	struct module *owner;
 	const unsigned long *crc;
 
-	for (i = 0; i < mod->num_syms; i++)
-		if (__find_symbol(mod->syms[i].name, &owner, &crc, 1)) {
-			name = mod->syms[i].name;
-			ret = -ENOEXEC;
-			goto dup;
-		}
+#define VERIFY(syms) \
+	for (i = 0; i < mod->num_##syms; i++) { \
+		name = mod->syms[i].name; \
+		if (__find_symbol(name, &owner, &crc, 1)) \
+			goto dup; \
+	}
 
-	for (i = 0; i < mod->num_gpl_syms; i++)
-		if (__find_symbol(mod->gpl_syms[i].name, &owner, &crc, 1)) {
-			name = mod->gpl_syms[i].name;
-			ret = -ENOEXEC;
-			goto dup;
-		}
+	VERIFY(syms);
+	VERIFY(gpl_syms);
+	VERIFY(gpl_future_syms);
+	VERIFY(unused_syms);
+	VERIFY(unused_gpl_syms);
+#undef VERIFY
+
+	return 0;
 
 dup:
-	if (ret)
-		printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
-			mod->name, name, module_name(owner));
+	printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
+	       mod->name, name, module_name(owner));
 
-	return ret;
+	return -ENOEXEC;
 }
 
 /* Change all symbols so that st_value encodes the pointer directly. */




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

* Re: [PATCH] fix verify_export_symbols()
  2008-03-17 22:36 ` Rusty Russell
@ 2008-03-18  0:29   ` Rusty Russell
  0 siblings, 0 replies; 4+ messages in thread
From: Rusty Russell @ 2008-03-18  0:29 UTC (permalink / raw)
  To: Jan Beulich; +Cc: linux-kernel, Andrew Morton

On Tuesday 18 March 2008 09:36:04 Rusty Russell wrote:
> On Thursday 13 March 2008 20:04:17 you wrote:
> > When the newer export flavors were added, it was apparently forgotten
> > to add respective code here.
> > In order to not double the (source) size of the function, add some
> > abstraction to reduce code duplication.
>
> Hi Jan,
>
>    Actually, the others did exist, they just weren't checked.

No, my bad, you're right (GPL-only existed, but they were covered already).  
The problem with this is that we'll get a bogus unused warning in the case of 
doing a __find_symbol on an unused symbol.

It's time for a general cleanup of the __find_symbol logic.  I'll post when 
it's done.

Thanks!
Rusty.

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

* Re: [PATCH] fix verify_export_symbols()
  2008-03-13  9:04 Jan Beulich
@ 2008-03-17 22:36 ` Rusty Russell
  2008-03-18  0:29   ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2008-03-17 22:36 UTC (permalink / raw)
  To: Jan Beulich; +Cc: linux-kernel, Andrew Morton

On Thursday 13 March 2008 20:04:17 you wrote:
> When the newer export flavors were added, it was apparently forgotten
> to add respective code here.
> In order to not double the (source) size of the function, add some
> abstraction to reduce code duplication.

Hi Jan,

   Actually, the others did exist, they just weren't checked.

I've taken this patch and your two other module patches.  Please cc me on 
module patches in future.

Thanks!
Rusty.

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

* [PATCH] fix verify_export_symbols()
@ 2008-03-13  9:04 Jan Beulich
  2008-03-17 22:36 ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2008-03-13  9:04 UTC (permalink / raw)
  To: linux-kernel

When the newer export flavors were added, it was apparently forgotten
to add respective code here.
In order to not double the (source) size of the function, add some
abstraction to reduce code duplication.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

---
 kernel/module.c |   39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

--- linux-2.6.25-rc5/kernel/module.c	2008-03-10 13:24:35.000000000 +0100
+++ 2.6.25-rc5-verify-export-symbols/kernel/module.c	2008-03-04 11:23:05.000000000 +0100
@@ -1383,33 +1383,32 @@ EXPORT_SYMBOL_GPL(__symbol_get);
  */
 static int verify_export_symbols(struct module *mod)
 {
-	const char *name = NULL;
-	unsigned long i, ret = 0;
+	const char *name;
+	unsigned int i;
 	struct module *owner;
 	const unsigned long *crc;
 
-	for (i = 0; i < mod->num_syms; i++)
-		if (!IS_ERR_VALUE(__find_symbol(mod->syms[i].name,
-							&owner, &crc, 1))) {
-			name = mod->syms[i].name;
-			ret = -ENOEXEC;
-			goto dup;
-		}
+#define VERIFY(syms) \
+	for (i = 0; i < mod->num_##syms; i++) { \
+		name = mod->syms[i].name; \
+		if (!IS_ERR_VALUE(__find_symbol(name, &owner, &crc, 1))) \
+			goto dup; \
+	}
 
-	for (i = 0; i < mod->num_gpl_syms; i++)
-		if (!IS_ERR_VALUE(__find_symbol(mod->gpl_syms[i].name,
-							&owner, &crc, 1))) {
-			name = mod->gpl_syms[i].name;
-			ret = -ENOEXEC;
-			goto dup;
-		}
+	VERIFY(syms);
+	VERIFY(gpl_syms);
+	VERIFY(gpl_future_syms);
+	VERIFY(unused_syms);
+	VERIFY(unused_gpl_syms);
+#undef VERIFY
+
+	return 0;
 
 dup:
-	if (ret)
-		printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
-			mod->name, name, module_name(owner));
+	printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
+		mod->name, name, module_name(owner));
 
-	return ret;
+	return -ENOEXEC;
 }
 
 /* Change all symbols so that st_value encodes the pointer directly. */




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

end of thread, other threads:[~2008-03-18  0:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-10 16:37 [PATCH] fix verify_export_symbols() Jan Beulich
2008-03-13  9:04 Jan Beulich
2008-03-17 22:36 ` Rusty Russell
2008-03-18  0:29   ` Rusty Russell

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

Powered by JetHome