From patchwork Wed Apr 11 15:22:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 897235 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-91501-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="bzCITmi8"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40LnqD1H46z9s0n for ; Thu, 12 Apr 2018 01:23:03 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:cc:from:subject:date:mime-version :content-type:message-id; q=dns; s=default; b=mQN1MhBWQIVZ64RLv5 /noBPEpqWPq4S9S2joLzbP2repthFz7mP2+jtH0zhBoQvIbBjHqdVRbHwOrvJGWB 7+6FGebIWI0eBYyVZnyR9+F9TfcUA9uy1tQCYPobGCXiVguaI4Oy5anajZh9MVki CVdzhp6Dkhn/uJ4nSsRCvj5AM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:cc:from:subject:date:mime-version :content-type:message-id; s=default; bh=TJYnvm/De3kCXUoMrgJoHZE+ XeI=; b=bzCITmi8hkBj4ib8HmU+2qz4S4JN58CMzB34/YwNXc1I7FQVxoCveXdo XdZkQB0qlL9UU75w/QIzz/VxBTUuz49dPcAg/9QneMigTiKp9DVLSByAgdmJ/osN t1lN+N/nwdakO7Qw+a+nQKZEgpTlv5UUkhu3XDsleU8dE6bb0I8= Received: (qmail 111922 invoked by alias); 11 Apr 2018 15:22:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 111908 invoked by uid 89); 11 Apr 2018 15:22:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=consolidate, Consolidate, cancelled, act X-HELO: mx0a-001b2d01.pphosted.com To: GNU C Library Cc: Adhemerval Zanella From: Stefan Liebler Subject: [PATCH] S390: Fix struct sigaction for 31bit in kernel_sigaction.h. Date: Wed, 11 Apr 2018 17:22:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18041115-0044-0000-0000-000005461416 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041115-0045-0000-0000-000028864A04 Message-Id: <2b2cc2fe-2db8-ba60-62e9-d45ef48789eb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-11_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804110143 Hi, the recent commit b4a5d26d8835d972995f0a0a2f805a8845bafa0b "linux: Consolidate sigaction implementation" changed the definition of struct sigaction for s390 (31bit). Unfortunately the order of the fields were wrong. This leads to blocking testcases e.g. nptl/tst-sem11. A thread which blocks due to sem_wait() is cancelled via pthread_cancel() and the signal-handler sigcancel_handler (see /nptl/nptl-init.c is called. But it just returns as the siginfo_t argument is not setup by the kernel. Then the main-thread is blocking due to pthread_join(). The flag SA_SIGINFO is set in sa_flags in struct sigaction and is copied to the "kernel_sigaction.h" struct by the sigaction() call, but due to the wrong ordering of the struct fields, the kernel does not recognize it. This patch is fixing the definition of s390-kernel_sigaction.h struct for 31bit. Okay to commit? Bye Stefan ChangeLog: * sysdeps/unix/sysv/linux/s390/kernel_sigaction.h (struct kernel_sigaction): Use the same definition on 31bit as is used on 64bit. commit 404f5a0eac37d4c85e027c7b7fc64cb3ecbfc894 Author: Stefan Liebler Date: Wed Apr 11 16:57:48 2018 +0200 S390: Fix struct sigaction for 31bit in kernel_sigaction.h. The recent commit b4a5d26d8835d972995f0a0a2f805a8845bafa0b "linux: Consolidate sigaction implementation" changed the definition of struct sigaction for s390 (31bit). Unfortunately the order of the fields were wrong. This leads to blocking testcases e.g. nptl/tst-sem11. A thread which blocks due to sem_wait() is cancelled via pthread_cancel() and the signal-handler sigcancel_handler (see /nptl/nptl-init.c is called. But it just returns as the siginfo_t argument is not setup by the kernel. Then the main-thread is blocking due to pthread_join(). The flag SA_SIGINFO is set in sa_flags in struct sigaction and is copied to the "kernel_sigaction.h" struct by the sigaction() call, but due to the wrong ordering of the struct fields, the kernel does not recognize it. diff --git a/sysdeps/unix/sysv/linux/s390/kernel_sigaction.h b/sysdeps/unix/sysv/linux/s390/kernel_sigaction.h index a8beaf7347..28a1aa0f37 100644 --- a/sysdeps/unix/sysv/linux/s390/kernel_sigaction.h +++ b/sysdeps/unix/sysv/linux/s390/kernel_sigaction.h @@ -11,15 +11,30 @@ struct kernel_sigaction void (*_sa_sigaction)(int, siginfo_t *, void *); } _u; #define k_sa_handler _u._sa_handler -#ifndef __s390x__ - sigset_t sa_mask; - unsigned long sa_flags; - void (*sa_restorer)(void); -#else + /* The rt_sigaction-syscall (which is currently used in glibc) + expects this struct on 31bit (real 31bit-kernel or compat-mode) and 64bit! + See /include/linux/signal_types.h: struct sigaction + or /include/linux/compat.h: struct compat_sigaction. + + The sigaction-syscall (which is currently not used in glibc and was never + used on s390x 64bit) expects the kernel struct old_sigaction + and struct compat_old_sigaction. There the order of the fields is: + -_sa_handler / _sa_sigaction + -sa_mask + -sa_flags + -sa_restorer + See the same kernel-headers as mentioned above. + + The definition of struct sigaction in + /arch/s390/include/uapi/asm/signal.h + (only used for kernel-uapi) + is currently using the struct-definition for rt_sigaction-syscall on 64bit + and the struct-definition for sigaction-syscall on 31bit. + Thus we can't simply copy this definition here. + Note: This kernel-uapi-defintion will also be fixed! */ unsigned long sa_flags; void (*sa_restorer)(void); sigset_t sa_mask; -#endif }; #define SET_SA_RESTORER(kact, act) \