All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>, Ingo Molnar <mingo@kernel.org>
Cc: X86 ML <x86@kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>,
	Daniel Xu <dxu@dxuuu.xyz>,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
	kuba@kernel.org, mingo@redhat.com, ast@kernel.org,
	tglx@linutronix.de, kernel-team@fb.com, yhs@fb.com,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [RFC PATCH -tip 0/3] x86/kprobes,orc: Fix ORC unwinder to unwind stack with optimized probe
Date: Wed, 31 Mar 2021 14:44:24 +0900	[thread overview]
Message-ID: <161716946413.721514.4057380464113663840.stgit@devnote2> (raw)

Hello,

These patches fixes the ORC unwinder to unwind optprobe trampoline
code on the stack correctly.
This patchset is based on the kretporbe and stacktrace fix series v5
which I sent last week.

https://lore.kernel.org/bpf/161676170650.330141.6214727134265514123.stgit@devnote2/

Note that I just confirmed the it fixes the case where the 
stacktrace called from the optprobe handler. So this should be
carefully reviewed.


Here is the test code;

cd /sys/kernel/debug/tracing
echo > trace
echo p full_proxy_read+5 >> kprobe_events
echo 1 > events/kprobes/enable
sleep 1 # wait for optimization
echo stacktrace:1 > events/kprobes/p_full_proxy_read_5/trigger
echo 1 > options/sym-offset
cat /sys/kernel/debug/kprobes/list


Without this,

             cat-138     [001] ...1     6.567662: p_full_proxy_read_5: (full_proxy_read+0x5/0x80)
             cat-138     [001] ...1     6.567711: <stack trace>
 => kprobe_trace_func+0x1d0/0x2c0
 => kprobe_dispatcher+0x39/0x60
 => opt_pre_handler+0x4f/0x80
 => optimized_callback+0xc3/0xf0
 => 0xffffffffa0006032
 => 0
 => 0


With this patch,

             cat-137     [007] ...1    17.542848: p_full_proxy_read_5: (full_proxy_read+0x5/0x80)
             cat-137     [007] ...1    17.542963: <stack trace>
 => kprobe_trace_func+0x1d0/0x2c0
 => kprobe_dispatcher+0x39/0x60
 => opt_pre_handler+0x4f/0x80
 => optimized_callback+0xc3/0xf0
 => full_proxy_read+0x5/0x80
 => vfs_read+0xab/0x1a0
 => ksys_read+0x5f/0xe0
 => do_syscall_64+0x33/0x40
 => entry_SYSCALL_64_after_hwframe+0x44/0xae
 => 0
 => 0


Thank you,

---

Masami Hiramatsu (3):
      x86/kprobes: Add ORC information to optprobe template
      kprobes: Add functions to find instruction buffer entry address
      x86/kprobes,orc: Unwind optprobe trampoline correctly


 arch/x86/include/asm/kprobes.h |    6 +++
 arch/x86/kernel/kprobes/opt.c  |   72 +++++++++++++++++++++++++++++++++++++---
 arch/x86/kernel/unwind_orc.c   |   15 +++++++-
 include/linux/kprobes.h        |    8 ++++
 kernel/kprobes.c               |   25 ++++++++++----
 5 files changed, 111 insertions(+), 15 deletions(-)

--
Masami Hiramatsu (Linaro) <mhiramat@kernel.org>

             reply	other threads:[~2021-03-31  5:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31  5:44 Masami Hiramatsu [this message]
2021-03-31  5:44 ` [RFC PATCH -tip 1/3] x86/kprobes: Add ORC information to optprobe template Masami Hiramatsu
2021-03-31  5:44 ` [RFC PATCH -tip 2/3] kprobes: Add functions to find instruction buffer entry address Masami Hiramatsu
2021-03-31  5:44 ` [RFC PATCH -tip 3/3] x86/kprobes,orc: Unwind optprobe trampoline correctly Masami Hiramatsu
2021-03-31 15:57   ` Josh Poimboeuf
2021-04-01  1:44     ` Masami Hiramatsu
2021-04-01  2:19       ` Masami Hiramatsu
2021-04-01  1:54   ` 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=161716946413.721514.4057380464113663840.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dxu@dxuuu.xyz \
    --cc=jpoimboe@redhat.com \
    --cc=kernel-team@fb.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yhs@fb.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.