Skip to content

RFC x86/ftrace: fix live patching vs. tracing race

Nicolai Stange lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest1 patch 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1x86/ftrace: make ftrace_int3_handler() not to skip fops invocationarch/x86/kernel/ftrace.c arch/x86/kernel/ftrace_64.S+97 -75 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/1] x86/ftrace: fix live patching vs. tracing race

Hi,

if a user starts to trace a live patched function, its mcount call will get redirected from a trampoline to ftrace_regs_caller.

In preparation for that, ftrace on x86 first installs an int3 insn at that call site.

ftrace_int3_handler() in turn simply skips over the mcount call insn, effectively reverting the livepatch for that function during ftrace_replace_code().

This breaks KLP's consistency model.

There are two possible options for fixing this:
1.) At the ftrace level.
2.) Search for a matching klp_ops from ftrace_int3_handler() and
handle the redirection if needed.

Both have their drawbacks, hence the RFC mode for this patch implementing 1.).

The main disadvantage is that it doesn't work on 32 bits (c.f. the patch description), but for KLP this would be fine.

OTOH, it keeps KLP specific code out of ftrace_int3_handler() and might perhaps be beneficial in other contexts as well.

Thanks for your comments!

Nicolai

Nicolai Stange (1):
x86/ftrace: make ftrace_int3_handler() not to skip fops invocation

 arch/x86/kernel/ftrace.c    | 48 ++++++++++++++++++++++++++++++++------
 arch/x86/kernel/ftrace_64.S | 56 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+), 7 deletions(-)
Signature · 1 line
2.13.7