Files
linux/kernel
Masami Hiramatsu (Google) 081f8fba97 kprobes: Do not overwrite jump instruction when re-arming unoptimizing probe
When an optimized probe is temporarily disarmed or disabled,
unoptimize_kprobe() places it on the unoptimizing list, but leaves
the relative jump in text until the optimizer thread runs.
__disarm_kprobe() explicitly skips arch_disarm_kprobe() when
kprobe_queued_unopt(p) is true.

However, if __arm_kprobe() is called before the unoptimization pass
executes, it unconditionally calls arch_arm_kprobe(p), writing a
breakpoint instruction over the first byte of the jump while leaving the
trailing bytes intact. optimize_kprobe(p) then dequeues the probe from
the unoptimizing queue, leaving the jump opcode overwritten with a
breakpoint in text while KPROBE_FLAG_OPTIMIZED remains set.

Skip calling arch_arm_kprobe() in __arm_kprobe() when
kprobe_queued_unopt(p) is true, keeping the existing relative jump intact
while unoptimization is cancelled. If optimize_kprobe() cannot optimize
the probe (e.g. due to a post_handler or disabled optimization), force
unoptimization immediately.

Link: https://lore.kernel.org/all/179440642973.328088.10282643330198602134.stgit@devnote2/

Fixes: 06e0d3b89d ("kprobes: Make optprobe optimizer multi-generational and asynchronous")
Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
2026-11-13 17:32:56 +09:00
..
…
…
2026-09-28 08:44:41 +02:00
…
…
…
…
…
2026-11-11 12:32:07 +01:00
2026-10-12 11:13:01 +02:00
…
…
…
2026-10-24 00:46:49 -07:00
2026-01-26 19:07:13 -08:00
…
…
2026-09-04 12:46:45 +02:00