Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1575795 > unrolled thread
| Started by | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| First post | 2017-02-07 16:20 +0100 |
| Last post | 2017-02-08 23:00 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[BUGFIX PATCH tip/master 2/3] kprobes/arm64: Fix a possible deadlock case in kretprobe Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-07 16:20 +0100
Re: [BUGFIX PATCH tip/master 2/3] kprobes/arm64: Fix a possible deadlock case in kretprobe Will Deacon <will.deacon@arm.com> - 2017-02-08 16:30 +0100
Re: [BUGFIX PATCH tip/master 2/3] kprobes/arm64: Fix a possible deadlock case in kretprobe Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-08 23:00 +0100
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2017-02-07 16:20 +0100 |
| Subject | [BUGFIX PATCH tip/master 2/3] kprobes/arm64: Fix a possible deadlock case in kretprobe |
| Message-ID | <t8fIJ-4zi-5@gated-at.bofh.it> |
Similar to x86 kretprobe deadlock issue, arm64 also implements
kretprobe-booster (trampoline code directly call handler.)
So it has same deadlock issue if there are 2 kretprobes on
normal function and the function called from FIQ (or anywhere
which can be invoked when local_irq_disabled).
This fixes the issue as same as we did on x86.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
arch/arm64/kernel/probes/kprobes.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 2a07aae..401f7c9 100644
--- a/arch/arm64/kernel/probes/kprobes.c
+++ b/arch/arm64/kernel/probes/kprobes.c
@@ -561,6 +561,8 @@ bool arch_within_kprobe_blacklist(unsigned long addr)
return false;
}
+static struct kprobe dummy_retprobe = {.addr = (void *)&kretprobe_trampoline};
+
void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs)
{
struct kretprobe_instance *ri = NULL;
@@ -572,6 +574,11 @@ void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs)
kprobe_opcode_t *correct_ret_addr = NULL;
INIT_HLIST_HEAD(&empty_rp);
+
+ /* This prevents kernel to change running cpu while processing */
+ preempt_disable();
+ get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
+ __this_cpu_write(current_kprobe, &dummy_retprobe);
kretprobe_hash_lock(current, &head, &flags);
/*
@@ -614,10 +621,9 @@ void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs)
orig_ret_address = (unsigned long)ri->ret_addr;
if (ri->rp && ri->rp->handler) {
__this_cpu_write(current_kprobe, &ri->rp->kp);
- get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
ri->ret_addr = correct_ret_addr;
ri->rp->handler(ri, regs);
- __this_cpu_write(current_kprobe, NULL);
+ __this_cpu_write(current_kprobe, &dummy_retprobe);
}
recycle_rp_inst(ri, &empty_rp);
@@ -632,6 +638,8 @@ void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs)
}
kretprobe_hash_unlock(current, &flags);
+ __this_cpu_write(current_kprobe, NULL);
+ preempt_enable_no_resched();
hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist);
[toc] | [next] | [standalone]
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Date | 2017-02-08 16:30 +0100 |
| Subject | Re: [BUGFIX PATCH tip/master 2/3] kprobes/arm64: Fix a possible deadlock case in kretprobe |
| Message-ID | <t8ClY-20B-25@gated-at.bofh.it> |
| In reply to | #1575795 |
[adding linux-arm-kernel] On Wed, Feb 08, 2017 at 12:13:14AM +0900, Masami Hiramatsu wrote: > Similar to x86 kretprobe deadlock issue, arm64 also implements > kretprobe-booster (trampoline code directly call handler.) > So it has same deadlock issue if there are 2 kretprobes on > normal function and the function called from FIQ (or anywhere > which can be invoked when local_irq_disabled). We don't support FIQ on arm64, so I'm not worried about that particular case. What are the other cases? I can think of debug exceptions, but those shouldn't be generally kprobe-able, and taking data aborts in things like get_user/put_user. Are those affected by this bug? Either way, could you please expand the commit message like you have for x86? It makes it much easier to understand the change when looking back at the log in future. Thanks, Will
[toc] | [prev] | [next] | [standalone]
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Date | 2017-02-08 23:00 +0100 |
| Subject | Re: [BUGFIX PATCH tip/master 2/3] kprobes/arm64: Fix a possible deadlock case in kretprobe |
| Message-ID | <t8Iro-5Hm-27@gated-at.bofh.it> |
| In reply to | #1576650 |
On Wed, 8 Feb 2017 15:06:55 +0000 Will Deacon <will.deacon@arm.com> wrote: > [adding linux-arm-kernel] > > On Wed, Feb 08, 2017 at 12:13:14AM +0900, Masami Hiramatsu wrote: > > Similar to x86 kretprobe deadlock issue, arm64 also implements > > kretprobe-booster (trampoline code directly call handler.) > > So it has same deadlock issue if there are 2 kretprobes on > > normal function and the function called from FIQ (or anywhere > > which can be invoked when local_irq_disabled). > > We don't support FIQ on arm64, so I'm not worried about that particular > case. What are the other cases? I can think of debug exceptions, but those > shouldn't be generally kprobe-able, and taking data aborts in things like > get_user/put_user. Are those affected by this bug? Hmm, in that case, this may not needed at this point. Would you have any plan to support FIQ like as NMI in x86? If something can interrupt while the critical region between spin_lock_irqsave() and spin_unlock_irqrestore(), and it can be kprobe'd, it is safer to apply this patch. > Either way, could you please expand the commit message like you have > for x86? It makes it much easier to understand the change when looking > back at the log in future. Ah, sorry. I will update the comment. Thank you, > > Thanks, > > Will -- Masami Hiramatsu <mhiramat@kernel.org>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web