lkml.org 
[lkml]   [2010]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] Rewrite jump_label.c to use binary search
On Wed, Sep 22, 2010 at 11:02:50AM -0400, Mathieu Desnoyers wrote:
> * Andi Kleen (andi@firstfloor.org) wrote:
> >
> > >
> > >>> + for (; entry < stop && entry->key == key; entry++)
> > >>> + if (kernel_text_address(entry->code))
> > >>
> > >> This does not work for modules I'm afraid, only for the core kernel. You
> > >> should test for __module_text_address() somewhere.
> > >
> > > I thought it was shared now, but ok.
> >
> > Double checked. This is ok because kernel_text_address()
> > already checks for modules. You were probably thinking
> > of __kernel_text_address()
>
> Ah right,
>
> Although we have another problem:
>
> __module_text_address() includes module init text, which defeats the
> purpose of the check put in there by Jason.
>
> So the check works for the core kernel, but not for modules.
>
> Mathieu
>

it works for modules too...it does:

struct module *__module_text_address(unsigned long addr)
{
struct module *mod = __module_address(addr);
if (mod) {
/* Make sure it's within the text section. */
if (!within(addr, mod->module_init, mod->init_text_size)
&& !within(addr, mod->module_core,
mod->core_text_size))
mod = NULL;
}
return mod;
}
and then in kernel/module.c we have :


module_free(mod, mod->module_init);
mod->module_init = NULL;


So, I was relying on the fact module_init gets set to NULL after the
free happens. However, there a small race there in that the vfree()
happens before module_init() is set to NULL. So that is probably most
easily fixed be wrapping those two lines with the jump_label_mutex.

thanks,

-Jason




\
 
 \ /
  Last update: 2010-09-22 17:31    [from the cache]
©2003-2011 Jasper Spaans