From: Frederic Riss <frederic.riss@gmail.com>
To: nico@cam.org, sagar.abhishek@gmail.com
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Is ARM kprobes unregistration SMP safe?
Date: Wed, 2 Sep 2009 12:22:14 +0200 [thread overview]
Message-ID: <87d3b2040909020322i40c09445t4555ffe5cb5b3e13@mail.gmail.com> (raw)
[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.
reply other threads:[~2009-09-02 10:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d3b2040909020322i40c09445t4555ffe5cb5b3e13@mail.gmail.com \
--to=frederic.riss@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nico@cam.org \
--cc=sagar.abhishek@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®