From patchwork Fri Dec 2 21:46:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 18144 Received: (qmail 55161 invoked by alias); 2 Dec 2016 21:46:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 55150 invoked by uid 89); 2 Dec 2016 21:46:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Cook, H*Ad:D*canonical.com, Hx-languages-length:2330, risk X-HELO: mail-pg0-f51.google.com Received: from mail-pg0-f51.google.com (HELO mail-pg0-f51.google.com) (74.125.83.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Dec 2016 21:46:16 +0000 Received: by mail-pg0-f51.google.com with SMTP id 3so111608319pgd.0 for ; Fri, 02 Dec 2016 13:46:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=TuobcsCVQ2VTDWrSIpwiy+vkV8LJtnzf+OJ3ylf1d1I=; b=FnA8wDGKXwlteF44TVvteanY2NIr3orrxWajC236xXjAld6TwWzGSIkUVoI7EsEFD9 lq6X/5SGn8pAmPkRaGkix6dISjODdFnotXmrOMatcjmUOVMVhqkltSej4FFHTC9o6/aB UtiS349WcW7kWgek72f9LnpY2DN1RmeQSBZWFYHzmxInOI4yZPWcZrn2QMyi5VcFei/7 tDqWBkTgaivGI3Y6piCOB+2dCBpFYg81yvb0VsPUzIu4Gx6lXbWMwsNnL1BU+IWiHPvG aYszj0EU67NDc8XR9Z0jgJLwyOf6sJxqr2cdWWYNxQFwnsAKOczXuM+NkgEk/2OsNFJn oDoQ== X-Gm-Message-State: AKaTC02V6wpfjrKrIRze/B26GHph/2wU6R3dhQc2mlWb7JPEgRQYTD1PhkiACBRK9o2GzK1k X-Received: by 10.98.26.88 with SMTP id a85mr46877466pfa.57.1480715174836; Fri, 02 Dec 2016 13:46:14 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id a22sm9976381pfg.7.2016.12.02.13.46.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2016 13:46:14 -0800 (PST) Date: Fri, 2 Dec 2016 13:46:13 -0800 From: Kees Cook To: gdb-patches@sourceware.org Cc: brian.murray@canonical.com, matthias.klose@canonical.com Subject: [PATCH] Fix PTRACE_GETREGSET failure for compat inferiors on arm64 Message-ID: <20161202214613.GA54717@beast> MIME-Version: 1.0 Content-Disposition: inline When running a 32-bit ARM inferior on a 64-bit ARM host, only the hardware floating-point registers (NT_ARM_VFP) are available. If the inferior uses hard-float, do not request soft-float registers (NT_PRFPREG) and run the risk of failing with EINVAL. This is most noticeably exposed when running "generate-core-file": (gdb) generate-core-file myprog.core Unable to fetch the floating point registers.: Invalid argument. ptrace(PTRACE_GETREGSET, 27642, NT_FPREGSET, 0xffcc67f0) = -1 EINVAL (Invalid argument) gdb/ChangeLog: 2016-12-02 Kees Cook * gdb/arm-linux-nat.c: Skip soft-float registers when using hard-float. --- gdb/arm-linux-nat.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index d11bdc6..2126cd7 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -384,17 +384,19 @@ arm_linux_fetch_inferior_registers (struct target_ops *ops, if (-1 == regno) { fetch_regs (regcache); - fetch_fpregs (regcache); if (tdep->have_wmmx_registers) fetch_wmmx_regs (regcache); if (tdep->vfp_register_count > 0) fetch_vfp_regs (regcache); + else + fetch_fpregs (regcache); } - else + else { if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) fetch_regs (regcache); - else if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM) + else if (tdep->vfp_register_count == 0 + && regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM) fetch_fpregs (regcache); else if (tdep->have_wmmx_registers && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM) @@ -420,17 +422,19 @@ arm_linux_store_inferior_registers (struct target_ops *ops, if (-1 == regno) { store_regs (regcache); - store_fpregs (regcache); if (tdep->have_wmmx_registers) store_wmmx_regs (regcache); if (tdep->vfp_register_count > 0) store_vfp_regs (regcache); + else + store_fpregs (regcache); } else { if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) store_regs (regcache); - else if ((regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM)) + else if (tdep->vfp_register_count == 0 + && (regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM)) store_fpregs (regcache); else if (tdep->have_wmmx_registers && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)