Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix PTRACE_GETREGSET failure for compat inferiors on arm64
@ 2016-12-02 21:46 Kees Cook
  2016-12-02 22:49 ` Yao Qi
  0 siblings, 1 reply; 10+ messages in thread
From: Kees Cook @ 2016-12-02 21:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: brian.murray, matthias.klose

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  <keescook@google.com>

	* 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)
-- 
2.7.4


-- 
Kees Cook
Nexus Security


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-12-09  9:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-02 21:46 [PATCH] Fix PTRACE_GETREGSET failure for compat inferiors on arm64 Kees Cook
2016-12-02 22:49 ` Yao Qi
2016-12-02 23:08   ` Kees Cook
2016-12-04 11:11     ` Yao Qi
2016-12-04 19:30       ` Kees Cook
2016-12-05 10:26         ` Yao Qi
2016-12-05 16:06           ` Kees Cook
2016-12-09  9:27             ` Yao Qi
2016-12-02 23:50   ` Doug Evans
2016-12-04 10:31     ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox