lkml.org 
[lkml]   [2004]   [Jan]   [31]   [last100]   RSS Feed
Views: [more markup]   [less markup]   [headers]   [forward]  
 
Messages in this thread
Patch in this message
/
DateSat, 31 Jan 2004 13:52:48 +0100
FromCarl-Daniel Hailfinger <>
Subject[PATCH] [2.6.2-rc3] Fix module.c pointer arithmetics
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
===== 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;
\
 
 \ /
  Last update: 2005-03-22 13:00    [from the cache]
©2003-2008