From patchwork Fri Nov 3 21:40:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 117961 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp213645qgn; Fri, 3 Nov 2017 14:41:14 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SPDXvGU2JRT33li9J8n44jSJ82BrUM2AyJRAiop9ly3joclZpjr+3kf+276eU9ILgwnIV0 X-Received: by 10.99.64.3 with SMTP id n3mr8366521pga.357.1509745274793; Fri, 03 Nov 2017 14:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509745274; cv=none; d=google.com; s=arc-20160816; b=fPmIoemxLZwx94GdDsNvpsr8HyXy616TA66UIVOhS8ye7ICEhzV2Uwipahd3xm5QSx cP+aqOZIqV+6NtBosNe4eUcxyZ+thfqaDaywfgWeRB5ahUpiofih/x8OCOCLzNt66Tyr wmqffMxw3qLPPmnhYnYYc91PfvodkS3NSmgKOYFSrbaLameXq2x30LYNtKeezavR4m7B D7PDBiUZdnAQEKkJrDHp5AXaU2ei1rI77q61hb9XGcXE0IVo/4Ry7LJICcFUqiBZTauF HFiyg1REWdOnCosaAH8cGYJnB2s/p4JrifAlS6cQQFYHLiSJq5HfLWEb+eYLc0hJ/fuh UlUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=MwCNOpr91KHbem/OvJJpup9YYGkkZtCHtqkqnw9jCCw=; b=LODLjn882dAacC+3bJm37riEYdAwIuu8l4dgVh5cKu0UNTnzgl2Uef06308ZcZGJBq 2yjetnu+9EzGf+Zp3t7cavloWFistNfPQ2Hejuk6Kx8PMVvq/nE56B+aGcQaXa2UeHhr nVW+32nNrcc/fe/OhlWRn9+jNLBjUPIlV7QFTWLnTLVo0VVGBbbqjKLpAcD9J55ROGmn 0qxV2Ox2fdY1WYhZxvlRBQ/xtNe2WGqz1fo1Nl2V2z3swQqaKtAj2OMw0rtC2hJdgoRu KI2H37jR/vY2fsoMO9TwUybrCCS4qiTgSPt2tgswWoleA4ehwWfqPAv236XgpE8Rh4aS zuuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=KDbJT2JE; spf=pass (google.com: domain of libc-alpha-return-86726-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86726-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b1si4632696pls.445.2017.11.03.14.41.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 14:41:14 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86726-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=KDbJT2JE; spf=pass (google.com: domain of libc-alpha-return-86726-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86726-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=Oavo2DpbtHrfNwukUMBNfjwDSSLrJV//LuVfyW/kuDkDvodGUbTqD 9w/f5Z8+MhDJJA8Qlqp6idxMAXCRYjS2Q2m6WAZQK5Q7vVzFFiJdEfISpXLSkCa/ ZilBITtreEHQje67gWs7cYkgUoOoNDdS3v0MEtk2FrmlBKfd4nugj0= 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:from:to:subject:date:message-id; s=default; bh=GXdWzjPZj1Ga5L1Zn6ilcT/F4u8=; b=KDbJT2JE1bu/eMwra48nqEqACt6Q wTfSe6k5n3KRkI1FGgczvNhhnR5MGTxvyV4autP1SKPOCK/yUzeBk3NFLDArbeyX cV5VvdfP3Jh9vlgneqZjKSm9mLZd7ikOT7adMkNuxHKTo7mYfJdLNc6QPRTH+Oxu szUx8xODp4WlKBA= Received: (qmail 37670 invoked by alias); 3 Nov 2017 21:41:04 -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 37649 invoked by uid 89); 3 Nov 2017 21:41:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f194.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=MwCNOpr91KHbem/OvJJpup9YYGkkZtCHtqkqnw9jCCw=; b=M6SxzZ2b56lyWAnO+3ntHplQfU8mugcf4fcyghY8zlnAtuZKQXwY1pw+Ja8szn38lh QSZmL3z9G8ge223FistHD0Fxolprdv2IUFUCyMozTuIXs5NgZbq7DVsdW1H5CJTqXvCV 0u7k2IxmFltrkifmPJytYd1X3rye/SH+sIWrw9cZDifce9u7Mu7wZhBahKAN1lkbmKA+ ZPQDEB0F8Y55D4eji/sQdAYmPZeBJQXqVdNU0orQTy3En6td4cHYlcCFYROetJjXdqG1 2pqXVXyX9zychXYORGmMBScXzGYBDxe/f2RMrqYAfGA5a5OwFQfuY0Q4NjaRsR0qYPqO 0MAA== X-Gm-Message-State: AMCzsaW4YH5B25++SGUq1+LIj12EI97y62TwKd7hAAu5c8k9EEWBqP1i fyA8UI/w+qgpO7rAM6hxv55679HsOHg= X-Received: by 10.200.53.34 with SMTP id y31mr12585697qtb.206.1509745258204; Fri, 03 Nov 2017 14:40:58 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/6] Consolidate Linux sigprocmask implementation (BZ #22391) Date: Fri, 3 Nov 2017 19:40:44 -0200 Message-Id: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates the sigprocmask Linux syscall implementation on sysdeps/unix/sysv/linux/sigprocmask.c. The changes are: 1. For ia64, s390-64, sparc64, and x86_64 the default semantic for filter out SIGCANCEL and SIGSETXID is used. Also the Linux pthread semantic is documented in the signal chapter. 2. A new internal function to check for NPTL internal signals within a signal set is added (__nptl_has_internal_signal). It is used to simplify the default sigprocmask.c implementation. Checked on x86_64-linux-gnu. [BZ #22391] * manual/signal.texi: Add a note about internal pthread signals on Linux. * sysdeps/unix/sysv/linux/ia64/sigprocmask.c: Remove file. * sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/x86_64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/nptl-signals.h (__nptl_has_internal_signal): New function. * sysdeps/unix/sysv/linux/sigprocmask.c (__sigprocmask): Use __nptl_has_internal_signal and __nptl_clear_internal_signals function. Signed-off-by: Adhemerval Zanella Reported-by: Yury Norov --- ChangeLog | 17 +++++++ manual/signal.texi | 5 ++ sysdeps/unix/sysv/linux/alpha/sigprocmask.c | 58 ---------------------- sysdeps/unix/sysv/linux/ia64/sigprocmask.c | 40 --------------- sysdeps/unix/sysv/linux/nptl-signals.h | 6 +++ sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c | 38 -------------- sysdeps/unix/sysv/linux/sigprocmask.c | 23 +++------ .../unix/sysv/linux/sparc/sparc64/sigprocmask.c | 34 ------------- sysdeps/unix/sysv/linux/x86_64/sigprocmask.c | 39 --------------- 9 files changed, 34 insertions(+), 226 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/alpha/sigprocmask.c delete mode 100644 sysdeps/unix/sysv/linux/ia64/sigprocmask.c delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/sigprocmask.c -- 2.7.4 diff --git a/manual/signal.texi b/manual/signal.texi index 9577ff0..46696af 100644 --- a/manual/signal.texi +++ b/manual/signal.texi @@ -2461,6 +2461,11 @@ well. (In addition, it's not wise to put into your program an assumption that the system has no signals aside from the ones you know about.) +On Linux pthreads internally uses some signals to implement asynchronous +cancellation, effective ID synchronization for POSIX conformance, and +posix timer management. These signals are filtered out on signal set +function manipulation. + @deftypefun int sigemptyset (sigset_t *@var{set}) @standards{POSIX.1, signal.h} @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} diff --git a/sysdeps/unix/sysv/linux/alpha/sigprocmask.c b/sysdeps/unix/sysv/linux/alpha/sigprocmask.c deleted file mode 100644 index ebec70c..0000000 --- a/sysdeps/unix/sysv/linux/alpha/sigprocmask.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 1993-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by David Mosberger (davidm@azstarnet.com). - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include - -/* When there is kernel support for more than 64 signals, we'll have to - switch to a new system call convention here. */ - -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - unsigned long int setval; - long result; - - if (set) - setval = set->__val[0]; - else - { - setval = 0; - how = SIG_BLOCK; /* ensure blocked mask doesn't get changed */ - } - - result = INLINE_SYSCALL (osf_sigprocmask, 2, how, setval); - if (result == -1) - /* If there are ever more than 63 signals, we need to recode this - in assembler since we wouldn't be able to distinguish a mask of - all 1s from -1, but for now, we're doing just fine... */ - return result; - - if (oset) - { - oset->__val[0] = result; - result = _SIGSET_NWORDS; - while (--result > 0) - oset->__val[result] = 0; - } - return 0; -} - -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask); diff --git a/sysdeps/unix/sysv/linux/ia64/sigprocmask.c b/sysdeps/unix/sysv/linux/ia64/sigprocmask.c deleted file mode 100644 index 920c5fd..0000000 --- a/sysdeps/unix/sysv/linux/ia64/sigprocmask.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Linux/IA64 specific sigprocmask - Written by Jes Sorensen, , April 1999. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* Linux/ia64 only has rt signals, thus we do not even want to try falling - back to the old style signals as the default Linux handler does. */ - -#include -#include -#include - -#include -#include - -/* Get and/or change the set of blocked signals. */ -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); -} -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask) diff --git a/sysdeps/unix/sysv/linux/nptl-signals.h b/sysdeps/unix/sysv/linux/nptl-signals.h index f30c597..6afd3fe 100644 --- a/sysdeps/unix/sysv/linux/nptl-signals.h +++ b/sysdeps/unix/sysv/linux/nptl-signals.h @@ -33,6 +33,12 @@ #define SIGSETXID (__SIGRTMIN + 1) +static inline bool +__nptl_has_internal_signal (const sigset_t *set) +{ + return __sigismember (set, SIGCANCEL) || __sigismember (set, SIGSETXID); +} + /* Return is sig is used internally. */ static inline int __nptl_is_internal_signal (int sig) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c b/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c deleted file mode 100644 index a8010e7..0000000 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2001-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* 64 bit Linux for S/390 only has rt signals, thus we do not even want to try - falling back to the old style signals as the default Linux handler does. */ - -#include -#include -#include - -#include -#include - -/* Get and/or change the set of blocked signals. */ -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); -} -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask) diff --git a/sysdeps/unix/sysv/linux/sigprocmask.c b/sysdeps/unix/sysv/linux/sigprocmask.c index e776563..d14fc5c 100644 --- a/sysdeps/unix/sysv/linux/sigprocmask.c +++ b/sysdeps/unix/sysv/linux/sigprocmask.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. +/* Get and/or change the set of blocked signals. Linux version. + Copyright (C) 1997-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,34 +18,22 @@ #include #include -#include /* Needed for string function builtin redirection. */ -#include +#include -#include -#include -#include /* SIGCANCEL, SIGSETXID */ - - -/* Get and/or change the set of blocked signals. */ int __sigprocmask (int how, const sigset_t *set, sigset_t *oset) { sigset_t local_newmask; - /* The only thing we have to make sure here is that SIGCANCEL and - SIGSETXID are not blocked. */ - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) - || __builtin_expect (__sigismember (set, SIGSETXID), 0))) + if (set != NULL && __glibc_unlikely (__nptl_has_internal_signal (set))) { local_newmask = *set; - __sigdelset (&local_newmask, SIGCANCEL); - __sigdelset (&local_newmask, SIGSETXID); + __nptl_clear_internal_signals (&local_newmask); set = &local_newmask; } - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); + return INLINE_SYSCALL_CALL (rt_sigprocmask, how, set, oset, _NSIG / 8); } libc_hidden_def (__sigprocmask) weak_alias (__sigprocmask, sigprocmask) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c b/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c deleted file mode 100644 index ef7d7fe..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - -#include -#include - -/* Get and/or change the set of blocked signals. */ -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); -} -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask) diff --git a/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c b/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c deleted file mode 100644 index 1610ddf..0000000 --- a/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Jes Sorensen, , April 1999. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* Linux/x86_64 only has rt signals, thus we do not even want to try falling - back to the old style signals as the default Linux handler does. */ - -#include -#include -#include - -#include -#include - -/* Get and/or change the set of blocked signals. */ -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); -} -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask) From patchwork Fri Nov 3 21:40:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 117963 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp213975qgn; Fri, 3 Nov 2017 14:41:40 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QuPF6Sq6cNK4zIslwg0khlPBBlIiFZj3ST5GRWcnZYzNjheEp823YMEIBwpy98J9CPFs26 X-Received: by 10.99.124.24 with SMTP id x24mr8308143pgc.90.1509745300716; Fri, 03 Nov 2017 14:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509745300; cv=none; d=google.com; s=arc-20160816; b=SymeaHoZg6jSa2J2UVlcx0ojC+L0mKAfUc5frTY4qB0KV+9AG4WKxc5+ihGU15pv9z 2gZ1mceVaYrEUTqeKNRAe6u1piul18d2QuMVhvXhOLMr5zfvGavHGW0aDjBgec9hQxg4 9JZXuSDXEXrrqqVcbCK0WRyaZJIqfL//1gkxB3AwPy/oW+B3noBzLoaf0pHydfVb1Qs0 418G2PA4YKbFBcMlbYtVE6zK3OclRNGMVoQjb4A2LNERQd4XRrqTFqnV4o0Gyw0OfMiC vjbwcdaZphlfc7kRNugSEGSTo9ury7K84UExDxB+0sqiCe8e5EbNOC8CwLVtI5Lt8lCK AsKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=BynrEX/rKebFySrWDudaJazmgGvvKEbg1HNqw8PnPW8=; b=Hq/MU2UWDI3uitJDgEG/85/McBbFW9R/jDYmJYqBsnsmhv0IUAed8PzyUdA3J2GcnE zm4VJhbEPwFx9ySBHA5OUNRO2SzDa2OHyfUPMBJZ1lzeJ+drTT1IMPhIiHgnvgcDgoKI yz9/P5zd6o4pOEsPzOW0djM0NbVzPYXBzTkLcGl2yAAHE5OKOGEPgOfd5cCCgiRnMBwt Jzg6be9h/dQ61FQok2OqQ7Qd2mMTLLwmc8C2D/e4ZeYnHWcMX2WlLBzaxsCSV3GIvs9k xoMhrffoIa7sK7YVXgiaOI4mkOw6MMPSPyPjcWjXJN0bRA2OS3FKDPAHHC+gVSeWaVx/ M/Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=imWcsNjk; spf=pass (google.com: domain of libc-alpha-return-86728-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86728-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g1si5483586plb.462.2017.11.03.14.41.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 14:41:40 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86728-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=imWcsNjk; spf=pass (google.com: domain of libc-alpha-return-86728-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86728-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Zi2UalR0JIssCHzQT0CBOOCr8BQafyo /ZGTC86z34E3ra6HFPF9O3+Dr1FbO+3puiA2vWInyCLNBvdWSujDFjp6erN1tifR z1BtBfmbBYW7leznncHcyNZEjF+a/PJ+8L2q3XVfIPIH5oaMTsrR4WfrO1t0fu4A CO3BWbOK+1Ro= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=dZRJtmP8Jd6/EVMBhfoWulC3Dkw=; b=imWcs NjkVv5QDYhlCEIQxW6f1W0SonGSfNtxfe1UsqV1K+Fe6E+Xy3WQc+K0lRAOikDvZ 7GBtzoN4KB5K0qZ6JTCYRW7upekvSMISzmCtTNNxadFX/COfIHtAiU/cJis1rQ/p J/vlKhAXXNB6SE21A6PUBK7xD6BinIBCwz9/KI= Received: (qmail 37906 invoked by alias); 3 Nov 2017 21:41:05 -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 37763 invoked by uid 89); 3 Nov 2017 21:41:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=communicate, filters X-HELO: mail-qk0-f169.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=BynrEX/rKebFySrWDudaJazmgGvvKEbg1HNqw8PnPW8=; b=P6L+6u+TOPBmWxJ2YGbKehg3kqH9uoILUkWqa05EFYV0RmOYAJdFyIcWawgKjvdESw H4Pz8fMD/Evk0RqDY2oUWkM42eW6RBUXlB6FaRGohewmIiWjeJCjQIyoLk1oBpyvWWgh cXkwjY22eDkX93U5QJ3w0J1DoSU+BIvrt/nhqizD7lb6CaEBHkD4ukKuet03DRTMeFD5 9xcDikEEuiuUj412C3nC3OTwAdSiiNxb3jAh+Nudg94w5ssGZ6TpctxX/IknxXhYb+j/ kRw7cu7I1BXwTJZ4fJd8986vFkci2FCInMOlyvwlbETQmVriuGzN+JH6fI5a4HFHJvuM tVRA== X-Gm-Message-State: AMCzsaVGRtKG4D/02aL7QYYbwFtlN6PK4MtgNhZYhOiLclerb8dsB4EX ltFssojb1ciFA/WUwdqYOEUpXFyes0M= X-Received: by 10.55.191.195 with SMTP id p186mr11813695qkf.152.1509745259662; Fri, 03 Nov 2017 14:40:59 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/6] Filter out NPTL internal signals (BZ #22391) Date: Fri, 3 Nov 2017 19:40:45 -0200 Message-Id: <1509745249-11404-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> This patch filters out the internal NPTL signals (SIGCANCEL/SIGTIMER and SIGSETXID) from signal functions. GLIBC on Linux requires both signals to proper implement pthread cancellation, posix timers, and set*id posix thread synchronization. And not filtering out the internal signal is troublesome: - A conformant program on a architecture that does not filter out the signals might inadvertently disable pthread asynchronous cancellation, set*id synchronization or posix timers. - It might also to security issues if SIGSETXID is masked and set*id functions are called (some threads might have effective user or group id different from the rest). The changes are basically: - Change __nptl_is_internal_signal to bool and used on all signal function that has a signal number as input. Also for signal function which accepts signals sets (sigset_t) it assumes that canonical function were used to add/remove signals which lead to some input simplification. - Fix tst-sigset.c to avoid check for SIGCANCEL/SIGTIMER and SIGSETXID. It is rewritten to check each signal indidually and to check realtime signals using canonical macros. - Add generic __nptl_clear_internal_signals and __nptl_is_internal_signal version since both symbols are used on generic implementations. - Remove superflous sysdeps/nptl/sigfillset.c. - Remove superflous SIGTIMER handling on Linux __nptl_is_internal_signal since it is the same of SIGCANCEL. - Remove dnagling define and obvious comment on nptl/sigaction.c. Checked on x86_64-linux-gnu. [BZ #22391] * nptl/sigaction.c (__sigaction): Use __nptl_is_internal_signal to check for internal nptl signals. * signal/sigaddset.c (sigaddset): Likewise. * signal/sigdelset.c (sigdelset): Likewise. * sysdeps/posix/signal.c (__bsd_signal): Likewise. * sysdeps/posix/sigset.c (sigset): Call and check sigaddset return value. * signal/sigfillset.c (sigfillset): User __nptl_clear_internal_signals to filter out internal nptl signals. * signal/tst-sigset.c (do_test): Check ech signal indidually and also check realtime signals using standard macros. * sysdeps/nptl/nptl-signals.h (__nptl_clear_internal_signals, __nptl_is_internal_signal): New functions. * sysdeps/nptl/sigfillset.c: Remove file. * sysdeps/unix/sysv/linux/nptl-signals.h (__nptl_is_internal_signal): Change return to bool. (__nptl_clear_internal_signals): Remove SIGTIMER clean since it is equal to SIGCANEL on Linux. * sysdeps/unix/sysv/linux/sigtimedwait.c (__sigtimedwait): Assume signal set was constructed using standard functions. * sysdeps/unix/sysv/linux/sigwait.c (do_sigtwait): Likewise. Signed-off-by: Adhemerval Zanella Reported-by: Yury Norov --- ChangeLog | 25 +++++++++ nptl/sigaction.c | 14 +----- signal/sigaction.c | 2 +- signal/sigaddset.c | 5 +- signal/sigdelset.c | 5 +- signal/sigfillset.c | 10 +--- signal/tst-sigset.c | 92 +++++++++++++++++++++++++--------- sysdeps/nptl/nptl-signals.h | 12 +++++ sysdeps/nptl/sigfillset.c | 20 -------- sysdeps/posix/signal.c | 5 +- sysdeps/posix/sigset.c | 10 +--- sysdeps/unix/sysv/linux/nptl-signals.h | 10 +++- sysdeps/unix/sysv/linux/sigtimedwait.c | 17 +------ sysdeps/unix/sysv/linux/sigwait.c | 13 ----- 14 files changed, 130 insertions(+), 110 deletions(-) delete mode 100644 sysdeps/nptl/sigfillset.c -- 2.7.4 diff --git a/nptl/sigaction.c b/nptl/sigaction.c index 2994fd5..e243515 100644 --- a/nptl/sigaction.c +++ b/nptl/sigaction.c @@ -16,22 +16,12 @@ License along with the GNU C Library; if not, see . */ - -/* This is no complete implementation. The file is meant to be - included in the real implementation to provide the wrapper around - __libc_sigaction. */ - -#include - -/* We use the libc implementation but we tell it to not allow - SIGCANCEL or SIGTIMER to be handled. */ -#define LIBC_SIGACTION 1 - +#include int __sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { - if (__glibc_unlikely (sig == SIGCANCEL || sig == SIGSETXID)) + if (sig <= 0 || sig >= NSIG || __nptl_is_internal_signal (sig)) { __set_errno (EINVAL); return -1; diff --git a/signal/sigaction.c b/signal/sigaction.c index 8a6220c..2717989 100644 --- a/signal/sigaction.c +++ b/signal/sigaction.c @@ -24,7 +24,7 @@ int __sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { - if (sig <= 0 || sig >= NSIG) + if (sig <= 0 || sig >= NSIG || __nptl_is_internal_signal (sig)) { __set_errno (EINVAL); return -1; diff --git a/signal/sigaddset.c b/signal/sigaddset.c index 161be7b..b282024 100644 --- a/signal/sigaddset.c +++ b/signal/sigaddset.c @@ -17,13 +17,14 @@ #include #include -#include +#include /* Add SIGNO to SET. */ int sigaddset (sigset_t *set, int signo) { - if (set == NULL || signo <= 0 || signo >= NSIG) + if (set == NULL || signo <= 0 || signo >= NSIG + || __nptl_is_internal_signal (signo)) { __set_errno (EINVAL); return -1; diff --git a/signal/sigdelset.c b/signal/sigdelset.c index 2aaa536..6ca7834 100644 --- a/signal/sigdelset.c +++ b/signal/sigdelset.c @@ -17,13 +17,14 @@ #include #include -#include +#include /* Add SIGNO to SET. */ int sigdelset (sigset_t *set, int signo) { - if (set == NULL || signo <= 0 || signo >= NSIG) + if (set == NULL || signo <= 0 || signo >= NSIG + || __nptl_is_internal_signal (signo)) { __set_errno (EINVAL); return -1; diff --git a/signal/sigfillset.c b/signal/sigfillset.c index 0fcc24a..75f432f 100644 --- a/signal/sigfillset.c +++ b/signal/sigfillset.c @@ -18,6 +18,7 @@ #include #include #include +#include /* Set all signals in SET. */ int @@ -31,14 +32,7 @@ sigfillset (sigset_t *set) memset (set, 0xff, sizeof (sigset_t)); - /* If the implementation uses a cancellation signal don't set the bit. */ -#ifdef SIGCANCEL - __sigdelset (set, SIGCANCEL); -#endif - /* Likewise for the signal to implement setxid. */ -#ifdef SIGSETXID - __sigdelset (set, SIGSETXID); -#endif + __nptl_clear_internal_signals (set); return 0; } diff --git a/signal/tst-sigset.c b/signal/tst-sigset.c index d47adcc..a2b764d 100644 --- a/signal/tst-sigset.c +++ b/signal/tst-sigset.c @@ -1,43 +1,85 @@ /* Test sig*set functions. */ #include -#include -#define TEST_FUNCTION do_test () +#include + static int do_test (void) { - int result = 0; - int sig = -1; + sigset_t set; + TEST_VERIFY (sigemptyset (&set) == 0); -#define TRY(call) \ - if (call) \ - { \ - printf ("%s (sig = %d): %m\n", #call, sig); \ - result = 1; \ - } \ - else +#define VERIFY(set, sig) \ + TEST_VERIFY (sigismember (&set, sig) == 0); \ + TEST_VERIFY (sigaddset (&set, sig) == 0); \ + TEST_VERIFY (sigismember (&set, sig) != 0); \ + TEST_VERIFY (sigdelset (&set, sig) == 0); \ + TEST_VERIFY (sigismember (&set, sig) == 0) + /* ISO C99 signals. */ + VERIFY (set, SIGINT); + VERIFY (set, SIGILL); + VERIFY (set, SIGABRT); + VERIFY (set, SIGFPE); + VERIFY (set, SIGSEGV); + VERIFY (set, SIGTERM); - sigset_t set; - TRY (sigemptyset (&set) != 0); + /* Historical signals specified by POSIX. */ + VERIFY (set, SIGHUP); + VERIFY (set, SIGQUIT); + VERIFY (set, SIGTRAP); + VERIFY (set, SIGKILL); + VERIFY (set, SIGBUS); + VERIFY (set, SIGSYS); + VERIFY (set, SIGPIPE); + VERIFY (set, SIGALRM); + + /* New(er) POSIX signals (1003.1-2008, 1003.1-2013). */ + VERIFY (set, SIGURG); + VERIFY (set, SIGSTOP); + VERIFY (set, SIGTSTP); + VERIFY (set, SIGCONT); + VERIFY (set, SIGCHLD); + VERIFY (set, SIGTTIN); + VERIFY (set, SIGTTOU); + VERIFY (set, SIGPOLL); + VERIFY (set, SIGXCPU); + VERIFY (set, SIGXFSZ); + VERIFY (set, SIGVTALRM); + VERIFY (set, SIGPROF); + VERIFY (set, SIGUSR1); + VERIFY (set, SIGUSR2); + + /* Nonstandard signals found in all modern POSIX systems + (including both BSD and Linux). */ + VERIFY (set, SIGWINCH); -#ifdef SIGRTMAX - int max_sig = SIGRTMAX; -#else - int max_sig = NSIG - 1; + /* Arch-specific signals. */ +#ifdef SIGEMT + VERIFY (set, SIGEMT); +#endif +#ifdef SIGLOST + VERIFY (set, SIGLOST); +#endif +#ifdef SIGINFO + VERIFY (set, SIGINFO); +#endif +#ifdef SIGSTKFLT + VERIFY (set, SIGSTKFLT); +#endif +#ifdef SIGPWR + VERIFY (set, SIGPWR); #endif - for (sig = 1; sig <= max_sig; ++sig) + /* Read-time signals (POSIX.1b real-time extensions). If they are + supported SIGRTMAX value is greater than SIGRTMIN. */ + for (int rtsig = SIGRTMIN; rtsig <= SIGRTMAX; rtsig++) { - TRY (sigismember (&set, sig) != 0); - TRY (sigaddset (&set, sig) != 0); - TRY (sigismember (&set, sig) == 0); - TRY (sigdelset (&set, sig) != 0); - TRY (sigismember (&set, sig) != 0); + VERIFY (set, rtsig); } - return result; + return 0; } -#include "../test-skeleton.c" +#include diff --git a/sysdeps/nptl/nptl-signals.h b/sysdeps/nptl/nptl-signals.h index 298acf2..3fe53cc 100644 --- a/sysdeps/nptl/nptl-signals.h +++ b/sysdeps/nptl/nptl-signals.h @@ -20,3 +20,15 @@ signal numbers reserved by libpthread for those internal purposes. Note that some code presumes SIGTIMER is the same as SIGCANCEL. */ + +/* Remove internal glibc signal from the mask. */ +static inline void +__nptl_clear_internal_signals (sigset_t *set) +{ +} + +static inline bool +__nptl_is_internal_signal (int sig) +{ + return false; +} diff --git a/sysdeps/nptl/sigfillset.c b/sysdeps/nptl/sigfillset.c deleted file mode 100644 index 50e8512..0000000 --- a/sysdeps/nptl/sigfillset.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -#include diff --git a/sysdeps/posix/signal.c b/sysdeps/posix/signal.c index 81ba177..79b5160 100644 --- a/sysdeps/posix/signal.c +++ b/sysdeps/posix/signal.c @@ -18,8 +18,8 @@ #include #include -#include /* For the real memset prototype. */ #include +#include sigset_t _sigintr attribute_hidden; /* Set by siginterrupt. */ @@ -31,7 +31,8 @@ __bsd_signal (int sig, __sighandler_t handler) struct sigaction act, oact; /* Check signal extents to protect __sigismember. */ - if (handler == SIG_ERR || sig < 1 || sig >= NSIG) + if (handler == SIG_ERR || sig < 1 || sig >= NSIG + || __nptl_is_internal_signal (sig)) { __set_errno (EINVAL); return SIG_ERR; diff --git a/sysdeps/posix/sigset.c b/sysdeps/posix/sigset.c index a4dfe0a..6234ecf 100644 --- a/sysdeps/posix/sigset.c +++ b/sysdeps/posix/sigset.c @@ -31,15 +31,9 @@ sigset (int sig, __sighandler_t disp) sigset_t set; sigset_t oset; - /* Check signal extents to protect __sigismember. */ - if (disp == SIG_ERR || sig < 1 || sig >= NSIG) - { - __set_errno (EINVAL); - return SIG_ERR; - } - __sigemptyset (&set); - __sigaddset (&set, sig); + if (sigaddset (&set, sig) < 0) + return SIG_ERR; if (disp == SIG_HOLD) { diff --git a/sysdeps/unix/sysv/linux/nptl-signals.h b/sysdeps/unix/sysv/linux/nptl-signals.h index 6afd3fe..1e22201 100644 --- a/sysdeps/unix/sysv/linux/nptl-signals.h +++ b/sysdeps/unix/sysv/linux/nptl-signals.h @@ -16,8 +16,13 @@ License along with the GNU C Library; if not, see . */ +#ifndef __NPTL_SIGNALS_H +# define __NPTL_SIGNALS_H + #include #include +#include +#include /* The signal used for asynchronous cancelation. */ #define SIGCANCEL __SIGRTMIN @@ -40,7 +45,7 @@ __nptl_has_internal_signal (const sigset_t *set) } /* Return is sig is used internally. */ -static inline int +static inline bool __nptl_is_internal_signal (int sig) { return (sig == SIGCANCEL) || (sig == SIGTIMER) || (sig == SIGSETXID); @@ -51,7 +56,6 @@ static inline void __nptl_clear_internal_signals (sigset_t *set) { __sigdelset (set, SIGCANCEL); - __sigdelset (set, SIGTIMER); __sigdelset (set, SIGSETXID); } @@ -89,3 +93,5 @@ __libc_signal_restore_set (const sigset_t *set) /* Used to communicate with signal handler. */ extern struct xid_command *__xidcmd attribute_hidden; + +#endif /* __NPTL_SIGNALS_H */ diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c index 42afbce..21e9fca 100644 --- a/sysdeps/unix/sysv/linux/sigtimedwait.c +++ b/sysdeps/unix/sysv/linux/sigtimedwait.c @@ -29,21 +29,8 @@ int __sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout) { - sigset_t tmpset; - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) - || __builtin_expect (__sigismember (set, SIGSETXID), 0))) - { - /* Create a temporary mask without the bit for SIGCANCEL set. */ - // We are not copying more than we have to. - memcpy (&tmpset, set, _NSIG / 8); - __sigdelset (&tmpset, SIGCANCEL); - __sigdelset (&tmpset, SIGSETXID); - set = &tmpset; - } - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ int result = SYSCALL_CANCEL (rt_sigtimedwait, set, info, timeout, _NSIG / 8); /* The kernel generates a SI_TKILL code in si_code in case tkill is diff --git a/sysdeps/unix/sysv/linux/sigwait.c b/sysdeps/unix/sysv/linux/sigwait.c index 395bd9f..18a4485 100644 --- a/sysdeps/unix/sysv/linux/sigwait.c +++ b/sysdeps/unix/sysv/linux/sigwait.c @@ -33,19 +33,6 @@ do_sigwait (const sigset_t *set, int *sig) { int ret; - sigset_t tmpset; - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) - || __builtin_expect (__sigismember (set, SIGSETXID), 0))) - { - /* Create a temporary mask without the bit for SIGCANCEL set. */ - // We are not copying more than we have to. - memcpy (&tmpset, set, _NSIG / 8); - __sigdelset (&tmpset, SIGCANCEL); - __sigdelset (&tmpset, SIGSETXID); - set = &tmpset; - } - /* XXX The size argument hopefully will have to be changed to the real size of the user-level sigset_t. */ #ifdef INTERNAL_SYSCALL From patchwork Fri Nov 3 21:40:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 117962 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp213784qgn; Fri, 3 Nov 2017 14:41:26 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QEIXYm19NYIIpmT/BdMc5AD4pUWj281I1cRrX6qcKxs0KuDaIe1irGIWxYqPqSOHmnou7k X-Received: by 10.159.211.65 with SMTP id g1mr8147904plp.312.1509745286485; Fri, 03 Nov 2017 14:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509745286; cv=none; d=google.com; s=arc-20160816; b=cQdPeHJ/M4jPZ1aWvsDuR265QXr+XcSSe3DvprHTi16jvK8cTWIEEtVLez9Zt40fVL YT5C4AAcRUD6gLzGqFlNIGg+YvUYxS/kNoA1rBmLfsgs5t8hEpiNJ1MBM3pEK409Smha d9Sy1/lk8Yj8gFpSXktye5XT/ahbcEwZaTQKu+LTPYiMf987B99sg4iAxxOy/DY7AK7e q2do817bu3yDng1jcWtJ9YGTYsRvB6J9sPuzOjxpdaMt1yaBEwKnE2D4+WfhMrRM1vq+ wD+U6S5jRcw85vZayT0WaBWaYx9K+OY3hb4DGoFFZ72TvHuRuTSusLt4iAbJ6wzc2Uud 3vHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=HdkD0T2n21vHzg99cvVKfadB/caMe+eoTMlf13Eqqe0=; b=rxlQo9BM6vkz2vtvk/864zaHOVE9n38NrqHzHwud/ydA8LnCWBr4kDdSMPuFkFkQs/ DiOVQlNS3LAWfghKdpETTZqpfcKJaiuEFAk4J485GSffc6awy+hEIECUnuijOLnP4DcF VDqqdZzotBaGwhw6OZag105XPK1Lkh4IgkUyXVljyehab4dG/Gi/Hdn+rr2/2/rxdyF0 weeuWWIUkINlpKHZEvJM6HF4ELNSRAVRLP+w020ONk2riJWKXyn6CqrHYe9baEyoXRGr wu7Nwc5qoGbiGoCGqGWPx0UfDOuHn1gcyZxMvCqnI2zTT67/ciY/pmywvCoAZJy8+hEV h3wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IxFDjgRg; spf=pass (google.com: domain of libc-alpha-return-86727-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86727-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o69si7412818pfi.63.2017.11.03.14.41.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 14:41:26 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86727-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IxFDjgRg; spf=pass (google.com: domain of libc-alpha-return-86727-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86727-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=HlC63dHFziVo1FgRZaDiC6anGo0dA8D PmFxe5lBccAtXMGwrGHDBCdO3ren5ba2Mq0HkLaPIMm0hcBO7JeRstPhlUrqL8Wl Fd8TF1bmXs8rejzTxxnLq+kF6RF8NhshUmqMOkdJKQMt7Oqg56eaAT/of0rqUOYS YbW0yhAZDgXA= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=6l+Qe8AfFfma4KUiVdjjyDvSV+Y=; b=IxFDj gRgMtO4vubbbqgkf9T0hsL2sTsZrXoIlpGKR9R4Ko/ZtqDkX9W3aJD8Qrwp5Jt3v fwNzswPlLfYS0uqEUH1L8n4M0d0jEyEjMCpaqNImb3Go9SZSg/E0YyiIJa2kz4uR tW3m3aHZKW34u6mE3EKCOzVQI3UolEcvyoP0eY= Received: (qmail 37793 invoked by alias); 3 Nov 2017 21:41:05 -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 37742 invoked by uid 89); 3 Nov 2017 21:41:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HdkD0T2n21vHzg99cvVKfadB/caMe+eoTMlf13Eqqe0=; b=tG1YL4PdRKsAuJqo14iOBZLARnGO8sagmu9nwX++3s9vWyv0WixZ2Ci3PirUPYyb+A OPsunWbKcJYURahRRVF7B/ThjvGJT7zCkRz7GdJdycxmkxUZ9QNQtN3bEZ/DiAKAxSkN IlTHYCMoMVyQBqVY44BnPMZQ8ILvzgq4Mzgp9DdC1x7OtZu+GST4zjtlOMlOLjDha4a8 MZMUoto3Jz0/ICY7GywaqUkyj0ZMJ90l8FNvD4rTaqop1ZpAeY+fKJDgirEaBhVYrWNH yBlWl42y1uO57m9QJxbgERzk68yMMlbUEwEORjdXOqnZDTFlyOVFQjuHtnT1wC/Pqh+x tM8Q== X-Gm-Message-State: AJaThX7kougyHzr1YQBmoEqldtmZ5MWiH77/vTPWmoBh7r50pVBEmIQQ 5ikZNhdCzfFGnIABKgUVUOXSKVj7fG4= X-Received: by 10.55.212.149 with SMTP id s21mr11573798qks.16.1509745261098; Fri, 03 Nov 2017 14:41:01 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/6] Simplify Linux sig{timed}wait{info} implementations Date: Fri, 3 Nov 2017 19:40:46 -0200 Message-Id: <1509745249-11404-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> This patch simplifies sig{timed}wait{info} by: - Assuming __NR_rt_sigtimedwait existence on all architectures due minimum kernel version requirement. - Add libc.so private __sigtimedwait symbol. - Call __sigtimedwait on both sigwait and sigwaitinfo. Checked on x86_64-linux-gnu. * sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add __sigtimedwait. * sysdeps/unix/sysv/linux/sigtimedwait.c: Simplify includes and assume __NR_rt_sigtimedwait. * sysdeps/unix/sysv/linux/sigwait.c (__sigwait): Call __sigtimedwait. * sysdeps/unix/sysv/linux/sigwaitinfo.c (__sigwaitinfo): Likewise. Signed-off-by: Adhemerval Zanella --- ChangeLog | 7 ++++ sysdeps/unix/sysv/linux/Versions | 1 + sysdeps/unix/sysv/linux/sigtimedwait.c | 9 ----- sysdeps/unix/sysv/linux/sigwait.c | 67 ++++------------------------------ sysdeps/unix/sysv/linux/sigwaitinfo.c | 40 ++------------------ 5 files changed, 18 insertions(+), 106 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 6c9e06f..d3dbcde 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -172,6 +172,7 @@ libc { __open_nocancel; __read_nocancel; __close_nocancel; + __sigtimedwait; # functions used by nscd __netlink_assert_response; } diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c index 21e9fca..f74a921 100644 --- a/sysdeps/unix/sysv/linux/sigtimedwait.c +++ b/sysdeps/unix/sysv/linux/sigtimedwait.c @@ -17,13 +17,7 @@ #include #include -#include - -#include #include -#include - -#ifdef __NR_rt_sigtimedwait int __sigtimedwait (const sigset_t *set, siginfo_t *info, @@ -44,6 +38,3 @@ __sigtimedwait (const sigset_t *set, siginfo_t *info, } libc_hidden_def (__sigtimedwait) weak_alias (__sigtimedwait, sigtimedwait) -#else -# include -#endif diff --git a/sysdeps/unix/sysv/linux/sigwait.c b/sysdeps/unix/sysv/linux/sigwait.c index 18a4485..2e8fa71 100644 --- a/sysdeps/unix/sysv/linux/sigwait.c +++ b/sysdeps/unix/sysv/linux/sigwait.c @@ -15,73 +15,20 @@ License along with the GNU C Library; if not, see . */ -#include #include -#define __need_NULL -#include -#include - -#include #include -#include - -#ifdef __NR_rt_sigtimedwait - -/* Return any pending signal or wait for one for the given time. */ -static int -do_sigwait (const sigset_t *set, int *sig) -{ - int ret; - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ -#ifdef INTERNAL_SYSCALL - INTERNAL_SYSCALL_DECL (err); - do - ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, set, - NULL, NULL, _NSIG / 8); - while (INTERNAL_SYSCALL_ERROR_P (ret, err) - && INTERNAL_SYSCALL_ERRNO (ret, err) == EINTR); - if (! INTERNAL_SYSCALL_ERROR_P (ret, err)) - { - *sig = ret; - ret = 0; - } - else - ret = INTERNAL_SYSCALL_ERRNO (ret, err); -#else - do - ret = INLINE_SYSCALL (rt_sigtimedwait, 4, set, NULL, NULL, _NSIG / 8); - while (ret == -1 && errno == EINTR); - if (ret != -1) - { - *sig = ret; - ret = 0; - } - else - ret = errno; -#endif - - return ret; -} int __sigwait (const sigset_t *set, int *sig) { - if (SINGLE_THREAD_P) - return do_sigwait (set, sig); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = do_sigwait (set, sig); - - LIBC_CANCEL_RESET (oldtype); - - return result; + siginfo_t si; + if (__sigtimedwait (set, &si, 0) < 0) + return -1; + *sig = si.si_signo; + return 0; } libc_hidden_def (__sigwait) weak_alias (__sigwait, sigwait) -#else -# include -#endif strong_alias (__sigwait, __libc_sigwait) + +LIBC_CANCEL_HANDLED (); diff --git a/sysdeps/unix/sysv/linux/sigwaitinfo.c b/sysdeps/unix/sysv/linux/sigwaitinfo.c index 0062d3e..6267425 100644 --- a/sysdeps/unix/sysv/linux/sigwaitinfo.c +++ b/sysdeps/unix/sysv/linux/sigwaitinfo.c @@ -15,52 +15,18 @@ License along with the GNU C Library; if not, see . */ -#include #include -#define __need_NULL -#include -#include - -#include #include -#include - -#ifdef __NR_rt_sigtimedwait /* Return any pending signal or wait for one for the given time. */ int __sigwaitinfo (const sigset_t *set, siginfo_t *info) { - sigset_t tmpset; - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) - || __builtin_expect (__sigismember (set, SIGSETXID), 0))) - { - /* Create a temporary mask without the bit for SIGCANCEL set. */ - // We are not copying more than we have to. - memcpy (&tmpset, set, _NSIG / 8); - __sigdelset (&tmpset, SIGCANCEL); - __sigdelset (&tmpset, SIGSETXID); - set = &tmpset; - } - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - int result = SYSCALL_CANCEL (rt_sigtimedwait, set, info, NULL, _NSIG / 8); - - /* The kernel generates a SI_TKILL code in si_code in case tkill is - used. tkill is transparently used in raise(). Since having - SI_TKILL as a code is useful in general we fold the results - here. */ - if (result != -1 && info != NULL && info->si_code == SI_TKILL) - info->si_code = SI_USER; - - return result; + return __sigtimedwait (set, info, 0); } libc_hidden_def (__sigwaitinfo) weak_alias (__sigwaitinfo, sigwaitinfo) -#else -# include -#endif strong_alias (__sigwaitinfo, __libc_sigwaitinfo) + +LIBC_CANCEL_HANDLED (); From patchwork Fri Nov 3 21:40:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 117964 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp214115qgn; Fri, 3 Nov 2017 14:41:50 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SexK/AjHZmgy7OIVxNr3+vfYeSzDYog0OAQWfGQwDtFEgtUiZioVRMTKh86pB6O6PdYXPr X-Received: by 10.159.207.134 with SMTP id z6mr7807684plo.272.1509745310665; Fri, 03 Nov 2017 14:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509745310; cv=none; d=google.com; s=arc-20160816; b=C6MRWh0la49D55JHsg8WBOKudsXgnmtnD9elj/xpdGkp9/GftQ8C1DvTF8gvjA/Ctu eU5mHM7dWLLwAHu811C9o+744GaN25dfUZ5mEnn5O8YOvE7mr+/sIXftkRk3BGuWyTbS NyfGWilHN8OAUMNWK8zq7TUUdqWyQKBAY7P55WmSobjRLZlmcFDlvM2ahudLHGvLhq4O kc0LJ6X4DExUNJcDMRDaY9j0TpsZEysXxhjOxNh/ZrlK30lSJhagjN9PJFn+A8agLLWa tkNzXaCmxOg2HbVZJ834PBVS2BY0h7FtDUIs9sb0e6izfAL4WspLqoCPJbdhRVCBBMqC wxKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=E0gfUwZS9kVXODJPJQhdNdPgnLYPc3DrAxH/5h67nU8=; b=ONtKUESBFjHNiWHiyR+b9Si0rmT6XQQO1xM0o+AqpxCsSbk6eajMj3sY73XHjbu7HA uxgAlqK5Lyd856MLA8KKxT7F/4+8KBjxz8rWER4QstOWe0NecAw4BZqx21Ivz+6M7O1N Vn07tfIIgeJrG9Ppt27EUS8x51mIQXmZ0sFtvfgVwCLhSU1yYVkPYHFKzuNUiY0OFqFG k1PUAKahw6bYT/FVEn0STl6m7Tf7pFCjl6CqkbUZKGHZcQ3r9UMYV+ZomXC2z+ebM6m7 a8+r+Z3GOwdSKfNQnWC2Y8D4RWolIB3TnaeNzue8wTmGR9JVCoAg7HKJplC6+lWtuj3t uMXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PaDa/3Et; spf=pass (google.com: domain of libc-alpha-return-86729-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86729-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 15si5947968pld.802.2017.11.03.14.41.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 14:41:50 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86729-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PaDa/3Et; spf=pass (google.com: domain of libc-alpha-return-86729-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86729-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=jKBkk7DqEfSlpYOXNbsQ+TTM4Wv+YvU OLrguhsXuCTwxDbslNSyvF3HQaGJrPgIGcYX0IiucW92JAjoEJz8/V4/HwV8m2OA DjrN4ROmIx9vWwgeOvoj/ZyxtY7+brBfm07cn7Hwh4naLemjijr6ZZ0AfmuSPKLh 8uZvC5TlhkbI= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=7n1z4IM9dlX8CC2EjGijLge418k=; b=PaDa/ 3Etz4cD0505cjqEsyk2U3+ewFb/mV3JZyN6fFQpVZ/tpNdR+ZErcWDE5DmNJ5OF3 6jGSXPFCbwQcc9e9jgxS/0fqEprzPfDW9/UgfRBV3QvHKh/poJCHWEfs84iIAN3i 2MDksCQ/3yCK2waNlZnz3nCS1E08v70rF4Z5R4= Received: (qmail 37971 invoked by alias); 3 Nov 2017 21:41:05 -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 37905 invoked by uid 89); 3 Nov 2017 21:41:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f194.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=E0gfUwZS9kVXODJPJQhdNdPgnLYPc3DrAxH/5h67nU8=; b=t8GwkDyyZse2GspvxJ3L8J6K9cwvmS+R0QbAUYm+CXloptQKvd2tsRXGcoIpebk5zg zW+0Tyze52GJryYM9eSWEfuh0LxtEtPumlW4ZBjPPuzAxvaIvEWB0RSqsNXptEbkbQoo Z+U6942oXALv8PrzKji9DgIaXf8TnD8YpkfN7eg2hoNWL1/pK6Yq2Q3aaXGfnNdzqlgZ rPMuDkzm7cDFLJYdr1U5DxT0oQDHVEty3/+jmgmOe+lK5iE6gdMXMLqYo0rqMPb7L4qn GfhYtylcRxEkSdx1Yqg3jk9HsWdrZ6D9nIfyavEKEmnQAVKeZYXICzBYiy1E4TRoG08j 66TA== X-Gm-Message-State: AJaThX7NxPdLPE6p4Bd5EMXyXAGJXGjWgqvWKbajl7VPXc5J/OF+9s7C Tmg966ssMnP63Iq+SuU8YWnxWBhwAvc= X-Received: by 10.55.168.214 with SMTP id r205mr12210713qke.238.1509745262418; Fri, 03 Nov 2017 14:41:02 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 4/6] Cleanup Linux sigqueue implementation Date: Fri, 3 Nov 2017 19:40:47 -0200 Message-Id: <1509745249-11404-4-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> This patch simplify Linux sigqueue implementation by assuming __NR_rt_sigqueueinfo existence due minimum kernel requirement. Checked on x86_64-linux-gnu. * sysdeps/unix/sysv/linux/sigqueue.c (__sigqueue): Asssume __NR_rt_sigqueueinfo. Signed-off-by: Adhemerval Zanella --- ChangeLog | 3 +++ sysdeps/unix/sysv/linux/sigqueue.c | 10 ++-------- 2 files changed, 5 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/sigqueue.c b/sysdeps/unix/sysv/linux/sigqueue.c index 059e524..67bb6b2 100644 --- a/sysdeps/unix/sysv/linux/sigqueue.c +++ b/sysdeps/unix/sysv/linux/sigqueue.c @@ -17,13 +17,10 @@ #include #include -#include #include - +#include #include -#include -#ifdef __NR_rt_sigqueueinfo /* Return any pending signal or wait for one for the given time. */ int __sigqueue (pid_t pid, int sig, const union sigval val) @@ -40,9 +37,6 @@ __sigqueue (pid_t pid, int sig, const union sigval val) info.si_uid = __getuid (); info.si_value = val; - return INLINE_SYSCALL (rt_sigqueueinfo, 3, pid, sig, &info); + return INLINE_SYSCALL_CALL (rt_sigqueueinfo, pid, sig, &info); } weak_alias (__sigqueue, sigqueue) -#else -# include -#endif From patchwork Fri Nov 3 21:40:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 117965 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp214322qgn; Fri, 3 Nov 2017 14:42:06 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TJPB804CZwR2S0JGGkFIIHG50JpLFb+zyoERfAJDV9YjtxPCp1R6rXlVS7hWisu6cRE1DI X-Received: by 10.84.236.12 with SMTP id q12mr7941213plk.314.1509745326714; Fri, 03 Nov 2017 14:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509745326; cv=none; d=google.com; s=arc-20160816; b=HbxczTo9l/acfdOX+N4a0JMjyy8PffOms+pasHFr7b627RvSrwOqUVAx9gqd60c1Mf d6YQZJIk4ha1N0HxoPFRXOkq8kWi3tUAAuUcgpPxRgtuAzyJI0kOePJaurXcMu1ksNvq t6Pfw6BAINifqVj2Qyytw0mBnDmcWs3wQ+400CJqg/9nwAZMtuX4V5Jp74St2FmECjyo Qx6Vn9/Ka8SKvYcVpCwinan2/Km1GB+r1V8b27egqXDso9chCNwdnQaUYgPGONwYxYjq ktgmVpVw7Pevy5ewnTUz1ceCrhL/hT82RQT+KlwVb6oP85uIO+NDOix+wfA4OdYoEdBS F44Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=3l7+yspJC4LaeFVnz2D5Rmamb0AtBF407lwLW2BX6M8=; b=mfIooScLY5fCGy+T79P1+KIceZyyLUAA4GNyMguE1UHrZ+8fxKuFohVMcXCP7N9cnL xHOHiyKAllDSjnk8PXJ+zv0it5S7JQnX/cbltjdzL2nlko3FthLpQzQrrW3lPpt2R5VV iVuATZoONO1/kK4o/Vl2hBjD2dUZl6gvVxdRfxbqKhUWyhMjakdWMkhxcNmDRX/uXXzU Z5/NyXKpQxpxIc/9qc/Xc16iinpopWM4VVDEs5iMQ6g8xEsonUHaRfZxEoG30cCCNDOf XLUX3koJaUlJjTWLR0EXfSUk87SUweClyVQ2esf5wFu5zISOuLPkZuECEGBpwSgUEjuu Ak9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=LTXFSCUB; spf=pass (google.com: domain of libc-alpha-return-86730-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86730-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h128si7298381pfb.121.2017.11.03.14.42.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 14:42:06 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86730-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=LTXFSCUB; spf=pass (google.com: domain of libc-alpha-return-86730-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86730-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=kqUzIcqiJjbBtx0xDRE4GnB2tmbiHaw 1JqaEwbejV/VACk9CN4SIR9jPApEjxdRC0KCZeN6AFq8hjZmCBANevmFYtBKXn4w RDjFfYmlDDbXJweHlhUrXYNTGQz5QB5SjlzkyFeuuvUCDnt0cQuOrrAvLXvoNVPk hDPSnHyxQRn4= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=qw97PcsGyWzGFZye5I9wJ3/Z5fk=; b=LTXFS CUB+VN0IpiDtcvm1s1XlPg9mtqZQzh3pOL1pGGUWlhE/4f+CbPKYEoQx+GVvBqla jZb0WhYtMlyqn2PbCxsukam5si7opZy20Kym6TTpkpNMnWyh7EpWMWfvLpEJXv22 EXDmWmaGODQjgJW7C230lvW8g+oiKkf/V6dEyA= Received: (qmail 38168 invoked by alias); 3 Nov 2017 21:41:07 -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 38114 invoked by uid 89); 3 Nov 2017 21:41:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=3l7+yspJC4LaeFVnz2D5Rmamb0AtBF407lwLW2BX6M8=; b=ZJd9xtdbAhasJ9+kUAurL+MAAq05ySzrTTHZL5civQbcZIbQ0Fb62+cli6kBNDcQGP /dpaLGPhqOJDkuxi0ieigCCLz0chjmpqRG2RdenFSKnoN0brcBBm3/3ms//3B9+sMfeg HaSbdc2Hb9HlPuD3LZQIyz7/wSZNBJ3gkfV8FixNYaP/fg7fVlvSxUO0txMK3tF6rdJb 86clDcaOP8i7OTa2P/b8IDmDhIEfdJ3IUYKIUymafLkU8s2ccfyB14Al9XFvF2d9SYuB ktHGaQVGSfMRHiYp5hYkQ9zLrSfGXstMu5lJeWpTSkP6Ott8T+0ymHV/U477+VaHpszb 1udg== X-Gm-Message-State: AMCzsaXcYgmxwq7QNMwM5pnkQVZ8namjadWSWz7cMUHFTGhQMu038HmA rmAtPRl+0ns/nM8H9OabzQHcOMQNPZg= X-Received: by 10.237.36.130 with SMTP id t2mr12124575qtc.148.1509745263776; Fri, 03 Nov 2017 14:41:03 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 5/6] Optimize sighold implementation Date: Fri, 3 Nov 2017 19:40:48 -0200 Message-Id: <1509745249-11404-5-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> This patch simplifies sighold a bit by removing an extra sigprocmask and using SIG_BLOCK (which union of the current set and the set argument). Checked on x86_64-linux-gnu. * signal/sighold.c (sighold): Optimize implementation. Signed-off-by: Adhemerval Zanella --- ChangeLog | 2 ++ signal/sighold.c | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/signal/sighold.c b/signal/sighold.c index 2e32e47..955ac5b 100644 --- a/signal/sighold.c +++ b/signal/sighold.c @@ -26,14 +26,8 @@ sighold (int sig) { sigset_t set; - /* Retrieve current signal set. */ - if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) - return -1; - - /* Add the specified signal. */ + sigemptyset (&set); if (sigaddset (&set, sig) < 0) return -1; - - /* Set the new mask. */ - return __sigprocmask (SIG_SETMASK, &set, NULL); + return __sigprocmask (SIG_BLOCK, &set, NULL); } From patchwork Fri Nov 3 21:40:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 117966 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp214424qgn; Fri, 3 Nov 2017 14:42:14 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Sbsg9jcsrB07na2pRIqRDs5CYOfMja2ooswKL+H0MkRL7xEQzIcm9zj7SUUzOWzIC64XE9 X-Received: by 10.101.85.72 with SMTP id t8mr8431265pgr.211.1509745334186; Fri, 03 Nov 2017 14:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509745334; cv=none; d=google.com; s=arc-20160816; b=zNPjGiV4/bhku+YDgmeaYsXD0kK+WVjKwqItpqD7X7O44RByEsBBPt914ltYCVje6G 7up1YlA8SIIE0i2kfGZWD+dJiFdkN9xZdAffaeWpOJuDxfK+zhyO/e6hmL772SRtIVsc YtaVtA0NXApdBK4KF57r7PdiV/8DRpDBk6f3mh3hKP9cDkhoy/g6q/r/6Ql74ULw3MF3 l6IBwV5nFn2fwjm+xWiQDqzwgCGVFfbZNBb+/VTeEqUlGE23eOmdLm2WztoHYCjCpcKX S3QpJDXzweTowZ8TcxTSqf/nS1kZFC+Ayj9ngyvMyiJ6Y3F9KRZpleCZSGI68Wwr8L5Z RzUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Fxk3q4PdSurYhS8dg5BaTOPzydo7t6MeS5ZLKEyatv4=; b=T801UhqFlfR3LkZaADwRhQFCd1uPNAkTqBlNwzo8wsrDDzDycNxQrdeVyoZfEe4lEa 32JylxmTIrL2XYqEcmgT83RlP8bwKEWN4ausiR7BzQFb/b8c7Q0vIfWUf2ihTITvG6IQ e/K2rS9aTAtX88geIcmIFUrg/hiBk+mLvwKR4vIXgu8dikwuANYxPmvMc8xGxYmiKtLb 8flpovzvRViQIkGaHT6a13zFzkQONeXD8aCwQw69bl4WoEUFeM7WgoAaE6EULrQUypNX uOJbYjq6Jrgpsxcalmg2KFGEnQsEYhuOo45gfA8MCNVr3EkdnQxb9prJn+SiCuA4DVl1 22Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Dd0FZfEq; spf=pass (google.com: domain of libc-alpha-return-86731-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86731-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n11si4922407pls.465.2017.11.03.14.42.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 14:42:14 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86731-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Dd0FZfEq; spf=pass (google.com: domain of libc-alpha-return-86731-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86731-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=vPajd1jvA1E4SmFt7WCI0YTANFSRM94 wO5LJHVb666HJWFzwen+egXu19PQBNjMK3qIDbRL1CcXAVVZdz7Niur7nh4iqrW3 XQRFZxYb+7mxSRbJRhPjzJ803nPYpP2UkX49s2uj8UPO25Zdnx5ZJ95ndX6CwcUJ 4mhhS1Joqn1c= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=jJekoEh3uE9vWBJlfczF9TSaqFk=; b=Dd0FZ fEqY2TPoFjGt0x+V7BCjaINCOXJ47HLnSNRpY3l1EmDP5DbQB9DPfTV/E8I/0bWR SV7ZJbzoVwGzl3lfggYiIz54PhI2oIopbcA2YzAwQyGe5WN9FPvjpzfkIrRF7LCB P8WAUUe0i5U64YW0SVKjnVRmNxZrK0/lSOz7Mw= Received: (qmail 38368 invoked by alias); 3 Nov 2017 21:41:08 -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 38341 invoked by uid 89); 3 Nov 2017 21:41:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Fxk3q4PdSurYhS8dg5BaTOPzydo7t6MeS5ZLKEyatv4=; b=fvRkCXhLa28h+eDPurFP9Pn441rM++yzdUPTf+CeDM3x+BTiGSShowhEJk1+Z6UZbp ++OaUFKrIu9qS6kicuu7Qd/45YX/HWRvObjeO302UJkaBxtEkJQ9fLK3NxTZ5V2Yjj0D CPp/SDrEdN7u6S3GF8GYesX1J4NnCZpdKYLy7LIWfpYnwkSstzjesoMnc4c4KHET2ziY RLa1sNwbDYIjANZPAbCL1+sMof+QuuHuZfrIgyKfZIcLu9Zk0wDrN3fBGJHcu0pk7mu0 F67beoI5mgJ4LO3r2XYxcg/q5ktvP57RcOBRyaJmfMqwINOhsMl/Rl4zIDNMscvCRIIC TYMA== X-Gm-Message-State: AMCzsaXI+E9eZBwvEh0NCMDn0VF1Kc9kql0qmgCPnKlMg8DY3isNBNkK SlNOzQLaRpJ86IsO1UBnOWnjO/YtBbc= X-Received: by 10.200.24.184 with SMTP id s53mr12217280qtj.48.1509745265079; Fri, 03 Nov 2017 14:41:05 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 6/6] Cleanup sigpause implementation Date: Fri, 3 Nov 2017 19:40:49 -0200 Message-Id: <1509745249-11404-6-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509745249-11404-1-git-send-email-adhemerval.zanella@linaro.org> This patch simplify sigpause by remobing the single thread optimization since it will be handled already by the __sigsuspend call. Checked on x86_64-linux-gnu. * sysdeps/posix/sigpause.c (do_sigpause): Remove. (__sigpause): Rely on __sigsuspend to implement single thread optimization. Signed-off-by: Adhemerval Zanella --- ChangeLog | 4 ++++ sysdeps/posix/sigpause.c | 25 +++++-------------------- 2 files changed, 9 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/sysdeps/posix/sigpause.c b/sysdeps/posix/sigpause.c index 9038ed3..706195c 100644 --- a/sysdeps/posix/sigpause.c +++ b/sysdeps/posix/sigpause.c @@ -19,15 +19,13 @@ #include #include #include /* For NULL. */ -#include #undef sigpause #include +#include -/* Set the mask of blocked signals to MASK, - wait for a signal to arrive, and then restore the mask. */ -static int -do_sigpause (int sig_or_mask, int is_sig) +int +__sigpause (int sig_or_mask, int is_sig) { sigset_t set; @@ -46,21 +44,6 @@ do_sigpause (int sig_or_mask, int is_sig) to do anything here. */ return __sigsuspend (&set); } - -int -__sigpause (int sig_or_mask, int is_sig) -{ - if (SINGLE_THREAD_P) - return do_sigpause (sig_or_mask, is_sig); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = do_sigpause (sig_or_mask, is_sig); - - LIBC_CANCEL_RESET (oldtype); - - return result; -} libc_hidden_def (__sigpause) /* We have to provide a default version of this function since the @@ -87,3 +70,5 @@ __xpg_sigpause (int sig) return __sigpause (sig, 1); } strong_alias (__xpg_sigpause, __libc___xpg_sigpause) + +LIBC_CANCEL_HANDLED ();