glibc/signal
Adhemerval Zanella d2dc5467c6 Filter out NPTL internal signals (BZ #22391)
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 __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 __clear_internal_signals and __is_internal_signal
    version since both symbols are used on generic implementations.

  - Remove superflous sysdeps/nptl/sigfillset.c.

  - Remove superflous SIGTIMER handling on Linux __is_internal_signal
    since it is the same of SIGCANCEL.

  - Remove dangling define and obvious comment on nptl/sigaction.c.

Checked on x86_64-linux-gnu.

	[BZ #22391]
	* nptl/sigaction.c (__sigaction): Use __is_internal_signal to
	check for internal nptl signals.
	* nptl/sigaction.c (__sigaction): Likewise.
	* 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 __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/generic/internal-signals.h (__clear_internal_signals,
	__is_internal_signal, __libc_signal_block_all,
	__libc_signal_block_app, __libc_signal_restore_set): New functions.
	* sysdeps/nptl/sigfillset.c: Remove file.
	* sysdeps/unix/sysv/linux/internal-signals.h (__is_internal_signal):
	Change return to bool.
	(__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.

Reported-by: Yury Norov <ynorov@caviumnetworks.com>
2018-04-03 13:30:49 -03:00
..
bits/types Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sys initial import 1995-02-18 01:27:10 +00:00
Makefile Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
Versions Remove __need macros from signal.h. 2017-05-20 19:04:43 -04:00
allocrtsig.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
kill.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
killpg.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
raise.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigaction.c Filter out NPTL internal signals (BZ #22391) 2018-04-03 13:30:49 -03:00
sigaddset.c Filter out NPTL internal signals (BZ #22391) 2018-04-03 13:30:49 -03:00
sigaltstack.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigandset.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigblock.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigdelset.c Filter out NPTL internal signals (BZ #22391) 2018-04-03 13:30:49 -03:00
sigempty.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigfillset.c Filter out NPTL internal signals (BZ #22391) 2018-04-03 13:30:49 -03:00
siggetmask.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sighold.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigignore.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigintr.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigisempty.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigismem.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
signal.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
signal.h Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigorset.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigpause.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigpending.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigprocmask.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigqueue.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigrelse.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigreturn.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigset.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigsetmask.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigsetops.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigstack.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigsuspend.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigtimedwait.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigvec.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigwait.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sigwaitinfo.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
sysv_signal.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
tst-raise.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
tst-signal.c * malloc/memusagestat.c (main): Use return instead of exit to 2000-12-31 10:52:32 +00:00
tst-sigset.c Filter out NPTL internal signals (BZ #22391) 2018-04-03 13:30:49 -03:00
tst-sigset2.c [BZ #1951] 2006-04-23 19:05:33 +00:00
tst-sigsimple.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00
tst-sigwait-eintr.c Update copyright dates with scripts/update-copyrights. 2018-01-01 00:32:25 +00:00