lkml.org 
[lkml]   [2015]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH V2 10/10] arm64: uprobes: check conditions before simulating instructions
Date
From: Steve Capper <steve.capper@linaro.org>

Currently uprobes just simulates any instruction that it can't in
place execute. This can lead to unpredictable behaviour if the
execution condition fails and the instruction wouldn't otherwise
have been executed.

This patch adds the condition check

Signed-off-by: Steve Capper <steve.capper@linaro.org>
---
arch/arm64/kernel/uprobes.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/uprobes.c b/arch/arm64/kernel/uprobes.c
index 2cc9114deac2..a6d12b81e9ae 100644
--- a/arch/arm64/kernel/uprobes.c
+++ b/arch/arm64/kernel/uprobes.c
@@ -119,15 +119,22 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
{
kprobe_opcode_t insn;
unsigned long addr;
+ struct arch_specific_insn *ainsn;

if (!auprobe->simulate)
return false;

insn = *(kprobe_opcode_t *)(&auprobe->insn[0]);
addr = instruction_pointer(regs);
+ ainsn = &auprobe->ainsn;
+
+ if (ainsn->handler) {
+ if (!ainsn->check_condn || ainsn->check_condn(insn, ainsn, regs))
+ ainsn->handler(insn, addr, regs);
+ else
+ instruction_pointer_set(regs, instruction_pointer(regs) + 4);
+ }

- if (auprobe->ainsn.handler)
- auprobe->ainsn.handler(insn, addr, regs);

return true;
}
--
2.1.0


\
 
 \ /
  Last update: 2015-06-18 06:21    [W:0.268 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site