Re: [PATCH 7/8] kprobes: Fix slot reclaim and sibling re-opt in optprobe state machine

From
Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date
2026-11-10 01:11:11
Reply to
sashiko-bot@kernel.org, 2026-11-04
On Wed, 04 Nov 2026 00:30:42 +0000, sashiko-bot@kernel.org [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] kprobes: slot leak and stale optinsn reuse via register_aggr_kprobe()
OK, this remains.
- [High] kprobes: missing arch_disarm_kprobe() in unoptimize_kprobe() on force
This has been fixed by Mani's patch. [1]
- [High] kprobes: premature unhash of rescued aggrprobe in add_new_kprobe()
This also fixed by Mani's patch [2]

[1] https://lore.kernel.org/all/20261105-kprobes-optprobe-state-v2-1-7a2f5290baa0@columbia.edu/ (local)
[2] https://lore.kernel.org/all/20261105-kprobes-optprobe-state-v2-3-7a2f5290baa0@columbia.edu/ (local)

[...]
quoted
 		}
 	}
 
@@ -1084,13 +1093,20 @@ static void kill_optimized_kprobe(struct kprobe *p)
 				list_del_init(&op->list);
 			}
 		} else {
-			list_del_init(&op->list);
+			if (optprobe_queued_unopt(op)) {
+				/* Move to cooling list so optinsn slot is cooled down */
+				list_move(&op->list,
+					  &optprobe_gens[optprobe_cur_gen].cooling_list);
+				kick_kprobe_optimizer();
+			} else if (!optprobe_queued_cooling(op) && !optprobe_queued_freeing(op)) {
+				list_del_init(&op->list);
+			}
 		}
 	}
 	op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED;
 
 	/*
-	 * Don't remove the slot if it is queued for freeing or unoptimization;
+	 * Don't remove the slot if it is queued for freeing, unoptimization, or cooling;
 	 * the optimizer will reclaim it after the quiescence period.
 	 */
 	if (!optprobe_queued_freeing(op) && !optprobe_queued_unopt(op) &&
[Severity: High]
Does deferring arch_remove_optimized_kprobe(op) here leak op->optinsn.insn or
reuse a stale optinsn trampoline if a new kprobe is registered at the same
virtual address before cooling completes?
Ah, yes, and we don't need to defer the killing gone kprobes because
that should not hit anymore. (which is in unloaded modules)
OK, let me drop deferring it.

Thanks!


-- 
Masami Hiramatsu (Google) [off-list ref]
Thread (18 messages) 18 messages, 2 authors, last reply 8d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help