Skip to content

x86/kprobes: Fix 2 issues related to text_poke_bp and optprobe

Masami Hiramatsu lkml 1 version Applied

Status from this message: The following commit has been merged into the core/kprobes branch of tip:

Get series with b4
b4 am 157483420094.25881.9190014521050510942.stgit@devnote2

Versions newest first

  1. v1 Latest2 patches 14 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2x86/alternative: Sync bp_patching update for avoiding NULL pointer exceptionarch/x86/kernel/alternative.c+7 -110 replies
2/2kprobes: Set unoptimized flag after unoptimizing codekernel/kprobes.c+3 -14 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchAlexei StarovoitovMasami HiramatsuDaniel Bristot de Oliveira
1/2R-b R-b
2/2T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH -tip 0/2] x86/kprobes: Fix 2 issues related to text_poke_bp and optprobe

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) <[email protected]>