Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sourceware.org
Subject: Re: 5/5 - handle glibc pointer mangling jmp_bufs (x86/x86_64)
Date: Mon, 14 Apr 2008 19:24:00 -0000	[thread overview]
Message-ID: <200804142020.07056.pedro@codesourcery.com> (raw)
In-Reply-To: <20080414185843.GH1968@caradoc.them.org>

A Monday 14 April 2008 19:58:43, Daniel Jacobowitz wrote:
> On Mon, Apr 07, 2008 at 11:25:50PM +0100, Pedro Alves wrote:
> > A Monday 07 April 2008 03:36:27, Pedro Alves wrote:
> > > I'm not proposing this to go in, as it will brake glibc's where
> > > the pointer mangling is not implemented or is implemented
> > > differently.  Maybe we could get around this 99% of the
> > > times by switching the unmangling algorithm based on glibc's
> > > version, although I don't know how to get at glibc's version.
>

> Darn, and you got my hopes up.  I figured you'd come up with a clever
> solution to this when I saw the patch subject.
>

Eh, sorry for not being cleverer :-)

Well, my main motivation was to get longjmp working in
non-stop mode, I made this patch just so I could test it.

> Glibc stores the key in %fs:POINTER_GUARD, from whence we can
> retrieve it, as in this patch.  It also stores it in
> __pointer_chk_guard_local (local to ld.so), and __pointer_chk_guard
> (exported, but only on platfroms which do not put it in the TCB).
>

> If you have an unstripped ld.so, you can retrieve it from that symbol.

The key is not enough.  There's also a 'rotate right' involved.  That
seems to have changed through time, as Jan's patch didn't handle the ror,
just the xor.

> Maybe that is good enough for now, and we can seek a better long-term
> solution separately.  Also, the location of the guard does not
> definitively answer the question of whether it is used to mangle
> jmp_bufs.  ARM and MIPS don't use it at all.  

True.  I had thought that a solution based on detecting the
glibc version and demangling accordingly would be enough.

Why isn't it so?  Is it plain impossible to
extract glibc's version?

> Perhaps we should 
> manually call setjmp to determine if the pointer is mangled?
> Heck, from there we could deduce the canary and make this a single
> glibc-specific method!
>

I actually thought of doing this, but I seem to have grown
an aversion to the inferior function calls (due to them
not being  async), so I never tried it, go figure.
This would have to be arch dependant, and would have to cope
with multiple versions or the algorithm.  Does it mangle?  Is it
a plan xor?  It is rotated?  By how many bits?  Not so
much over-complicated tough.

> RMS asked us about a way to expose pointer mangling to gdb ages ago.
> I believe Jan made this work via libthread_db, which I would prefer to
> avoid (remote debugging, for instance).  Failing that, I think we're
> stuck with the symbol table.

As I said, getting at the pointer_guard value is not enough.

-- 
Pedro Alves


  reply	other threads:[~2008-04-14 19:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-07  3:21 Pedro Alves
2008-04-07 23:02 ` Pedro Alves
2008-04-14 19:02   ` Daniel Jacobowitz
2008-04-14 19:24     ` Pedro Alves [this message]
2008-04-14 19:56       ` Daniel Jacobowitz
2008-04-15 12:54         ` Daniel Jacobowitz
2008-04-15 14:40           ` Pedro Alves
2008-04-07  6:31 Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200804142020.07056.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox