This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 00/08] nptl: Fix Race conditions in pthread cancellation (BZ#12683)
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 31 Aug 2015 18:10:40 -0300
- Subject: [PATCH 00/08] nptl: Fix Race conditions in pthread cancellation (BZ#12683)
- Authentication-results: sourceware.org; auth=none
Hi all,
This is an updated version of my previous patchset to fix BZ#12683 [1]
The patchset fixes the x86_64, i386, x32, powerpc32, powerpc64{le}, aarch64,
and ARM port. It will require some help for alpha, hppa, ia64, m68k, microblaze,
nios2, s390, sh, sparc, and tile. I summarized in wiki page [2] the steps
required to adjust the remaining architectures, but based on arm/aarch64 the
minimal adjustments required are:
1. Write a new syscall implementation at sysdeps/unix/sysv/linux/<arch>/syscall_cancel.S
that basically do:
long int __syscall_cancel_arch (volatile unsigned int *cancelhandling,
__syscall_arg_t nr, __syscall_arg_t arg1, __syscall_arg_t arg2,
__syscall_arg_t arg3, __syscall_arg_t arg4, __syscall_arg_t arg5,
__syscall_arg_t arg6)
{
if (*cancelhandling & CANCELED_BITMASK)
__syscall_do_cancel()
return INLINE_SYSCALL (nr, 6, arg1, arg2, arg3, arg4, arg5, arg6);
}
2. Adjust sysdeps/unix/sysv/linux/<arch>/sysdep-cancel.h to make cancellable
syscalls to call __syscall_cancel instead of *_{enable,disable}_asynccancel.
3. Create a function to get current IP address based on ucontext_t:
static inline
long int __pthread_get_ip (const struct ucontext *uc)
{
// TODO
}
4. Define both SYSCALL_CANCEL_ERROR(__val) and SYSCALL_CANCEL_ERRNO(__val)
macros.
For x86_64 and i386 implementation my approach was to just remove the
pthread_cond_{timed}wait assembly implementation and use default C code, but
since Torvald Riegel new condvar implementation [3] also removed them this
patchset do not contain such removals. Also, this fix is easy to adjust
to new futex API also proposed by Torvalds and I can adjust the patch when
the new API is pushed upstream. The bulk of implementation just depend of a
cancellable futex call done by new mechanism which is orthogonal of the new
proposed futex API.
The idea is try to push it for 2.23 and I have a personal branch [4] with
a working tree for the aforementioned architectures plus some skeleton for
s390 and s390x (not working thou).
[1] https://sourceware.org/ml/libc-alpha/2015-06/msg00895.html
[2] https://sourceware.org/glibc/wiki/Release/2.21/bz12683
[3] https://sourceware.org/ml/libc-alpha/2015-05/msg00287.htm
[4] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/bz12683