x86: Use correct .reg-xstate section size
authorAndreas Arnez <arnez@linux.vnet.ibm.com>
Wed, 14 Jan 2015 17:53:23 +0000 (17:53 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 4 Feb 2015 13:14:31 +0000 (14:14 +0100)
When reading the XSAVE extended state from an i386 or AMD64 core file,
the respective regset iterator requests a minimum section size of
zero.  Since the respective regset supply function does not check the
size either, this may lead to accessing data out of range if the
section is too short.

In write mode, the iterator always uses the maximum supported size for
the XSAVE extended state.

This is now changed such that the iterator always requests the
expected size of this section based on xcr0, both for reading and
writing.

gdb/ChangeLog:

* amd64-linux-tdep.c (amd64_linux_iterate_over_regset_sections):
For ".reg-xstate", explicitly specify the requested section size
via X86_XSTATE_SIZE instead of just 0 on input and
X86_XSTATE_MAX_SIZE on output.
* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections):
Likewise.

gdb/ChangeLog
gdb/amd64-linux-tdep.c
gdb/i386-linux-tdep.c

index a2cc9a5a3228ab2021bd5f3ca20415d321e04761..822d0d40bc85d46cc78a098def3b46c3fed2e7d8 100644 (file)
@@ -1,3 +1,12 @@
+2015-02-04  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
+       * amd64-linux-tdep.c (amd64_linux_iterate_over_regset_sections):
+       For ".reg-xstate", explicitly specify the requested section size
+       via X86_XSTATE_SIZE instead of just 0 on input and
+       X86_XSTATE_MAX_SIZE on output.
+       * i386-linux-tdep.c (i386_linux_iterate_over_regset_sections):
+       Likewise.
+
 2015-02-04  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
        PR corefiles/17808:
index 42d884e4215c081a7f068c9a52bcbf145c866699..5db04c0626e961421476940bdbcb20576ba0ad39 100644 (file)
@@ -1639,7 +1639,7 @@ amd64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 
   cb (".reg", 27 * 8, &i386_gregset, NULL, cb_data);
   cb (".reg2", 512, &amd64_fpregset, NULL, cb_data);
-  cb (".reg-xstate",  regcache ? X86_XSTATE_MAX_SIZE : 0,
+  cb (".reg-xstate",  X86_XSTATE_SIZE (tdep->xcr0),
       &amd64_linux_xstateregset, "XSAVE extended state", cb_data);
 }
 
index 8a5209ac216657b9ba9375b30969fe0b66e1cdbb..4a0ce600c35724a06ed3487b0238db19584e701e 100644 (file)
@@ -690,8 +690,7 @@ i386_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
   cb (".reg", 68, &i386_gregset, NULL, cb_data);
 
   if (tdep->xcr0 & X86_XSTATE_AVX)
-    /* Use max size for writing, accept any size when reading.  */
-    cb (".reg-xstate", regcache ? X86_XSTATE_MAX_SIZE : 0,
+    cb (".reg-xstate", X86_XSTATE_SIZE (tdep->xcr0),
        &i386_linux_xstateregset, "XSAVE extended state", cb_data);
   else if (tdep->xcr0 & X86_XSTATE_SSE)
     cb (".reg-xfp", 512, &i386_fpregset, "extended floating-point",
This page took 0.028673 seconds and 4 git commands to generate.