On Wed, 04 Nov 2026 00:25:03 +0000, sashiko-bot@kernel.org [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] kprobes: unreachable kprobe_unused() branch in unoptimize_kprobe()
--
commit c6680d6b1b284ca1b2cdf402fac410e5adfc1db4
Author: Masami Hiramatsu (Google) [off-list ref]
kprobes: Fix UAF and queue cooling probes on forced unoptimization
This patch fixes a use-after-free on forced unoptimization of an active
optimized kprobe by queueing the probe onto the current generation's list
and waiting for a Tasks RCU grace period before freeing it. It also separates
newly unoptimized probes into a local list in do_unoptimize_kprobes() so
probes already on freeing_list are not disarmed twice.
quoted
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 135fec5d49cf5..ceacd56245c24 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
[ ... ]
quoted
@@ -1039,6 +1039,15 @@ static void unoptimize_kprobe(struct kprobe *p, bool force)
if (force) {
/* Forcibly update the code: this is a special case */
force_unoptimize_kprobe(op);
+ if (kprobe_unused(&op->kp)) {
+ if (!kprobe_gone(&op->kp))
+ arch_disarm_kprobe(&op->kp);
+ hlist_del_init_rcu(&op->kp.hlist);
+ list_add(&op->list, &cur->freeing_list);
+ } else {
+ list_add(&op->list, &cur->cooling_list);
+ }
+ kick_kprobe_optimizer();
[Severity: Low]
Can kprobe_unused(&op->kp) ever evaluate to true here?
At the start of unoptimize_kprobe(), the function checks:
if (!kprobe_aggrprobe(p) || kprobe_disarmed(p))
return; /* This is not an optprobe nor optimized */
where kprobe_disarmed(p) for an aggregator probe is:
return kprobe_disabled(p) && list_empty(&op->list);
And earlier in unoptimize_kprobe(), the !list_empty(&op->list) block handles
all probes already on a list and returns.
Oops, indeed. OK, let's drop that branch.
Thanks,
--
Masami Hiramatsu (Google) [off-list ref]