Re: Prevent overriding of Symbols in the Kernel, avoiding Undefined behaviour
From: Ashutosh Naik
Date: Tue Dec 13 2005 - 10:27:30 EST
On 12/13/05, Ashutosh Naik <ashutosh.naik@xxxxxxxxx> wrote:
> On 12/13/05, Rusty Russell <rusty@xxxxxxxxxxxxxxx> wrote:
> >
> > How about something like:
> >
> > const struct kernel_symbol *sym;
> > unsigned int i;
> > const unsigned long *crc;
> > struct module *owner;
> >
> > spin_lock_irq(&modlist_lock);
> > for (i = 0; i < mod->num_syms; i++)
> > if (__find_symbol(mod->syms[i].name, &owner, &crc, 1))
> > goto dup;
> > for (i = 0; i < num->num_gpl_syms; i++)
> > if (__find_symbol(mod->gpl_syms[i].name,&owner,&crc,1))
> > goto dup;
> > spin_unlock_irq(&modlist_lock);
> > return 0;
> > dup:
> > printk("%s: exports duplicate symbol (owned by %s)\n",
> > mod->name, module_name(owner));
> > return -ENOEXEC;
> > }
>
> Have tried that in the attached patch. However, mod->syms[i].name
> would be valid only after a long relocation for loop has run through.
> While this adds a wee bit extra overhead, that overhead is only in the
> case where the module does actually export a Duplicate Symbol.
Forgot to add
Signed-off-by: Ashutosh Naik <ashutosh.naik@xxxxxxxxx>
Signed-off-by: Anand Krishnan <anandhkrishnan@xxxxxxxxxxx>
Cheers
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/