Thorsten Glaser
2021-May-03 21:05 UTC
[klibc] Debian #988027: sigsetjmp ignores second argument, siglongjmp always restores signals
As indicated below, I can provide a fix for this (but it should be easy enough); also for the s390x setjmp/longjmp bug #943425 once the porters clarify the ABI (i.e. which registers to save), if needed. ---------- Forwarded message ---------- Message-ID: <162007527823.6523.7891920735984618909.reportbug at zelenka.debian.org> Subject: Bug#988027: klibc: sigsetjmp ignores second argument, siglongjmp always restores signals Package: libklibc-dev Version: 2.0.8-6 Severity: serious Justification: spec violation, affecting release architectures X-Debbugs-Cc: tg at debian.org Found during debugging of #943425: - usr/include/setjmp.h struct __sigjmp_buf { jmp_buf __jmpbuf; sigset_t __sigs; }; => does not contain information whether __sigs was saved #define sigsetjmp(__env, __save) \ ({ \ struct __sigjmp_buf *__e = (__env); \ sigprocmask(0, NULL, &__e->__sigs); \ setjmp(__e->__jmpbuf); \ }) => ignores the __save argument - usr/klibc/siglongjmp.c __noreturn siglongjmp(sigjmp_buf buf, int retval) { sigprocmask(SIG_SETMASK, &buf->__sigs, NULL); longjmp(buf->__jmpbuf, retval); => always restores __sigs This is in direct violation to the Debian sigsetjmp(3) docs... If, and only if, the savesigs argument provided to sigsetjmp() is non- zero, the process's current signal mask is saved in env and will be re- stored if a siglongjmp() is later performed with this env. ... and POSIX: * The siglongjmp() function shall restore the saved signal mask if and only if the env argument was initialized by a call to [9]sigsetjmp() with a non-zero savemask argument. Q: https://pubs.opengroup.org/onlinepubs/9699919799/functions/siglongjmp.html If necessary I can provide a patch to fix this. -- System Information: Debian Release: 11.0 APT prefers unstable-debug APT policy: (500, 'unstable-debug'), (500, 'unstable') Architecture: s390x Kernel: Linux 4.19.0-16-s390x (SMP w/2 CPU threads) Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: unable to detect Versions of packages libklibc-dev depends on: ii libklibc 2.0.8-6 ii linux-libc-dev 5.10.28-1 libklibc-dev recommends no packages. libklibc-dev suggests no packages. -- no debconf information