Skip to content

Commit c39df47

Browse files
mhiramathitachiLinus Torvalds
authored andcommitted
[PATCH] kprobe-booster: disable in preemptible kernel
The kprobe-booster's safety check against preemption does not work well now, because the preemption count has been modified by read_rcu_lock() in atomic_notifier_call_chain() before we check it. So, I'd like to prevent boosting kprobe temporarily if the kernel is preemptable. Now we are searching for the good solution. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Prasanna S Panchamukhi <prasanna@in.ibm.com> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 2a8a3d5 commit c39df47

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎arch/i386/kernel/kprobes.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,6 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
256256
int ret = 0;
257257
kprobe_opcode_t *addr;
258258
struct kprobe_ctlblk *kcb;
259-
#ifdef CONFIG_PREEMPT
260-
unsigned pre_preempt_count = preempt_count();
261-
#else
262-
unsigned pre_preempt_count = 1;
263-
#endif
264259

265260
addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t));
266261

@@ -338,13 +333,15 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
338333
return 1;
339334

340335
ss_probe:
341-
if (pre_preempt_count && p->ainsn.boostable == 1 && !p->post_handler){
336+
#ifndef CONFIG_PREEMPT
337+
if (p->ainsn.boostable == 1 && !p->post_handler){
342338
/* Boost up -- we can execute copied instructions directly */
343339
reset_current_kprobe();
344340
regs->eip = (unsigned long)p->ainsn.insn;
345341
preempt_enable_no_resched();
346342
return 1;
347343
}
344+
#endif
348345
prepare_singlestep(p, regs);
349346
kcb->kprobe_status = KPROBE_HIT_SS;
350347
return 1;

0 commit comments

Comments
 (0)