public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [2.6.2-rc3] Fix module.c pointer arithmetics
@ 2004-01-31 12:52 Carl-Daniel Hailfinger
  2004-01-31 13:55 ` Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Carl-Daniel Hailfinger @ 2004-01-31 12:52 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Rusty Russell, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

Linus,
Rusty,

while studying the module code closely, I found a problem in
kernel/module.c:153ff.

for (i = 0; __start___ksymtab+i < __stop___ksymtab; i++)

In combination with __start___ksymtab[i].name this will go eight times too
far. Proposed fix is attached.

Please apply before 2.6.2. If you think this makes the code too slow, I
can offer an alternative which will even speed up the current code.

Thanks,
Carl-Daniel

[-- Attachment #2: modulefix.txt --]
[-- Type: text/plain, Size: 1132 bytes --]

===== kernel/module.c 1.99 vs edited =====
--- 1.99/kernel/module.c	Wed Jan 21 02:50:58 2004
+++ edited/kernel/module.c	Sat Jan 31 13:50:47 2004
@@ -150,14 +150,14 @@
 
 	/* Core kernel first. */ 
 	*owner = NULL;
-	for (i = 0; __start___ksymtab+i < __stop___ksymtab; i++) {
+	for (i = 0; __start___ksymtab+i*sizeof(struct kernel_symbol) < __stop___ksymtab; i++) {
 		if (strcmp(__start___ksymtab[i].name, name) == 0) {
 			*crc = symversion(__start___kcrctab, i);
 			return __start___ksymtab[i].value;
 		}
 	}
 	if (gplok) {
-		for (i = 0; __start___ksymtab_gpl+i<__stop___ksymtab_gpl; i++)
+		for (i = 0; __start___ksymtab_gpl+i*sizeof(struct kernel_symbol) < __stop___ksymtab_gpl; i++)
 			if (strcmp(__start___ksymtab_gpl[i].name, name) == 0) {
 				*crc = symversion(__start___kcrctab_gpl, i);
 				return __start___ksymtab_gpl[i].value;
@@ -1308,7 +1308,7 @@
 	unsigned int i;
 
 	if (!mod) {
-		for (i = 0; __start___ksymtab+i < __stop___ksymtab; i++)
+		for (i = 0; __start___ksymtab+i*sizeof(struct kernel_symbol) < __stop___ksymtab; i++)
 			if (strcmp(__start___ksymtab[i].name, name) == 0)
 				return 1;
 		return 0;

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

end of thread, other threads:[~2004-01-31 16:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-31 12:52 [PATCH] [2.6.2-rc3] Fix module.c pointer arithmetics Carl-Daniel Hailfinger
2004-01-31 13:55 ` Rusty Russell
2004-01-31 16:35   ` Carl-Daniel Hailfinger

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