aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Capper <steve.capper@linaro.org>2015-04-07 12:28:39 +0100
committerSteven Capper <steve.capper@linaro.org>2015-04-07 12:58:40 +0100
commit53983a40dd70730a5d82ba6f53555752c402c5c8 (patch)
treee64c7c2870ee2cb88b5ffd05db7838ef825a8e29
parent1edea7323e9595d2fc3658710802099592a79e05 (diff)
downloadlinux-for-aram/uprobes.tar.gz
arm64: uprobes: check conditions before simulating instructionsfor-aram/uprobes
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>
-rw-r--r--arch/arm64/kernel/uprobes.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/arch/arm64/kernel/uprobes.c b/arch/arm64/kernel/uprobes.c
index 2cc9114deac..a6d12b81e9a 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;
}