From patchwork Mon Oct 13 13:48:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 38648 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1C2AB2039B for ; Mon, 13 Oct 2014 13:50:17 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf4233008lam.8 for ; Mon, 13 Oct 2014 06:50:16 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=s9smPf/jROGOxQOMDMqwf6pS2E/I1XkM0Gat2MN4xno=; b=ZUzy6/e+X7cGzJZnUy5FwNRosyJ0huyHVL3m64xlCUsAeTZdwU/vLzB+CveM+NS6W4 maZdZPB2Is1kAEH7Nh8FhYI9FiDyCCNEdC7jwFUPksmD4w7K9mJAS+6imOn2qNznKd/+ kVKiW4+5vDdYM5wtq4kq9QcYWF6TCuWxZywjFdiqYbajh+a97xVP7UibHLmQn0Rn/xyl WcbKCj9cN8meMIu8UNC8gCLSC/kSXYKHtlW+UatuX5UreED4XhwMz6qN5a4dSoDaBORU fEgfatsrlHpt6++16ZZBbKyrC+siPCbO5COxl97Z8Z7CIhZty6GrGj6UKQDhdtsjewWR 3XxA== X-Gm-Message-State: ALoCoQmZltcWMY8HarISY/PYqc00cA+dlQHg9eHnBqZkl4BcGWTaYXHhNgPYjHbRLwc+2t1YfuFP X-Received: by 10.112.140.199 with SMTP id ri7mr25845lbb.17.1413208216905; Mon, 13 Oct 2014 06:50:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.130 with SMTP id l2ls458429lag.45.gmail; Mon, 13 Oct 2014 06:50:16 -0700 (PDT) X-Received: by 10.152.10.2 with SMTP id e2mr3068295lab.96.1413208216784; Mon, 13 Oct 2014 06:50:16 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by mx.google.com with ESMTPS id ci7si22405928lad.21.2014.10.13.06.50.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Oct 2014 06:50:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id s18so6716175lam.37 for ; Mon, 13 Oct 2014 06:50:16 -0700 (PDT) X-Received: by 10.152.7.145 with SMTP id j17mr23880331laa.67.1413208216674; Mon, 13 Oct 2014 06:50:16 -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.84.229 with SMTP id c5csp217436lbz; Mon, 13 Oct 2014 06:50:15 -0700 (PDT) X-Received: by 10.68.201.67 with SMTP id jy3mr23498039pbc.81.1413208213821; Mon, 13 Oct 2014 06:50:13 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si10368565pat.185.2014.10.13.06.50.13 for ; Mon, 13 Oct 2014 06:50:13 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754914AbaJMNuK (ORCPT + 1 other); Mon, 13 Oct 2014 09:50:10 -0400 Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:57209 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754682AbaJMNuF (ORCPT ); Mon, 13 Oct 2014 09:50:05 -0400 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.83) (envelope-from ) id 1Xdg0f-0003pj-RW; Mon, 13 Oct 2014 15:50:01 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: Will Deacon , Jiri Slaby Subject: [patch added to the 3.12 stable tree] arm64: ptrace: fix compat hardware watchpoint reporting Date: Mon, 13 Oct 2014 15:48:34 +0200 Message-Id: <1413208201-14602-3-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1413208201-14602-1-git-send-email-jslaby@suse.cz> References: <1413208201-14602-1-git-send-email-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org 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.50 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: Will Deacon This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit 27d7ff273c2aad37b28f6ff0cab2cfa35b51e648 upstream. I'm not sure what I was on when I wrote this, but when iterating over the hardware watchpoint array (hbp_watch_array), our index is off by ARM_MAX_BRP, so we walk off the end of our thread_struct... ... except, a dodgy condition in the loop means that it never executes at all (bp cannot be NULL). This patch fixes the code so that we remove the bp check and use the correct index for accessing the watchpoint structures. Signed-off-by: Will Deacon Signed-off-by: Jiri Slaby --- arch/arm64/include/asm/hw_breakpoint.h | 1 - arch/arm64/kernel/ptrace.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/hw_breakpoint.h b/arch/arm64/include/asm/hw_breakpoint.h index d064047612b1..52b484b6aa1a 100644 --- a/arch/arm64/include/asm/hw_breakpoint.h +++ b/arch/arm64/include/asm/hw_breakpoint.h @@ -79,7 +79,6 @@ static inline void decode_ctrl_reg(u32 reg, */ #define ARM_MAX_BRP 16 #define ARM_MAX_WRP 16 -#define ARM_MAX_HBP_SLOTS (ARM_MAX_BRP + ARM_MAX_WRP) /* Virtual debug register bases. */ #define AARCH64_DBG_REG_BVR 0 diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 9fa78cd0f092..ee79a1a6e965 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -81,7 +81,8 @@ static void ptrace_hbptriggered(struct perf_event *bp, break; } } - for (i = ARM_MAX_BRP; i < ARM_MAX_HBP_SLOTS && !bp; ++i) { + + for (i = 0; i < ARM_MAX_WRP; ++i) { if (current->thread.debug.hbp_watch[i] == bp) { info.si_errno = -((i << 1) + 1); break;