2004-01-31 12:52:56

by Carl-Daniel Hailfinger

[permalink] [raw]
Subject: [PATCH] [2.6.2-rc3] Fix module.c pointer arithmetics

===== 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;


Attachments:
modulefix.txt (1.11 kB)

2004-01-31 13:58:57

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] [2.6.2-rc3] Fix module.c pointer arithmetics

In message <[email protected]> you write:
> - 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.

2004-01-31 16:35:38

by Carl-Daniel Hailfinger

[permalink] [raw]
Subject: Re: [PATCH] [2.6.2-rc3] Fix module.c pointer arithmetics

Rusty Russell wrote:
> In message <[email protected]> you write:
>
>>- 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.


> Puzzled,
> Rusty.

Sorry for the confusion,
Carl-Daniel.