Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa/gdbserver] Fix ppc64 bi-arch TLS bug
@ 2008-05-28 23:07 Ulrich Weigand
  2008-05-29  0:18 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2008-05-28 23:07 UTC (permalink / raw)
  To: gdb-patches

Hello,

this fixes another bug in ppc64 bi-arch gdbserver support: the
ppc_collect_ptrace_register did not zero out the register buffer
(in the case of a 4-byte inferior register on a 64-bit host).

This doesn't matter for the main user of this function
(usr_store_inferior_registers in linux-low.c) which always
zeros the buffer itself before passing it in.

However, there is a second caller, ps_lgetregs in proc-service.c
(via the ppc_fill_gregset function) which does *not* zero the
buffer.  This could cause TLS access to fail in some instances
of 64->32 bit bi-arch debugging.

Fixed by simply always clearing the register buffer.

Tested on powerpc64-linux (-m64/-m32) and powerpc-linux using
local gdbserver.

OK for mainline?

Bye,
Ulrich


ChangeLog:

	* linux-ppc-low.c (ppc_collect_ptrace_register): Clear buffer.

diff -urNp gdb-orig/gdb/gdbserver/linux-ppc-low.c gdb-head/gdb/gdbserver/linux-ppc-low.c
--- gdb-orig/gdb/gdbserver/linux-ppc-low.c	2008-05-11 23:03:06.000000000 +0200
+++ gdb-head/gdb/gdbserver/linux-ppc-low.c	2008-05-28 19:24:33.372182584 +0200
@@ -149,6 +149,9 @@ static void
 ppc_collect_ptrace_register (int regno, char *buf)
 {
   int size = register_size (regno);
+
+  memset (buf, 0, sizeof (long));
+
   if (size < sizeof (long))
     collect_register (regno, buf + sizeof (long) - size);
   else
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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

* Re: [rfa/gdbserver] Fix ppc64 bi-arch TLS bug
  2008-05-28 23:07 [rfa/gdbserver] Fix ppc64 bi-arch TLS bug Ulrich Weigand
@ 2008-05-29  0:18 ` Daniel Jacobowitz
  2008-05-29 20:30   ` Ulrich Weigand
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-05-29  0:18 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gdb-patches

On Wed, May 28, 2008 at 08:29:51PM +0200, Ulrich Weigand wrote:
> Hello,
> 
> this fixes another bug in ppc64 bi-arch gdbserver support: the
> ppc_collect_ptrace_register did not zero out the register buffer
> (in the case of a 4-byte inferior register on a 64-bit host).
> 
> This doesn't matter for the main user of this function
> (usr_store_inferior_registers in linux-low.c) which always
> zeros the buffer itself before passing it in.
> 
> However, there is a second caller, ps_lgetregs in proc-service.c
> (via the ppc_fill_gregset function) which does *not* zero the
> buffer.  This could cause TLS access to fail in some instances
> of 64->32 bit bi-arch debugging.
> 
> Fixed by simply always clearing the register buffer.
> 
> Tested on powerpc64-linux (-m64/-m32) and powerpc-linux using
> local gdbserver.
> 
> OK for mainline?

OK.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [rfa/gdbserver] Fix ppc64 bi-arch TLS bug
  2008-05-29  0:18 ` Daniel Jacobowitz
@ 2008-05-29 20:30   ` Ulrich Weigand
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2008-05-29 20:30 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacbowitz wrote:
> On Wed, May 28, 2008 at 08:29:51PM +0200, Ulrich Weigand wrote:
> > Hello,
> > 
> > this fixes another bug in ppc64 bi-arch gdbserver support: the
> > ppc_collect_ptrace_register did not zero out the register buffer
> > (in the case of a 4-byte inferior register on a 64-bit host).
> > 
> > This doesn't matter for the main user of this function
> > (usr_store_inferior_registers in linux-low.c) which always
> > zeros the buffer itself before passing it in.
> > 
> > However, there is a second caller, ps_lgetregs in proc-service.c
> > (via the ppc_fill_gregset function) which does *not* zero the
> > buffer.  This could cause TLS access to fail in some instances
> > of 64->32 bit bi-arch debugging.
> > 
> > Fixed by simply always clearing the register buffer.
> > 
> > Tested on powerpc64-linux (-m64/-m32) and powerpc-linux using
> > local gdbserver.
> > 
> > OK for mainline?
> 
> OK.

Committed, thanks.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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

end of thread, other threads:[~2008-05-29 11:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-28 23:07 [rfa/gdbserver] Fix ppc64 bi-arch TLS bug Ulrich Weigand
2008-05-29  0:18 ` Daniel Jacobowitz
2008-05-29 20:30   ` Ulrich Weigand

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