All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] kprobes: Fixes for ftrace ops and optprobe state machine
@ 2026-11-11 14:13 Masami Hiramatsu (Google)
  2026-11-11 14:13 ` [PATCH v3 1/5] kprobes: Switch ftrace ops when adding probe with post_handler Masami Hiramatsu (Google)
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-11-11 14:13 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Naveen N Rao, David S . Miller
  Cc: linux-kernel, linux-trace-kernel, Mani Tofigh

Hi,

Here is v3 of the remaining bug fixes for kprobes and optprobes.
The previous version is here:

  https://lore.kernel.org/all/179427358690.291326.2078291446658598883.stgit@devnote2/

This version restores __arm_kprobe() fix as patch 3, and update the KUnit
test code to check it.
This includes following fixes.

1. Ftrace Ops Switching for Post-Handlers (Patch 1):
   - When adding a second probe with a post_handler to an existing ftrace
     kprobe, the aggregate probe's post_handler was set but remained armed
     on kprobe_ftrace_ops. Subsequent disarming attempted to disarm from
     kprobe_ipmodify_ops, failing with -ENOENT and leaking the armed probe.
     Switch ftrace ops safely in register_aggr_kprobe() outside of
     text_mutex and cpus_read_lock.

2. Optprobe State Machine & Tasks RCU Quiescence (Patches 2-4):
   - Forcibly unoptimized probes (unoptimize_kprobe(force = true)) were
     not queued to cooling_list, causing kprobe_disarmed() to return true
     prematurely and risking use-after-free in the optinsn detour buffer
     before Tasks RCU completed.
   - When re-arming a probe that is queued on unoptimizing_list before the
     optimizer thread runs, skip arch_arm_kprobe() in __arm_kprobe() so
     the active jump instruction is not overwritten with a breakpoint.
   - When a disabled cooling probe finishes cooling and transitions to
     safely disarmed in optprobe_finalize_generation(), re-optimize any
     blocked sibling probe whose jump range covers its address.

3. KUnit Regression Tests (Patch 5):
   - Add KUnit test cases to lib/tests/test_kprobes.c covering the recent
     kprobes, kretprobes, ftrace ops, and optprobe fixes.

Changes in v3:
[03/05]
 - Restore the __arm_kprobe() fix that was accidentally dropped in v2
   while omitting the reuse_unused_kprobe() hunk superseded by commit
   1ffd6efb1b58 ("kprobes: Arm reused optprobe on cooling list").
[05/05]
 - Check that the jump opcode at *opt_kp.addr is preserved across
   disable_kprobe() and enable_kprobe() in
   test_optprobe_rearm_unoptimizing().

Thank you,

---
base-commit: 1ffd6efb1b58e596ed70f660182803264a4c84d9

Masami Hiramatsu (Google) (5):
      kprobes: Switch ftrace ops when adding probe with post_handler
      kprobes: Fix UAF and queue cooling probes on forced unoptimization
      kprobes: Do not overwrite jump instruction when re-arming unoptimizing probe
      kprobes: Re-optimize blocked sibling probe when cooling finishes
      kprobes: Add KUnit test cases for kprobes regressions


 kernel/kprobes.c         |  116 +++++++++++++++++++++++++++-----------
 lib/tests/test_kprobes.c |  139 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 220 insertions(+), 35 deletions(-)

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-11 14:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 14:13 [PATCH v3 0/5] kprobes: Fixes for ftrace ops and optprobe state machine Masami Hiramatsu (Google)
2026-11-11 14:13 ` [PATCH v3 1/5] kprobes: Switch ftrace ops when adding probe with post_handler Masami Hiramatsu (Google)
2026-11-11 14:13 ` [PATCH v3 2/5] kprobes: Fix UAF and queue cooling probes on forced unoptimization Masami Hiramatsu (Google)
2026-11-11 14:13 ` [PATCH v3 3/5] kprobes: Do not overwrite jump instruction when re-arming unoptimizing probe Masami Hiramatsu (Google)
2026-11-11 14:13 ` [PATCH v3 4/5] kprobes: Re-optimize blocked sibling probe when cooling finishes Masami Hiramatsu (Google)
2026-11-11 14:14 ` [PATCH v3 5/5] kprobes: Add KUnit test cases for kprobes regressions Masami Hiramatsu (Google)

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.