From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Naveen N Rao <naveen@kernel.org>,
"David S . Miller" <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Mani Tofigh <mt4022@columbia.edu>
Subject: [PATCH v3 0/5] kprobes: Fixes for ftrace ops and optprobe state machine
Date: Wed, 11 Nov 2026 23:13:21 +0900 [thread overview]
Message-ID: <179440640176.328088.17106877243326801914.stgit@devnote2> (raw)
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>
next reply other threads:[~2026-11-11 14:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 14:13 Masami Hiramatsu (Google) [this message]
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)
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=179440640176.328088.17106877243326801914.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mt4022@columbia.edu \
--cc=naveen@kernel.org \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®