mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: Chuck Ebbert <76306.1226@compuserve.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>, Linus Torvalds <torvalds@osdl.org>
Subject: Re: Possible spinlock recursion in search_module_extables() ?
Date: Wed, 08 Nov 2006 12:42:17 -0500	[thread overview]
Message-ID: <1163007738.12604.4.camel@dantu.rdu.redhat.com> (raw)
In-Reply-To: <200606190635_MC3-1-C2D8-258F@compuserve.com>

On Mon, 2006-06-19 at 06:31 -0400, Chuck Ebbert wrote:
> Looking at this code:
> 
> const struct exception_table_entry *search_exception_tables(unsigned long addr)
> {
>         const struct exception_table_entry *e;
> 
>         e = search_extable(__start___ex_table, __stop___ex_table-1, addr);
>         if (!e)
>                 e = search_module_extables(addr);
>         return e;
> }
> 
> const struct exception_table_entry *search_module_extables(unsigned long addr)
> {
>         unsigned long flags;
>         const struct exception_table_entry *e = NULL;
>         struct module *mod;
> 
>         spin_lock_irqsave(&modlist_lock, flags);
>         list_for_each_entry(mod, &modules, list) {
>                 if (mod->num_exentries == 0)
>                         continue;
> 
>                 e = search_extable(mod->extable,
>                                    mod->extable + mod->num_exentries - 1,
>                                    addr);
>                 if (e)
>                         break;
>         }
>         spin_unlock_irqrestore(&modlist_lock, flags);
> 
>         /* Now, if we found one, we are running inside it now, hence
>            we cannot unload the module, hence no refcnt needed. */
>         return e;
> }
> 
> 
> search_module_extables() takes a spinlock.  If some kind of fault occurs
> while it's holding that lock (module list corrupted etc.,) won't it be
> re-entered while looking for its own fault handler?  If so, would this
> be a possible fix?
> 
> const struct exception_table_entry *search_exception_tables(unsigned long addr)
> {
>         const struct exception_table_entry *e;
> 
>         if (core_kernel_text(addr))
>                 e = search_extable(__start___ex_table, __stop___ex_table-1, addr);
>         else
>                 e = search_module_extables(addr);
> 
>         return e;
> }

I seem to be able to reliably trigger this spinlock recursion problem
with systemtap on a RHEL4 kernel. The patch suggested above does seem to
correct it, but I'm not familiar enough with extables to know whether
the approach here is correct.

-- Jeff





  reply	other threads:[~2006-11-08 17:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-19 10:31 Chuck Ebbert
2006-11-08 17:42 ` Jeff Layton [this message]
2006-11-08 18:56   ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1163007738.12604.4.camel@dantu.rdu.redhat.com \
    --to=jlayton@redhat.com \
    --cc=76306.1226@compuserve.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®