From: Ingo Molnar <mingo@kernel.org>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: linux-kernel@vger.kernel.org,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH -tip ] [BUGFIX] kprobes: Skip kretprobe hit in NMI context to avoid deadlock
Date: Fri, 1 Aug 2014 13:00:29 +0200 [thread overview]
Message-ID: <20140801110029.GA31286@gmail.com> (raw)
In-Reply-To: <20140801084254.12330.64728.stgit@kbuild-fedora.novalocal>
* Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote:
> Skip kretprobe hit in NMI context, because if an NMI happens
> inside the critical section protected by kretprobe_table.lock
> and another(or same) kretprobe hit, pre_kretprobe_handler
> tries to lock kretprobe_table.lock again.
> Normal interrupts have no problem because they are disabled
> with the lock.
>
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> ---
> kernel/kprobes.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 734e9a7..a537029 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1778,6 +1778,12 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
> unsigned long hash, flags = 0;
> struct kretprobe_instance *ri;
>
> + /* To avoid deadlock, prohibit return probing in NMI context */
> + if (in_nmi()) {
Should be unlikely()?
> + rp->nmissed++;
> + return 0;
In another place in this function we do:
} else {
rp->nmissed++;
raw_spin_unlock_irqrestore(&rp->lock, flags);
}
Is it safe to modify rp-> without locking?
> + }
> +
> /*TODO: consider to only swap the RA after the last pre_handler fired */
Nit: That comment is oddly formatted.
Thanks,
Ingo
next prev parent reply other threads:[~2014-08-01 11:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 8:42 [PATCH -tip ] [BUGFIX] kprobes: Skip kretprobe hit in NMI context to avoid deadlock Masami Hiramatsu
2014-08-01 9:48 ` Ananth N Mavinakayanahalli
2014-08-01 11:00 ` Ingo Molnar [this message]
2014-08-02 6:37 ` Masami Hiramatsu
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=20140801110029.GA31286@gmail.com \
--to=mingo@kernel.org \
--cc=ananth@in.ibm.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.