From patchwork Tue Jun 3 18:21:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 31334 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 13D18203AC for ; Tue, 3 Jun 2014 18:23:58 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wm4sf36153481obc.10 for ; Tue, 03 Jun 2014 11:23:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=qObhjZ0pU8sislQBlPvNdVWiLE16N/W8MIYnbCznYF0=; b=W7O63V1vEsxf0XumgXts/4sflnsG3H0W45PWqnqRuhlOpG+47lP+OmL/r2KBwanbZ/ HL9zNV67ds5UNaRtbIXO5t4DDEugLiYAynvzoRTIJCLnDSpE6Yz/dFaiQ6dGMgZlYHME /CJdOrSE2IzBwCIJ0kK+fQk6UGC/WbLhBNLtTeoLSlU/H2+gRXDYhrbs99EQMcwc4GJw DxF3w2xUUfAFCzpkZdbHYDRMTgcR3blzJ02XPXDGk+L+KC+xBuBqSMJI5iTTEK4BX7af fUA8j6qTf2b9fOAmwRsByLVLjSOqR090u0EZqC8SVwPj4KuLYkgE3CuqdrfxmPGw2sSl UORQ== X-Gm-Message-State: ALoCoQnfCgHwdxF+d0Yse30ZeCnw07G1H9ieokYuiQCS6BaK4c8JYEZ0R3vn5Zy4wi/PPM653vLl X-Received: by 10.42.27.18 with SMTP id h18mr9687516icc.25.1401819838378; Tue, 03 Jun 2014 11:23:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.40 with SMTP id m37ls2700199qgd.18.gmail; Tue, 03 Jun 2014 11:23:58 -0700 (PDT) X-Received: by 10.58.136.168 with SMTP id qb8mr38140217veb.21.1401819838201; Tue, 03 Jun 2014 11:23:58 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id wz6si5709vcb.13.2014.06.03.11.23.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Jun 2014 11:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id ij19so2834971vcb.10 for ; Tue, 03 Jun 2014 11:23:58 -0700 (PDT) X-Received: by 10.52.25.130 with SMTP id c2mr27742929vdg.27.1401819838044; Tue, 03 Jun 2014 11:23:58 -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.220.221.72 with SMTP id ib8csp16420vcb; Tue, 3 Jun 2014 11:23:57 -0700 (PDT) X-Received: by 10.224.54.133 with SMTP id q5mr39357388qag.84.1401819837377; Tue, 03 Jun 2014 11:23:57 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id w5si24063039qax.122.2014.06.03.11.23.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jun 2014 11:23:57 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1WrtLo-0005g4-BM; Tue, 03 Jun 2014 18:22:20 +0000 Received: from mail-pd0-f176.google.com ([209.85.192.176]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WrtLl-0005cc-HV for linux-arm-kernel@lists.infradead.org; Tue, 03 Jun 2014 18:22:18 +0000 Received: by mail-pd0-f176.google.com with SMTP id p10so4966776pdj.7 for ; Tue, 03 Jun 2014 11:21:55 -0700 (PDT) X-Received: by 10.68.136.226 with SMTP id qd2mr53107754pbb.72.1401819715426; Tue, 03 Jun 2014 11:21:55 -0700 (PDT) Received: from kamensky-w530.cisco.com (128-107-239-233.cisco.com. [128.107.239.233]) by mx.google.com with ESMTPSA id og3sm30730026pbc.48.2014.06.03.11.21.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jun 2014 11:21:54 -0700 (PDT) From: Victor Kamensky To: catalin.marinas@arm.com, will.deacon@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: ptrace: fix empty registers set in prstatus of aarch32 process core Date: Tue, 3 Jun 2014 11:21:30 -0700 Message-Id: <1401819690-3048-1-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140603_112217_631491_5E4030B0 X-CRM114-Status: GOOD ( 11.68 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.176 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record Cc: linaro-kernel@lists.linaro.org, Dave.Martin@arm.com, stable@vger.kernel.org, Victor Kamensky X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: victor.kamensky@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.220.179 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 Currently core file of aarch32 process prstatus note has empty registers set. As result aarch32 core files create by V8 kernel are not very useful. It happens because compat_gpr_get and compat_gpr_set functions can copy registers values to/from either kbuf or ubuf. ELF core file collection function fill_thread_core_info calls compat_gpr_get with kbuf set and ubuf set to 0. But current compat_gpr_get and compat_gpr_set function handle copy to/from only ubuf case. Fix is to handle kbuf and ubuf as two separate cases in similar way as other functions like user_regset_copyout, user_regset_copyin do. Signed-off-by: Victor Kamensky Acked-by: Will Deacon Cc: stable@vger.kernel.org Cc: Catalin Marinas --- arch/arm64/kernel/ptrace.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 6a8928b..9c9c2b9 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -650,11 +650,16 @@ static int compat_gpr_get(struct task_struct *target, reg = task_pt_regs(target)->regs[idx]; } - ret = copy_to_user(ubuf, ®, sizeof(reg)); - if (ret) - break; - - ubuf += sizeof(reg); + if (kbuf) { + memcpy(kbuf, ®, sizeof(reg)); + kbuf += sizeof(reg); + } else { + ret = copy_to_user(ubuf, ®, sizeof(reg)); + if (ret) + break; + + ubuf += sizeof(reg); + } } return ret; @@ -684,11 +689,16 @@ static int compat_gpr_set(struct task_struct *target, unsigned int idx = start + i; compat_ulong_t reg; - ret = copy_from_user(®, ubuf, sizeof(reg)); - if (ret) - return ret; + if (kbuf) { + memcpy(®, kbuf, sizeof(reg)); + kbuf += sizeof(reg); + } else { + ret = copy_from_user(®, ubuf, sizeof(reg)); + if (ret) + return ret; - ubuf += sizeof(reg); + ubuf += sizeof(reg); + } switch (idx) { case 15: