This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch][BZ 14594] Demangle function pointers before testing them


On 09/21/2012 01:30 AM, Andreas Schwab wrote:
Jeff Law <law@redhat.com> writes:

The problem is the code is testing the mangled pointer against null which
is blatently wrong

No, it is perfectly correct: the NULL pointer is never mangled in the first place. Demangling the NULL pointer will never result in a NULL pointer, and all you get is a crash.
You're still missing my point. If the clear pointer is _NOT_ NULL and the mangling function produces a NULL result, then the existing tests will do the wrong thing.

I see your point, namely that because a NULL clear pointer is not mangled an additional test is necessary. ie the code really needs to do this:

if (ptr != NULL)
  DEMANGLE (ptr);

if (ptr != NULL)
  *(ptr) (args);



That is trivial. Just make sure the canary is never a valid pointer (you lose a bit of randomness, but that should not be a problem).
And how do you propose to do that, keeping in mind architectures where functions can start on a byte boundary and can live virtually anywhere in the address space?

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]