From patchwork Thu Jun 18 03:58:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 6632991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ACEE69F326 for ; Thu, 18 Jun 2015 04:04:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0D1220675 for ; Thu, 18 Jun 2015 04:04:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 01FA520671 for ; Thu, 18 Jun 2015 04:04:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5R27-0006C7-AY; Thu, 18 Jun 2015 04:02:31 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5R05-0003Uh-5E for linux-arm-kernel@lists.infradead.org; Thu, 18 Jun 2015 04:00:26 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 30AB7362081; Thu, 18 Jun 2015 04:00:04 +0000 (UTC) Received: from localhost (vpn-48-37.rdu2.redhat.com [10.10.48.37]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5I402nL032426; Thu, 18 Jun 2015 00:00:03 -0400 From: Pratyush Anand To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com Subject: [RFC PATCH V2 10/10] arm64: uprobes: check conditions before simulating instructions Date: Thu, 18 Jun 2015 09:28:57 +0530 Message-Id: <350cf38eb8b9008d14a51ef7e0f8099644c8b97f.1434598237.git.panand@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150617_210025_282834_5C07E731 X-CRM114-Status: GOOD ( 11.47 ) X-Spam-Score: -5.6 (-----) Cc: steve.capper@linaro.org, srikar@linux.vnet.ibm.com, vijaya.kumar@caviumnetworks.com, linux-kernel@vger.kernel.org, oleg@redhat.com, dave.long@linaro.org, wcohen@redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Steve Capper 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 --- 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; }