Message ID | 20170119210015.GA87383@beast |
---|---|
State | New, archived |
Headers |
Received: (qmail 112121 invoked by alias); 19 Jan 2017 21:00:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 111819 invoked by uid 89); 19 Jan 2017 21:00:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=BAYES_50, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=Cook, noticeably, needless, sk:arm_lin X-HELO: mail-pf0-f172.google.com Received: from mail-pf0-f172.google.com (HELO mail-pf0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jan 2017 21:00:18 +0000 Received: by mail-pf0-f172.google.com with SMTP id y143so16238602pfb.0 for <gdb-patches@sourceware.org>; Thu, 19 Jan 2017 13:00:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=L0YDo5NMBGGWJHlXIR6x+QYVByvR0AoeBCPGnviDX1U=; b=MntDB5dSZSxkHQQhs/Hazl/ucSoLb5Hx0gXQ0uITPTHlKjI5behCKtonRjzvdjJJLU Qe7yOm+ucdp3Ynjg68EQe7PxldsdqNG+bdGy7Iiv024uChEDImODFMIjxd5bF6+6yxep 8HYo9S+AhJbTtqCxWVa2f1uwIzmr0VNCwO6qUuoyq/APWwVm9avzaHxp8tVzSFzrmZ/g vwVm1CccLmccBQE76SxVJEMJ7al2XDSseBK4ez08s6FdedlBA8E1rNyL9k1qqTTqmpbZ vVyzpnIst+SbONEw94cTVM36dvMzkCo5E/C7fhrpxOmVikUZTLR4y4cSnL9ObgvJpXFU C3Ng== X-Gm-Message-State: AIkVDXJvSfWJZekgPYrIZPq3fxq+Hy1GRbwS7fCOCWIcqxTG79TGffrrUNbyHpkUafArYS5b X-Received: by 10.99.184.18 with SMTP id p18mr12831407pge.33.1484859616738; Thu, 19 Jan 2017 13:00:16 -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 y201sm11044940pfb.16.2017.01.19.13.00.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2017 13:00:16 -0800 (PST) Date: Thu, 19 Jan 2017 13:00:15 -0800 From: Kees Cook <keescook@chromium.org> To: gdb-patches@sourceware.org Cc: Yao Qi <qiyaoltc@gmail.com>, Doug Evans <dje@google.com>, brian.murray@canonical.com, matthias.klose@canonical.com Subject: [PATCH v3] Fix PTRACE_GETREGSET failure for compat inferiors on arm64 Message-ID: <20170119210015.GA87383@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline |
Commit Message
Kees Cook
Jan. 19, 2017, 9 p.m. UTC
When running a 32-bit ARM inferior with a 32-bit ARM GDB on a 64-bit AArch64 host, only VFP registers (NT_ARM_VFP) are available. The FPA registers (NT_PRFPREG) are not available so GDB must not request them, as this will fail 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-19 Kees Cook <keescook@google.com> * gdb/arm-linux-nat.c: Skip soft-float registers when using hard-float. --- v3: - argh, actually drop needless other change. v2: - check have_fpa_registers instead, dropped needless other change: qiyaoltc --- gdb/arm-linux-nat.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Comments
On Thu, Jan 19, 2017 at 1:00 PM, Kees Cook <keescook@chromium.org> wrote: > When running a 32-bit ARM inferior with a 32-bit ARM GDB on a 64-bit > AArch64 host, only VFP registers (NT_ARM_VFP) are available. The FPA > registers (NT_PRFPREG) are not available so GDB must not request them, as > this will fail 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-19 Kees Cook <keescook@google.com> > > * gdb/arm-linux-nat.c: Skip soft-float registers when using hard-float. Hi! Friendly ping on this patch. Are there any corrections to be made, or can someone commit it? Thanks! -Kees > --- > v3: > - argh, actually drop needless other change. > v2: > - check have_fpa_registers instead, dropped needless other change: qiyaoltc > --- > gdb/arm-linux-nat.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c > index d11bdc6..4fa5204 100644 > --- a/gdb/arm-linux-nat.c > +++ b/gdb/arm-linux-nat.c > @@ -384,13 +384,14 @@ 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); > + if (tdep->have_fpa_registers) > + fetch_fpregs (regcache); > } > - else > + else > { > if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) > fetch_regs (regcache); > @@ -420,11 +421,12 @@ 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); > + if (tdep->have_fpa_registers) > + store_fpregs (regcache); > } > else > { > -- > 2.7.4 > > > -- > Kees Cook > Nexus Security
On Thu, Jan 19, 2017 at 9:00 PM, Kees Cook <keescook@chromium.org> wrote: > The patch is good to me, some nits below, > gdb/ChangeLog: > > 2016-12-19 Kees Cook <keescook@google.com> > > * gdb/arm-linux-nat.c: Skip soft-float registers when using hard-float. * gdb/arm-linux-nat.c (arm_linux_fetch_inferior_registers): Call fetch_fpregs if target has fpa registers. (arm_linux_store_inferior_registers): Call store_fpregs if target has fpa registers. > } > - else > + else > { Unnecessary change. I'll push your patch in tomorrow.
On Thu, Jan 26, 2017 at 3:23 PM, Yao Qi <qiyaoltc@gmail.com> wrote: > On Thu, Jan 19, 2017 at 9:00 PM, Kees Cook <keescook@chromium.org> wrote: >> > > The patch is good to me, some nits below, > >> gdb/ChangeLog: >> >> 2016-12-19 Kees Cook <keescook@google.com> >> >> * gdb/arm-linux-nat.c: Skip soft-float registers when using hard-float. > > * gdb/arm-linux-nat.c (arm_linux_fetch_inferior_registers): Call fetch_fpregs > if target has fpa registers. > (arm_linux_store_inferior_registers): Call store_fpregs if target has > fpa registers. Ah-ha, thanks! > >> } >> - else >> + else >> { > > Unnecessary change. I'll push your patch in tomorrow. Okay, I wasn't sure if whitespace/code-style fixes should be merged as they were found. Thanks! -Kees
On 17-01-26 23:23:30, Yao Qi wrote: > Unnecessary change. I'll push your patch in tomorrow. > Patch is pushed in! Thanks for your contribution.
On Fri, Jan 27, 2017 at 3:28 AM, Yao Qi <qiyaoltc@gmail.com> wrote: > On 17-01-26 23:23:30, Yao Qi wrote: >> Unnecessary change. I'll push your patch in tomorrow. >> > > Patch is pushed in! Thanks for your contribution. Great! Thanks for your help with it! :) -Kees
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index d11bdc6..4fa5204 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -384,13 +384,14 @@ 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); + if (tdep->have_fpa_registers) + fetch_fpregs (regcache); } - else + else { if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) fetch_regs (regcache); @@ -420,11 +421,12 @@ 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); + if (tdep->have_fpa_registers) + store_fpregs (regcache); } else {