This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 15/16] Avoid stack-protecting certain functions called from assembly.
- From: Nix <nix at esperi dot org dot uk>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Szabolcs Nagy <szabolcs dot nagy at arm dot com>, <libc-alpha at sourceware dot org>, <nd at arm dot com>
- Date: Thu, 03 Mar 2016 17:41:42 +0000
- Subject: Re: [PATCH 15/16] Avoid stack-protecting certain functions called from assembly.
- Authentication-results: sourceware.org; auth=none
- References: <1456677695-29778-1-git-send-email-nix at esperi dot org dot uk> <1456677695-29778-16-git-send-email-nix at esperi dot org dot uk> <56D736BB dot 7000407 at arm dot com> <87lh5z4irf dot fsf at esperi dot org dot uk> <mvmbn6vo60l dot fsf at hawking dot suse dot de>
On 3 Mar 2016, Andreas Schwab stated:
> Nix <nix@esperi.org.uk> writes:
>
>> I'm reasonably certain it has to do with pthread_cond_timedwait.S
>> somehow setting up a stack frame and locals below it in a form which
>> __pthread_mutex_{cond_lock_adjust,unlock_usercnt} then rely upon. I just
>> don't understand how they could be doing that, since they seem to be
>> calling the normal entry-point as usual. It's almost as if the call
>> skips the usual stack-frame setup for the local variables in that
>> function (including the canary), only I don't see how that could even be
>> possible. But de-protecting them clearly works...
>
> Have you tried stepping through the function to find the place where it
> breaks?
Yeah, but it was years ago, when x86 asm was even more opaque to me than
it is now. It looked like it was intentionally nulling the mutex
parameter out and then using that null later on -- but if my
vaguely-supported supposition in the message I just sent to Adhemerval
regarding the way the assembly implementation is sorta-sibcalling
functions overlaid on its own stack frame is right, I'm not surprised at
all that it was failing like that: the canary would have thrown off all
the arguments after it, in addition to overwriting something it wasn't
meant to on the stack frame (which seems to have had a hole left in it,
uncommented, for the 'type' local variable), following which the
assignment to the 'type' local variable in
__pthread_mutex_unlock_usercnt() would have blown up the next variable
in the caller's overlaid stack frame... oops.
This is all speculation, really, I don't read x86 asm well enough to be
sure what's going on in there. (If I did, I'd know what I was doing in
this change and this whole conversation would not arise!)
--
NULL && (void)