linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Righi <andrea.righi@canonical.com>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>,
	peterz@infradead.org,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -tip v3 04/10] x86/kprobes: Prohibit probing on IRQ handlers directly
Date: Tue, 26 Mar 2019 16:17:13 +0100	[thread overview]
Message-ID: <20190326151713.GB27897@xps-13> (raw)
In-Reply-To: <20190326235052.793b81b121021020fb3b1e93@kernel.org>

On Tue, Mar 26, 2019 at 11:50:52PM +0900, Masami Hiramatsu wrote:
> On Mon, 25 Mar 2019 17:23:34 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > On Wed, 13 Feb 2019 01:12:44 +0900
> > Masami Hiramatsu <mhiramat@kernel.org> wrote:
> > 
> > > Prohibit probing on IRQ handlers in irqentry_text because
> > > if it interrupts user mode, at that point we haven't changed
> > > to kernel space yet and which eventually leads a double fault.
> > > E.g.
> > > 
> > >  # echo p apic_timer_interrupt > kprobe_events
> > 
> > Hmm, this breaks one of my tests (which I probe on do_IRQ).
> 
> OK, it seems this patch is a bit redundant, because
> I found that these interrupt handler issue has been fixed
> by Andrea's commit before merge this patch.
> 
> commit a50480cb6d61d5c5fc13308479407b628b6bc1c5
> Author: Andrea Righi <righi.andrea@gmail.com>
> Date:   Thu Dec 6 10:56:48 2018 +0100
> 
>     kprobes/x86: Blacklist non-attachable interrupt functions
>     
>     These interrupt functions are already non-attachable by kprobes.
>     Blacklist them explicitly so that they can show up in
>     /sys/kernel/debug/kprobes/blacklist and tools like BCC can use this
>     additional information.
> 
> This description is a bit odd (maybe his patch is after mine?) I think
> while updating this series, the patches were merged out of order.
> Anyway, with above patch, the core problematic probe points are blacklisted.

This is the previous thread when I posted my patch (not sure if it helps
to figure out what happened - maybe it was just an out of order merge
issue, like you said):

https://lkml.org/lkml/2018/12/6/212

> 
> > 
> > It's been working for years.
> > 
> > 
> > >  # echo 1 > events/kprobes/enable
> > >  PANIC: double fault, error_code: 0x0
> > >  CPU: 1 PID: 814 Comm: less Not tainted 4.20.0-rc3+ #30
> > >  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
> > >  RIP: 0010:error_entry+0x12/0xf0
> > >  [snip]
> > >  Call Trace:
> > >   <ENTRY_TRAMPOLINE>
> > >   ? native_iret+0x7/0x7
> > >   ? async_page_fault+0x8/0x30
> > >   ? trace_hardirqs_on_thunk+0x1c/0x1c
> > >   ? error_entry+0x7c/0xf0
> > >   ? async_page_fault+0x8/0x30
> > >   ? native_iret+0x7/0x7
> > >   ? int3+0xa/0x20
> > >   ? trace_hardirqs_on_thunk+0x1c/0x1c
> > >   ? error_entry+0x7c/0xf0
> > >   ? int3+0xa/0x20
> > >   ? apic_timer_interrupt+0x1/0x20
> > >   </ENTRY_TRAMPOLINE>
> > >  Kernel panic - not syncing: Machine halted.
> > >  Kernel Offset: disabled
> > 
> > I'm not able to reproduce this (by removing this commit). 
> 
> I ensured that if I revert both of this patch and Andrea's patch,
> I can reproduce this with probing on apic_timer_interrupt().
> 
> > I'm thinking something else may have changed, as I've been tracing
> > interrupt entries for years, and interrupting userspace while doing
> > this.
> > 
> > I've even added probes where ftrace isn't (where it uses an int3) and
> > still haven't hit a problem.
> > 
> > I think this patch is swatting a symptom of a bug and not addressing
> > the bug itself. Can you send me the config that triggers this?
> 
> Yes, it seems you're right. Andrea's commit specifically fixed the
> issue and mine is redundant. (I'm not sure why do_IRQ is in 
> __irqentry_text...)

Not sure if there are specific reasons for that, but do_IRQ is part of
__irqentry_text because it's explicitly marked with __irq_entry.

> 
> So, Ingo, please revert this, since this bug already has been fixed by
> commit a50480cb6d61 ("kprobes: x86_64: blacklist non-attachable interrupt
> functions")
> 
> BTW, for further error investigation, I attached my kconfig which is
> usually I'm testing (some options can be changed) on Qemu.
> I'm using my mini-container shellscript ( https://github.com/mhiramat/mincs 
> ) which supports qemu-container.
> 
> 
> Thank you,
> 
> -- 
> Masami Hiramatsu <mhiramat@kernel.org>

Thanks,
-Andrea

  reply	other threads:[~2019-03-26 15:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 16:10 [PATCH -tip v3 00/10] kprobes: Fix and improve blacklist symbols Masami Hiramatsu
2019-02-12 16:11 ` [PATCH -tip v3 01/10] x86/kprobes: Prohibit probing on optprobe template code Masami Hiramatsu
2019-02-13  8:58   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:11 ` [PATCH -tip v3 02/10] x86/kprobes: Move trampoline code into RODATA Masami Hiramatsu
2019-02-13  8:59   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:12 ` [PATCH -tip v3 03/10] x86/kprobes: Prohibit probing on functions before kprobe_int3_handler() Masami Hiramatsu
2019-02-13  9:00   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:12 ` [PATCH -tip v3 04/10] x86/kprobes: Prohibit probing on IRQ handlers directly Masami Hiramatsu
2019-02-13  9:00   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-03-25 21:23   ` [PATCH -tip v3 04/10] " Steven Rostedt
2019-03-26 14:50     ` Masami Hiramatsu
2019-03-26 15:17       ` Andrea Righi [this message]
2019-02-12 16:13 ` [PATCH -tip v3 05/10] kprobes: Search non-suffixed symbol in blacklist Masami Hiramatsu
2019-02-13  7:13   ` Ingo Molnar
2019-02-13  7:17     ` Ingo Molnar
2019-02-13 13:43       ` Steven Rostedt
2019-02-13 23:44       ` Masami Hiramatsu
2019-02-13  9:01   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:13 ` [PATCH -tip v3 06/10] kprobes: Prohibit probing on hardirq tracers Masami Hiramatsu
2019-02-13  9:02   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:14 ` [PATCH -tip v3 07/10] kprobes: Prohibit probing on preempt_check debug functions Masami Hiramatsu
2019-02-13  9:02   ` [tip:perf/core] kprobes: Prohibit probing on preemption checking " tip-bot for Masami Hiramatsu
2019-02-12 16:14 ` [PATCH -tip v3 08/10] kprobes: Prohibit probing on RCU debug routine Masami Hiramatsu
2019-02-13  9:03   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:15 ` [PATCH -tip v3 09/10] kprobes: Prohibit probing on lockdep functions Masami Hiramatsu
2019-02-13  9:03   ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2019-02-12 16:15 ` [PATCH -tip v3 10/10] kprobes: Prohibit probing on bsearch() Masami Hiramatsu
2019-02-13  9:04   ` [tip:perf/core] " tip-bot for Andrea Righi

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=20190326151713.GB27897@xps-13 \
    --to=andrea.righi@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).