linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	Paul Mackerras <paulus@samba.org>,
	stable@kernel.vger.org,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org,
	"David S. Miller" <davem@davemloft.net>,
	Larry Finger <Larry.Finger@lwfinger.net>
Subject: Re: [PATCH] powerpc/kprobes: Fix trap address when trap happened in real mode
Date: Tue, 18 Feb 2020 14:58:00 +0100	[thread overview]
Message-ID: <e9cb17f4-b698-7d9b-d435-e715ee14c489@c-s.fr> (raw)
In-Reply-To: <20200218213317.533c78753cefb05bd42cc6ad@kernel.org>



Le 18/02/2020 à 13:33, Masami Hiramatsu a écrit :
> On Tue, 18 Feb 2020 12:04:41 +0100
> Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> 
>>>> Nevertheless, if one symbol has been forgotten in the blacklist, I think
>>>> it is a problem if it generate Oopses.
>>>
>>> There is a long history also on x86 to make a blacklist. Anyway, how did
>>> you get this error on PPC32? Somewhere would you like to probe and
>>> it is a real mode function? Or, it happened unexpectedly?
>>
>> The first Oops I got was triggered by a WARN_ON() kind of trap in real
>> mode. The trap exception handler called kprobe_handler() which tried to
>> read the instruction at the trap address (which was a real-mode address)
>> so it triggered a Bad Access Fault.
>>
>> This was initially the purpose of my patch.
> 
> OK, then filtering the trap reason in kprobe handler is a bit strange.
> It should be done in the previous stage (maybe in trap.c)

See commit 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.6-rc2&id=6cc89bad60a673a24386f1ada83de8a068a78909

> Can we filter it by exception flag or only by checking the instruction
> which causes the exception, or needs get_kprobe()...?

The trap instruction used by kprobe is also used for other purposes like 
BUG_ON() or WARN_ON(), so needs get_kprobe()



> 
>> After discussion with you, I started looking at what would be the effect
>> of setting a kprobe event in a function which runs in real mode.
> 
> If the kprobe single-stepping (or emulation) works in real mode, just
> ignore the kprobes pre/post_handlers and increment nmissed count.
> 
> If that doesn't work, we have to call a BUG_ON, because we can not
> continue the code execution. And also, you have to find a way to make
> a blacklist for real mode code.

Yes, it has to be done function by function (hoppefully there's not more 
than a dozen).
But I'd like something which can fails gracefully for the functions we 
will forget to mark noprobe.

But as a first step I'd really like a bug fix in 5.6 to avoid Oopsing in 
kprobe_handler() at a non-kprobe trap.

Christophe

  reply	other threads:[~2020-02-18 14:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14 12:47 [PATCH] powerpc/kprobes: Fix trap address when trap happened in real mode Christophe Leroy
2020-02-14 13:54 ` Masami Hiramatsu
2020-02-15 10:28   ` Christophe Leroy
2020-02-16 12:34     ` Masami Hiramatsu
2020-02-17  9:03       ` Christophe Leroy
2020-02-17 10:27         ` Masami Hiramatsu
2020-02-17 15:38           ` Christophe Leroy
2020-02-17 17:41             ` Christophe Leroy
2020-02-18  0:44             ` Masami Hiramatsu
2020-02-18  5:58               ` Christophe Leroy
2020-02-18 10:29                 ` Masami Hiramatsu
2020-02-18 11:04                   ` Christophe Leroy
2020-02-18 12:33                     ` Masami Hiramatsu
2020-02-18 13:58                       ` Christophe Leroy [this message]
2020-02-18 14:06                       ` Naveen N. Rao
2020-02-15 10:19 ` Christophe Leroy

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=e9cb17f4-b698-7d9b-d435-e715ee14c489@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=Larry.Finger@lwfinger.net \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mhiramat@kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=stable@kernel.vger.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).