Skip to content

Commit 8a2d71a

Browse files
rnavmpe
authored andcommitted
powerpc/kprobes: Disable preemption before invoking probe handler for optprobes
Per Documentation/kprobes.txt, probe handlers need to be invoked with preemption disabled. Update optimized_callback() to do so. Also move get_kprobe_ctlblk() invocation post preemption disable, since it accesses pre-cpu data. This was not an issue so far since optprobes wasn't selected if CONFIG_PREEMPT was enabled. Commit a30b85d ("kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y") changes this. Signed-off-by: Naveen N. Rao <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent fc2a5a6 commit 8a2d71a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/powerpc/kernel/optprobes.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ static unsigned long can_optimize(struct kprobe *p)
115115
static void optimized_callback(struct optimized_kprobe *op,
116116
struct pt_regs *regs)
117117
{
118-
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
119118
unsigned long flags;
120119

121120
/* This is possible if op is under delayed unoptimizing */
@@ -124,13 +123,14 @@ static void optimized_callback(struct optimized_kprobe *op,
124123

125124
local_irq_save(flags);
126125
hard_irq_disable();
126+
preempt_disable();
127127

128128
if (kprobe_running()) {
129129
kprobes_inc_nmissed_count(&op->kp);
130130
} else {
131131
__this_cpu_write(current_kprobe, &op->kp);
132132
regs->nip = (unsigned long)op->kp.addr;
133-
kcb->kprobe_status = KPROBE_HIT_ACTIVE;
133+
get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
134134
opt_pre_handler(&op->kp, regs);
135135
__this_cpu_write(current_kprobe, NULL);
136136
}
@@ -140,6 +140,7 @@ static void optimized_callback(struct optimized_kprobe *op,
140140
* local_irq_restore() will re-enable interrupts,
141141
* if they were hard disabled.
142142
*/
143+
preempt_enable_no_resched();
143144
local_irq_restore(flags);
144145
}
145146
NOKPROBE_SYMBOL(optimized_callback);

0 commit comments

Comments
 (0)