mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Zhongjin <chenzhongjin@huawei.com>
To: Jiri Olsa <olsajiri@gmail.com>, Steven Rostedt <rostedt@goodmis.org>
Cc: <linux-kernel@vger.kernel.org>, <bpf@vger.kernel.org>,
	<naveen.n.rao@linux.ibm.com>, <anil.s.keshavamurthy@intel.com>,
	<davem@davemloft.net>, <mhiramat@kernel.org>,
	<peterz@infradead.org>, <mingo@kernel.org>, <ast@kernel.org>,
	<daniel@iogearbox.net>
Subject: Re: [PATCH v3] kprobes: Forbid probing on trampoline and bpf prog
Date: Tue, 2 Aug 2022 20:28:39 +0800	[thread overview]
Message-ID: <e3993e00-9346-9e0d-7490-76ffb713f343@huawei.com> (raw)
In-Reply-To: <YujpFUB8KlkOgzyb@krava>


On 2022/8/2 17:06, Jiri Olsa wrote:
> On Mon, Aug 01, 2022 at 04:51:46PM -0400, Steven Rostedt wrote:
>> On Mon, 1 Aug 2022 22:41:19 +0200
>> Jiri Olsa <olsajiri@gmail.com> wrote:
>>
>>> LGTM cc-ing Steven because it affects ftrace as well
>> Thanks for the Cc, but I don't quite see how it affects ftrace.
>>
>> Unless you are just saying how it can affect kprobe_events?
> nope, I just saw the 'ftrace' in changelog ;-)
>
> anyway the patch makes check_kprobe_address_safe to fail
> on ftrace trampoline address.. but not sure you could make
> kprobe on ftrace trampoline before, probably not
>
> jirka

In fact with CONFIG_KPROBE_EVENTS_ON_NOTRACE=y it can happen.

But I think ftrace has no responsibility to promise the address safety 
when this option open.


Best,

Chen

>> -- Steve
>>
>>
>>> jirka
>>>
>>>> v1 -> v2:
>>>> Check core_kernel_text and is_module_text_address rather than
>>>> only kprobe_insn.
>>>> Also fix title and commit message for this. See old patch at [1].
>>>> ---
>>>>   kernel/kprobes.c | 3 ++-
>>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
>>>> index f214f8c088ed..80697e5e03e4 100644
>>>> --- a/kernel/kprobes.c
>>>> +++ b/kernel/kprobes.c
>>>> @@ -1560,7 +1560,8 @@ static int check_kprobe_address_safe(struct kprobe *p,
>>>>   	preempt_disable();
>>>>   
>>>>   	/* Ensure it is not in reserved area nor out of text */
>>>> -	if (!kernel_text_address((unsigned long) p->addr) ||
>>>> +	if (!(core_kernel_text((unsigned long) p->addr) ||
>>>> +	    is_module_text_address((unsigned long) p->addr)) ||
>>>>   	    within_kprobe_blacklist((unsigned long) p->addr) ||
>>>>   	    jump_label_text_reserved(p->addr, p->addr) ||
>>>>   	    static_call_text_reserved(p->addr, p->addr) ||
>>>> -- 
>>>> 2.17.1
>>>>    


  reply	other threads:[~2022-08-02 12:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01  3:37 Chen Zhongjin
2022-08-01 20:41 ` Jiri Olsa
2022-08-01 20:51   ` Steven Rostedt
2022-08-01 23:29     ` Masami Hiramatsu
2022-08-02  9:06     ` Jiri Olsa
2022-08-02 12:28       ` Chen Zhongjin [this message]
2022-08-01 23:28 ` Masami Hiramatsu
2022-08-02  9:55 ` [tip: perf/urgent] kprobes: Forbid probing on trampoline and BPF code areas tip-bot2 for Chen Zhongjin

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=e3993e00-9346-9e0d-7490-76ffb713f343@huawei.com \
    --to=chenzhongjin@huawei.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=olsajiri@gmail.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

all inboxes | Powered by JetHome®