[PATCH 00/08] nptl: Fix Race conditions in pthread cancellation (BZ#12683)
Stefan Liebler
stli@linux.vnet.ibm.com
Wed Sep 16 07:36:00 GMT 2015
Hi Adhemerval,
this is a patch, which applies on top of your personal branch
azanella/bz12683. It implements the s390/s390x specific parts.
The kernel has a bug in the 32bit compat layer.
When sigcancel_handler is executed, SIGCANCEL is added to uc_sigmask
and SIGCANCEL is send to the same thread again. The current kernel
misinterprets the uc_sigmask, which leads to delivering SIGCANCEL
in an endless loop.
The kernel bug is being fixed. With the fixed kernel, it works as
expected on s390, too.
Bye Stefan
On 08/31/2015 11:10 PM, Adhemerval Zanella wrote:
> 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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20150915_s390_cancelsvc.patch
Type: text/x-patch
Size: 12824 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150916/d0741953/attachment.bin>
More information about the Libc-alpha
mailing list