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: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Nix <nix at esperi dot org dot uk>, <libc-alpha at sourceware dot org>
- Cc: <nd at arm dot com>
- Date: Wed, 2 Mar 2016 18:53:47 +0000
- Subject: Re: [PATCH 15/16] Avoid stack-protecting certain functions called from assembly.
- Authentication-results: sourceware.org; auth=none
- Nodisclaimer: True
- 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>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
On 28/02/16 16:41, Nix wrote:
> From: Nick Alcock <nick.alcock@oracle.com>
>
> This is the problematic part. Without -fno-stack-protector on
> __pthread_mutex_cond_lock_adjust() and __pthread_mutex_unlock_usercnt(),
> nptl/tst-cond24 and nptl/tst-cond25 receive a NULL mutex at unlock time
> and segfault. However... I don't understand why. It is the callee's
> responsibility both to add the stack canary and to initialize it, just
> like any other local variable. It has to be, or the ABI for stack-
> protected code would be incompatible with that for non-protected code.
> But the fact remains that
> sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S both explicitly
> mentions the stack frame layout and calls this function, and this call
> goes wrong if we stack-protect it.
>
> So this is somewhere where I need someone to tell me what's special about
> sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S (and in particular
> special about priority-inheritance mutexes: everything else works),
> before I can be confident that this is even remotely the right thing to
> do.
>
i think this should be investigated before adding any
workarounds there.
> We also de-stack-protect setjmp/sigjmp.c: it receives a sibcall from
> sysdeps/x86_64/setjmp.S and lands in rtld, but is *not* rebuilt by
> the machinery that rebuilds almost everything else that lands in
> rtld with an appropriate MODULE_NAME.
>
> Similar fixups may be required for things called directly from
> assembly on other architectures.
>
i don't understand the details here, but i don't think calling
something from asm should be a problem, only early function calls
(before thread pointer setup) should be problematic (on targets
where the canary is in the tcb).
> v2: de-stack-protect setjmp/sigjmp.c.
> v3: Use $(no-stack-protector).
> v4: Use inhibit_stack_protector.