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: 49998 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 140C4228CC for ; Thu, 18 Jun 2015 04:00:57 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf17155809lbb.0 for ; Wed, 17 Jun 2015 21:00:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=3JVrEEyFnPrwdzz3CVhei9iqLNse52TgQhO5o8O87ig=; b=j/zQoTuCVjdv5JQfYyz0POSZLsDv5Di154TV8mrpe4O+nMljwCN1zuh03UZeEHAHdv QWII0HgMx4wOCKfxbiFOOImvv3jubocRtxxkZC9OmmkHX9Du+qVbgKV0fkuvLrRGfm3c a1RKwXW+hQ7H/bALNGz9/6DdshjzstSHnFtmGS0+31PbE942vcLkr4yTsr6c5Ax/kjJl /Nce0HG6fHI459GdCFgWa6UQ/th/RKeOAkg4mPggar1FE3T0ousK9iUqJY74xi3wdnUP y/x5ZFUNq5Zc8BlPUkyN4poD1V5xGsBmLor/v59nHeIfFx1WFLaszchMtXFVpcyrLLLI RFig== X-Gm-Message-State: ALoCoQmXP4ttIeA7+8p0cepKplqX9h6Abyq2Sfz0m2g2gBA15+MHVZg4b0IS/bCaw7IfS1RA0pVu X-Received: by 10.180.106.10 with SMTP id gq10mr32964348wib.0.1434600056019; Wed, 17 Jun 2015 21:00:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.181.34 with SMTP id dt2ls379372lac.14.gmail; Wed, 17 Jun 2015 21:00:55 -0700 (PDT) X-Received: by 10.152.28.131 with SMTP id b3mr11117997lah.44.1434600055760; Wed, 17 Jun 2015 21:00:55 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id k11si5399344lbz.74.2015.06.17.21.00.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 21:00:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labko7 with SMTP id ko7so46422172lab.2 for ; Wed, 17 Jun 2015 21:00:55 -0700 (PDT) X-Received: by 10.112.140.231 with SMTP id rj7mr10975787lbb.76.1434600055662; Wed, 17 Jun 2015 21:00:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp898055lbb; Wed, 17 Jun 2015 21:00:54 -0700 (PDT) X-Received: by 10.70.130.198 with SMTP id og6mr17154967pdb.153.1434600052186; Wed, 17 Jun 2015 21:00:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yw5si9398751pbb.105.2015.06.17.21.00.51; Wed, 17 Jun 2015 21:00:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752768AbbFREAk (ORCPT + 30 others); Thu, 18 Jun 2015 00:00:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32878 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752500AbbFREAE (ORCPT ); Thu, 18 Jun 2015 00:00:04 -0400 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 Cc: linux-kernel@vger.kernel.org, wcohen@redhat.com, oleg@redhat.com, dave.long@linaro.org, steve.capper@linaro.org, srikar@linux.vnet.ibm.com, vijaya.kumar@caviumnetworks.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: panand@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; }