Fix module.c pointer arithmetics
PATCH 1/1 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 =====
kernel/module.c +3 -3
@@ -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 ;
In message <[email protected]> you write:
kernel/module.c line 153
Quoted 2 lines
kernel/module.c +1
-1-for (i =0 ; __start___ksymtab+i < __stop___ksymtab; i++) { +for (i =0 ; __start___ksymtab+i*sizeof (struct kernel_symbol ) < __stop___ksymtab; i++) {
Above in this file, there is the declaration:
extern const struct kernel_symbol __start___ksymtab[];
What makes you think you need to multiply here?
Puzzled,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 11 lines · Rusty Russell
In message <[email protected]> you write:
kernel/module.c line 153
Quoted 2 lines
kernel/module.c +1
-1-for (i =0 ; __start___ksymtab+i < __stop___ksymtab; i++) { +for (i =0 ; __start___ksymtab+i*sizeof (struct kernel_symbol ) < __stop___ksymtab; i++) {Above in this file, there is the declaration:
extern const struct
kernel_symbol__start___ksymtab[];What makes you think you need to multiply here?
-ENOCAFFEINE. (Note to self: Never send patches while asleep) Now that I'm awake again, I feel ashamed.
Quoted 2 lines
Puzzled,
Rusty.
Sorry for the confusion,
Carl-Daniel.