All of lore.kernel.org
 help / color / mirror / Atom feed
* Is ARM kprobes unregistration SMP safe?
@ 2009-09-02 10:22 Frederic Riss
  0 siblings, 0 replies; only message in thread
From: Frederic Riss @ 2009-09-02 10:22 UTC (permalink / raw)
  To: nico, sagar.abhishek; +Cc: Linux Kernel Mailing List

[Sorry if you get that mail twice. Made a silly email typo in the
first version.]

Hi,

ARM kprobes are using an illegal instruction to trigger the kprobe
code. the trap handler looks like that:

asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
{
       unsigned int instr;

       pc = (void __user *)instruction_pointer(regs);

       instr = *(u32 *) pc;

       /*
        * It is possible to have recursive kprobes, so we can't call
        * the kprobe trap handler with the undef_lock held.
        */
       if (instr == KPROBE_BREAKPOINT_INSTRUCTION && !user_mode(regs)) {
               kprobe_trap_handler(regs, instr);
               return;
       }
       [...]
}

And in arch/arm/kernel/kprobes.c we have:

void __kprobes arch_disarm_kprobe(struct kprobe *p)
{
       *p->addr = p->opcode;
       flush_insns(p->addr, 1);
}

In an SMP system, I don't see what prevents a core to take the
undefined instruction exception while the other core is unregistering the
corresponding kprobe. With the right timing, at the time the exception
handler reads the patched instruction, it can have been 'unpatched' by
arch_disarm_kprobe, and thus fail the KPROBE_BREAKPOINT_INSTRUCTION
test. Shouldn't arch_disarm_kprobe use stop_machine or something like
that?

Fred.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-02 10:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-02 10:22 Is ARM kprobes unregistration SMP safe? Frederic Riss

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.