mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: kernel test robot <fengguang.wu@intel.com>,
	Ingo Molnar <mingo@kernel.org>, Alexei Starovoitov <ast@fb.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	tipbuild@zytor.com, lkp@01.org
Subject: Re: [kprobes/x86]  a19b2e3d78: WARNING:at_kernel/locking/lockdep.c:#trace_hardirqs_off_caller
Date: Tue, 3 Oct 2017 10:10:12 +0900	[thread overview]
Message-ID: <20171003101012.12cee3b5f7085ddbd0d63fb8@kernel.org> (raw)
In-Reply-To: <20171002160543.5d35jgxxfa4bftnu@hirez.programming.kicks-ass.net>

On Mon, 2 Oct 2017 18:05:43 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> On Tue, Oct 03, 2017 at 12:46:05AM +0900, Masami Hiramatsu wrote:
> > On Mon, 2 Oct 2017 09:33:16 +0200
> > Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > > > [   87.018115] Call Trace:
> > > > [   87.025046]  trace_hardirqs_off+0xd/0xf
> > > > [   87.034185]  setjmp_pre_handler+0x6c/0x95
> > > > [   87.043738]  kprobe_ftrace_handler+0xc3/0xf4
> > > 
> > > 
> > > So setjmp_pre_handler() does:
> > > 
> > > 	regs->flags &= ~X86_EFLAGS_IF;
> > > 	trace_hardirqs_off();
> > > 	regs->ip = (unsigned long)(jp->entry);
> > > 
> > > Which clears IF on the regs, but those will only take effect after an
> > > IRET, not instantly. This messes up he IRQ state tracing, which you're
> > > telling it will instantly disable IRQs.
> > 
> > Thanks for analyzing!
> > And right, since IRQ should be off while jump handler, it changes
> > regs->flags. (but ...why?)
> 
> Otherwise the IRET could re-enable interrupts?

Ah, I meant why IRQ should be disabled... It doesn't guarantee to
avoid nested kprobes (since another kprobe can be hit in jprobe
handler).

> > > A possible 'fix' would be to do local_irq_disable() in front of that,
> > > but I got pretty lost in that stuff so I can't say for sure if that
> > > makes sense or not.
> > 
> > I'm not sure how lockdep traces irq-disabling state, but it seems
> > that "enabling" irq state(trace_hardirqs_on()) is already missing
> > from kprobes.
> 
> If you could point me at where that is supposed to happen I can have a
> look at how that tracing works. I got lost in the code this morning.

The right place to decrement irq counter(trace_hardirqs_on()) should
be longjmp_break_handler(), which recovers flags register with other
registers from kcb->jprobe_saved_regs, and IRET recovers IF.
(maybe it doesn't count inc/dec correctly, isn't it?)

> > I'm considering to remove disabling-irq itself from jprobe.
> > (Frankly to say, I would like to remove jprobe itself...)
> 
> That would obviously also solve all problems :-)

Yeah, for long term it needs to be removed :)

Thank you,

-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2017-10-03  1:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-30 23:12 kernel test robot
2017-10-02  7:33 ` Peter Zijlstra
2017-10-02 15:46   ` Masami Hiramatsu
2017-10-02 16:05     ` Peter Zijlstra
2017-10-03  1:10       ` Masami Hiramatsu [this message]
2017-10-02 16:19     ` Linus Torvalds
2017-10-03  2:26       ` Masami Hiramatsu
2017-10-03  7:18 ` [BUGFIX PATCH] kprobes/x86: Remove IRQ disabling from jprobe handlers Masami Hiramatsu
2017-10-03  9:33   ` Ingo Molnar
2017-10-03 15:24     ` Masami Hiramatsu
2017-10-03 17:11       ` Ingo Molnar
2017-10-04  6:18         ` Masami Hiramatsu
2017-10-04 10:41           ` Ingo Molnar
2017-10-04 14:08             ` Masami Hiramatsu
2017-10-05  7:57               ` Ingo Molnar
2017-10-05  8:28                 ` Masami Hiramatsu
2017-10-03 17:43   ` [tip:x86/urgent] " tip-bot for 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=20171003101012.12cee3b5f7085ddbd0d63fb8@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=ast@fb.com \
    --cc=ast@kernel.org \
    --cc=fengguang.wu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tipbuild@zytor.com \
    --cc=torvalds@linux-foundation.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

Powered by JetHome