From: Masami Hiramatsu <mhiramat@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Peter Zijlstra <peterz@infradead.org>,
x86@kernel.org, linux-kernel@vger.kernel.org, bristot@redhat.com,
jbaron@akamai.com, torvalds@linux-foundation.org,
tglx@linutronix.de, namit@vmware.com, hpa@zytor.com,
luto@kernel.org, ard.biesheuvel@linaro.org, jpoimboe@redhat.com,
jeyu@kernel.org, alexei.starovoitov@gmail.com,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: [PATCH -tip 0/2] x86/kprobes: Fix 2 issues related to text_poke_bp and optprobe
Date: Wed, 27 Nov 2019 14:56:41 +0900 [thread overview]
Message-ID: <157483420094.25881.9190014521050510942.stgit@devnote2> (raw)
Hi,
Here are the patches which I've faced while testing ftracetest
without function tracer. While investigating I found there were
2 different bugs there.
The 1st bug is a timing bug caused by wrong global variable
update and syncing in text_poke_bp_batch(). This can cause a
kernel panic if we hit int3 in between bp_patching.vec = NULL
and bp_patching.nr_entries = 0. This is actually a wrong order
and no synchronization. Steve suggested we can fix it with
reordering and adding sync_core() between them.
The 2nd bug is in the optprobe, which is caused by wrong flag
update order. Currently kprobes update optimized flag before
unoptimizing code. But if the kprobe is hit unoptimizing
intermediate state, it can go back from int3 to the middle of
modified instruction and cause a kernel panic. This can be
fixed by updating flag after unoptimized code.
Thank you,
---
Masami Hiramatsu (2):
x86/alternative: Sync bp_patching update for avoiding NULL pointer exception
kprobes: Set unoptimized flag after unoptimizing code
arch/x86/kernel/alternative.c | 8 +++++++-
kernel/kprobes.c | 4 +++-
2 files changed, 10 insertions(+), 2 deletions(-)
--
Masami Hiramatsu (Linaro) <mhiramat@kernel.org>
next reply other threads:[~2019-11-27 5:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-27 5:56 Masami Hiramatsu [this message]
2019-11-27 5:56 ` [PATCH -tip 1/2] x86/alternative: Sync bp_patching update for avoiding NULL pointer exception Masami Hiramatsu
2019-12-02 9:15 ` Peter Zijlstra
2019-12-02 11:50 ` Masami Hiramatsu
2019-12-02 13:43 ` Peter Zijlstra
2019-12-02 14:39 ` Masami Hiramatsu
2019-12-04 8:33 ` [tip: core/kprobes] x86/alternatives: " tip-bot2 for Masami Hiramatsu
2019-12-09 14:39 ` [PATCH -tip 1/2] x86/alternative: " Peter Zijlstra
2019-12-10 16:44 ` Masami Hiramatsu
2019-12-10 17:32 ` Peter Zijlstra
2019-12-11 0:09 ` Peter Zijlstra
2019-12-11 8:09 ` Masami Hiramatsu
2019-12-11 9:12 ` Daniel Bristot de Oliveira
2019-11-27 5:57 ` [PATCH -tip 2/2] kprobes: Set unoptimized flag after unoptimizing code Masami Hiramatsu
2019-11-27 6:19 ` Alexei Starovoitov
2019-11-27 6:49 ` Ingo Molnar
2019-12-02 21:55 ` Alexei Starovoitov
2019-11-27 6:56 ` Masami Hiramatsu
2019-12-04 8:33 ` [tip: core/kprobes] " tip-bot2 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=157483420094.25881.9190014521050510942.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=ard.biesheuvel@linaro.org \
--cc=bristot@redhat.com \
--cc=hpa@zytor.com \
--cc=jbaron@akamai.com \
--cc=jeyu@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=namit@vmware.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.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