Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Masami Hiramatsu and committed by
Linus Torvalds
c39df470 2a8a3d5b

+3 -6
+3 -6
arch/i386/kernel/kprobes.c
··· 256 256 int ret = 0; 257 257 kprobe_opcode_t *addr; 258 258 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 264 259 265 260 addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t)); 266 261 ··· 333 338 return 1; 334 339 335 340 ss_probe: 336 - if (pre_preempt_count && p->ainsn.boostable == 1 && !p->post_handler){ 341 + #ifndef CONFIG_PREEMPT 342 + if (p->ainsn.boostable == 1 && !p->post_handler){ 337 343 /* Boost up -- we can execute copied instructions directly */ 338 344 reset_current_kprobe(); 339 345 regs->eip = (unsigned long)p->ainsn.insn; 340 346 preempt_enable_no_resched(); 341 347 return 1; 342 348 } 349 + #endif 343 350 prepare_singlestep(p, regs); 344 351 kcb->kprobe_status = KPROBE_HIT_SS; 345 352 return 1;