From patchwork Tue Jun 3 05:46:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 31318 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 58598203C2 for ; Tue, 3 Jun 2014 05:48:11 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id jt11sf23054919pbb.6 for ; Mon, 02 Jun 2014 22:48:10 -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 :in-reply-to:references: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=g9zR3eSjW74BXL8zefu6JS86nBd2x+v7JseD0ViGwlc=; b=HFFH5zQqq/WO/rtqlgvtsN19fNp3rHj7xtxybJSjMRm4+13LYMFqX3ZvEq4jlAHb8J 6TSwCOZjPDfdMjhZjsRCSjVRZbDRii+uw0ycHLmnfYFE6C4iae3TBTlkUjENg/6A+qhM z+MX3SKI4nQ+IYeSYrmbYg3GedLmTp9XOyv89fj4Qs3yqMJv48N8gfOxICx/MKyvqPES erp7PSxv0MIY1J2D2PNpCOmI+GFENqVK8zyRsCqJPsmHOTejgK89QDVWU0O8C3iq57Z6 M4vlufRWbGde25YRpjFIzZOqc5bkIsTcG8jmC7C+5akZ+YfkMyuWW3DACXdsgifcEiNv YX2g== X-Gm-Message-State: ALoCoQkbcWcwTpotwvW87gX09unZBBoyaJweS9L0WeVgz57qIFeq/pMrlVj420mboVbZjDu7AXLX X-Received: by 10.66.231.68 with SMTP id te4mr15387334pac.29.1401774490453; Mon, 02 Jun 2014 22:48:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.33 with SMTP id q30ls2289798qgd.10.gmail; Mon, 02 Jun 2014 22:48:10 -0700 (PDT) X-Received: by 10.220.163.3 with SMTP id y3mr34668627vcx.7.1401774490295; Mon, 02 Jun 2014 22:48:10 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id g5si9361112vda.6.2014.06.02.22.48.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 22:48:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id hq11so4301821vcb.11 for ; Mon, 02 Jun 2014 22:48:10 -0700 (PDT) X-Received: by 10.220.12.66 with SMTP id w2mr34380360vcw.15.1401774490176; Mon, 02 Jun 2014 22:48:10 -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 ib8csp151161vcb; Mon, 2 Jun 2014 22:48:09 -0700 (PDT) X-Received: by 10.140.81.74 with SMTP id e68mr52523592qgd.77.1401774489721; Mon, 02 Jun 2014 22:48:09 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id u32si20653157qge.1.2014.06.02.22.48.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jun 2014 22:48:09 -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 1WrhYb-0001y7-Hj; Tue, 03 Jun 2014 05:46:45 +0000 Received: from mail-pb0-f43.google.com ([209.85.160.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WrhYZ-0001vb-4j for linux-arm-kernel@lists.infradead.org; Tue, 03 Jun 2014 05:46:43 +0000 Received: by mail-pb0-f43.google.com with SMTP id up15so5026308pbc.16 for ; Mon, 02 Jun 2014 22:46:21 -0700 (PDT) X-Received: by 10.68.194.202 with SMTP id hy10mr47057313pbc.94.1401774381417; Mon, 02 Jun 2014 22:46:21 -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 fd5sm16814198pad.12.2014.06.02.22.46.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jun 2014 22:46:20 -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: Mon, 2 Jun 2014 22:46:09 -0700 Message-Id: <1401774369-7060-2-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1401774369-7060-1-git-send-email-victor.kamensky@linaro.org> References: <1401774369-7060-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140602_224643_197958_2AB82694 X-CRM114-Status: GOOD ( 11.95 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.43 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record Cc: linaro-kernel@lists.linaro.org, Dave.Martin@arm.com, 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.180 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 --- 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: