lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 22 Nov 2007 03:43:07 +0100 (CET)
From:	Andi Kleen <ak@...e.de>
To:	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	sam@...nborg.org, rusty@...tcorp.com.au
Subject: [PATCH RFC] [2/9] Fix duplicate symbol check to also check future gpl and unused symbols


This seems to have been forgotten earlier. Right now it was possible
for a normal symbol to override a future gpl symbol and similar.
I restructured the code a bit to avoid too much duplicated code.

---
 kernel/module.c |   45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

Index: linux/kernel/module.c
===================================================================
--- linux.orig/kernel/module.c
+++ linux/kernel/module.c
@@ -1430,33 +1430,36 @@ EXPORT_SYMBOL_GPL(do_symbol_get);
  * Ensure that an exported symbol [global namespace] does not already exist
  * in the kernel or in some other module's exported symbol table.
  */
-static int verify_export_symbols(struct module *mod)
+
+static int check_duplicate(const struct kernel_symbol *syms, int num, struct module *owner)
 {
-	const char *name = NULL;
-	unsigned long i, ret = 0;
-	struct module *owner;
+	int i;
 	const unsigned long *crc;
 
-	for (i = 0; i < mod->num_syms; i++)
-	        if (find_symbol(mod->syms[i].name, &owner, &crc, 1, mod)) {
-			name = mod->syms[i].name;
-			ret = -ENOEXEC;
-			goto dup;
-		}
-
-	for (i = 0; i < mod->num_gpl_syms; i++)
-	        if (find_symbol(mod->gpl_syms[i].name, &owner, &crc, 1, mod)) {
-			name = mod->gpl_syms[i].name;
-			ret = -ENOEXEC;
-			goto dup;
+	for (i = 0; i < num; i++)
+	        if (find_symbol(syms[i].name, &owner, &crc, 1, owner)) {
+			printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
+				owner->name, syms[i].name, module_name(owner));
+			return -ENOEXEC;
 		}
+	return 0;
+}
 
-dup:
+static int verify_export_symbols(struct module *mod)
+{
+	int ret = check_duplicate(mod->syms, mod->num_syms, mod);
 	if (ret)
-		printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
-			mod->name, name, module_name(owner));
-
-	return ret;
+		return ret;
+	ret = check_duplicate(mod->gpl_syms, mod->num_gpl_syms, mod);
+	if (ret)
+		return ret;
+	ret = check_duplicate(mod->unused_syms, mod->num_unused_syms, mod);
+	if (ret)
+		return ret;
+	ret = check_duplicate(mod->unused_gpl_syms, mod->num_unused_gpl_syms, mod);
+	if (ret)
+		return ret;
+	return check_duplicate(mod->gpl_future_syms, mod->num_gpl_future_syms, mod);
 }
 
 /* Change all symbols so that sh_value encodes the pointer directly. */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists