summaryrefslogtreecommitdiff
path: root/kernel/kprobes.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-10-02 17:34:18 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-10-02 17:34:18 -0700
commite767a4ea70a3992c37ed604157d32f0dfbf9b1e3 (patch)
tree7cca9c9cd6221921d03ab4daea0eecc571258b51 /kernel/kprobes.c
parentff47652a4b66c067c765a7ad464d930b5a9367cc (diff)
parent7a39c732a22ec4a369af9e19fbe3d666ec83eec4 (diff)
Merge tag 'probes-fixes-v7.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull probes fixes from Masami Hiramatsu: - fprobe: Use guard(rcu_sched_notrace) and check rcu_is_watching() Exit handlers early if !rcu_is_watching() to prevent potential use-after-free during unregistration in idle/quiescent states. Switch to guard(rcu_sched_notrace) to avoid fast-path lockdep overhead and recursion while ensuring safe grace period synchronization. - kprobes: Skip disarmed probes when checking optkprobe overlap Continue past disarmed or unprepared probes in get_optimized_kprobe() to find active optimized probes. This avoids overwriting active jump displacements which can lead to panic. * tag 'probes-fixes-v7.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: kprobes: Skip disarmed probes when checking optkprobe overlap fprobe: Use guard(rcu_sched_notrace) and check rcu_is_watching()
Diffstat (limited to 'kernel/kprobes.c')
-rw-r--r--kernel/kprobes.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 4edd8ca5c657..e787e4948c8b 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -496,14 +496,16 @@ static bool kprobe_queued(struct kprobe *p)
static struct kprobe *get_optimized_kprobe(kprobe_opcode_t *addr)
{
int i;
- struct kprobe *p = NULL;
+ struct kprobe *p;
struct optimized_kprobe *op;
/* Don't check i == 0, since that is a breakpoint case. */
- for (i = 1; !p && i < MAX_OPTIMIZED_LENGTH / sizeof(kprobe_opcode_t); i++)
+ for (i = 1; i < MAX_OPTIMIZED_LENGTH / sizeof(kprobe_opcode_t); i++) {
p = get_kprobe(addr - i);
+ /* A disabled probe can have prepared, but inactive, optinsns. */
+ if (!p || !kprobe_optready(p) || kprobe_disarmed(p))
+ continue;
- if (p && kprobe_optready(p)) {
op = container_of(p, struct optimized_kprobe, kp);
if (arch_within_optimized_kprobe(op, addr))
return p;