Package: dbus Version: 1.10.8-1 While investigating #823460 "lightdm: SIGPIPE ignored in session" in developed a libc patch which logs a message whenever any new program starts up an with unusual setup for SIGPIPE.
The logfile contains entries like this: 2016-04-08 12:15:12 UTC:/sbin/wpa_supplicant[3350] execd oddly (parent /usr/bin/dbus-daemon[3349]): Broken pipe: SIG_IGN It is a bug to execute a program with SIGPIPE ignored without its consent. (Or to put it another way, it is not part of the specification of programs in general, on a unix system, that they will function correctly if run with anomalous signal configuration.) In this case I see quite a few programs in the log being executed with SIGPIPE set to SIG_IGN. For many of thexe programs I don't really know whether the consent. But I think I know that wpa_supplicant doesn't; and I doubt that nm-dispatcher or the various systemd-* programs document that this is permitted or expected. In practice the fallout from this bug is likely to be modest because many of these programs are daemons of one kind or another anyway, and few of them tend to do their work with a lot of pipes etc. But one possible consequence is that daemons or other long-lived service processes might fail to terminate when their socket peer goes away, and instead might end up spinning on the cpu. I will attach the glibc patch I used, and an extract from the log it wrote. Ian. -- System Information: Debian Release: stretch/sid APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.5.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.utf-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) Versions of packages dbus depends on: ii adduser 3.114 ii init-system-helpers 1.29 ii libapparmor1 2.10-4 ii libaudit1 1:2.4.5-1+b1 ii libc6 2.22-7 ii libcap-ng0 0.7.7-1+b1 ii libdbus-1-3 1.10.8-1 ii libexpat1 2.1.1-1 ii libselinux1 2.5-1 ii libsystemd0 229-5 ii lsb-base 9.20160110 dbus recommends no packages. Versions of packages dbus suggests: ii dbus-x11 1.10.8-1 Versions of packages dbus is related to: ii dbus-x11 1.10.8-1 ii systemd 229-5 pn systemd-sysv <none> -- no debconf information
diff --git a/csu/init-first.c b/csu/init-first.c index b3bacdd..751fc5a 100644 --- a/csu/init-first.c +++ b/csu/init-first.c @@ -39,6 +39,92 @@ int __libc_argc attribute_hidden; char **__libc_argv attribute_hidden; +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <time.h> + +static void +__libc_check_sigpipe (const char *argv0) +{ + static const int sigs[] = { SIGPIPE, SIGTERM, SIGALRM, 9 }; + const int *sigp; + int sig; + struct sigaction sa; + sigset_t mask; + int r; + const char *oddity; + + sig = 0; + r = sigprocmask(SIG_UNBLOCK, 0, &mask); + if (r) { oddity = strerror(errno); goto bad; } + + for (sigp = sigs; (sig = *sigp); sigp++) { + r = sigaction(SIGPIPE, 0, &sa); + if (r) { oddity = strerror(errno); goto bad; } + if (sa.sa_handler == SIG_IGN) { oddity = "SIG_IGN"; goto bad; } + if (sigismember(&mask, sig)) { oddity = "blocked"; goto bad; } + } + return; + + bad:; + int logfd = -1; + FILE *logf = 0; + + logfd = open("/var/log/exec-sigignblock.log", O_APPEND|O_WRONLY); + if (logfd < 0) + if (errno == ENOENT || errno == EACCES || errno == EPERM) + return; + + logf = fdopen(logfd, "a"); + if (!logf) goto fail; + logfd = -1; /* eaten by fdopen */ + + unsigned long ourpid = getpid(); + unsigned long ppid = getppid(); + char parentbuf[100]; + + snprintf(parentbuf, sizeof(parentbuf), "/proc/%lu/exe", ppid); + r = readlink(parentbuf, parentbuf, sizeof(parentbuf)-1); + if (r < 0) { + const char *m = strerror(errno); + strncpy(parentbuf, m, sizeof(parentbuf)-1); + parentbuf[sizeof(parentbuf)-1] = 0; + } else if (r == 0) { + strcpy(parentbuf, "\"\""); + } else { + parentbuf[r] = 0; + } + + time_t now; + now = time(NULL); + if (now == (time_t)-1) { errno = EIO; goto fail; } + + struct tm *gmt = gmtime(&now); + if (!gmt) goto fail; + + r = fprintf(logf, "%04d-%02d-%02d %02d:%02d:%02d UTC:" + "%s[%lu] execd oddly (parent %s[%lu]): %s: %s\n", + gmt->tm_year+1900, gmt->tm_mon, gmt->tm_mday, + gmt->tm_hour, gmt->tm_min, gmt->tm_sec, + argv0, ourpid, + parentbuf, ppid, + sig ? strsignal(sig) : "sigprocmask", oddity); + if (r < 0) goto fail; + + r = fclose(logf); + logf = 0; + if (r) goto fail; + + return; + + fail: + perror("__libc_check_sigpipe report oddity"); + if (logf) fclose(logf); + if (logfd>=0) close(logfd); + return; +} + void __libc_init_first (int argc, char **argv, char **envp) { @@ -96,6 +182,8 @@ _init (int argc, char **argv, char **envp) #if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS __libc_global_ctors (); #endif + + __libc_check_sigpipe (argv[0]); } /* This function is defined here so that if this file ever gets into diff --git a/debian/changelog b/debian/changelog index f552f26..33a6254 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +glibc (2.22-7+iwj) UNRELEASED; urgency=medium + + * SIGPIPE tracking + + -- Ian Jackson <ijack...@chiark.greenend.org.uk> Sun, 08 May 2016 12:43:46 +0100 + glibc (2.22-7) unstable; urgency=medium [ Samuel Thibault ] diff --git a/debian/shlibs-add-udebs b/debian/shlibs-add-udebs old mode 100644 new mode 100755
2016-04-08 12:13:21 UTC:/usr/lib/dbus-1.0/dbus-daemon-launch-helper[12813] execd oddly (parent /usr/bin/dbus-daemon[12790]): Broken pipe: SIG_IGN 2016-04-08 12:13:21 UTC:/usr/lib/x86_64-linux-gnu/systemd-shim[12813] execd oddly (parent /usr/bin/dbus-daemon[12790]): Broken pipe: SIG_IGN 2016-04-08 12:13:21 UTC:/usr/lib/dbus-1.0/dbus-daemon-launch-helper[12911] execd oddly (parent /usr/bin/dbus-daemon[12905]): Broken pipe: SIG_IGN 2016-04-08 12:13:21 UTC:/usr/lib/NetworkManager/nm-dispatcher[12911] execd oddly (parent /usr/bin/dbus-daemon[12905]): Broken pipe: SIG_IGN 2016-04-08 12:13:24 UTC:/run/cgmanager/agents/cgm-release-agent.systemd[13682] execd oddly (parent No such file or directory[2]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/dbus-1.0/dbus-daemon-launch-helper[2826] execd oddly (parent /usr/bin/dbus-daemon[2824]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/lib/systemd/systemd-hostnamed[2826] execd oddly (parent /usr/bin/dbus-daemon[2824]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/dbus-1.0/dbus-daemon-launch-helper[2915] execd oddly (parent /usr/bin/dbus-daemon[2913]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/NetworkManager/nm-dispatcher[2915] execd oddly (parent /usr/bin/dbus-daemon[2913]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:(pinger)[3213] execd oddly (parent /usr/sbin/squid[3079]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/sbin/exim4[3250] execd oddly (parent /usr/sbin/exim4[3248]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/dbus-1.0/dbus-daemon-launch-helper[3312] execd oddly (parent /usr/bin/dbus-daemon[3311]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/bin/sh[3312] execd oddly (parent /usr/bin/dbus-daemon[3311]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:mkdir[3317] execd oddly (parent /bin/dash[3312]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/lib/systemd/systemd-logind[3312] execd oddly (parent /usr/bin/dbus-daemon[3311]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/dbus-1.0/dbus-daemon-launch-helper[3327] execd oddly (parent /usr/bin/dbus-daemon[3326]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/x86_64-linux-gnu/systemd-shim[3327] execd oddly (parent /usr/bin/dbus-daemon[3326]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/bin/sh[3344] execd oddly (parent /usr/sbin/lightdm[3294]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/xorg/Xorg[3344] execd oddly (parent /usr/sbin/lightdm[3294]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/dbus-1.0/dbus-daemon-launch-helper[3348] execd oddly (parent /usr/bin/dbus-daemon[3347]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/dbus-1.0/dbus-daemon-launch-helper[3350] execd oddly (parent /usr/bin/dbus-daemon[3349]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/lib/policykit-1/polkitd[3348] execd oddly (parent /usr/bin/dbus-daemon[3347]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/sbin/wpa_supplicant[3350] execd oddly (parent /usr/bin/dbus-daemon[3349]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:sh[3471] execd oddly (parent /usr/lib/xorg/Xorg[3344]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/bin/xkbcomp[3473] execd oddly (parent /bin/dash[3471]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:sh[3530] execd oddly (parent /usr/lib/xorg/Xorg[3344]): Broken pipe: SIG_IGN 2016-04-08 12:15:12 UTC:/usr/bin/xkbcomp[3531] execd oddly (parent /bin/dash[3530]): Broken pipe: SIG_IGN 2016-04-08 12:15:13 UTC:lightdm[3713] execd oddly (parent /usr/sbin/lightdm[3294]): Broken pipe: SIG_IGN 2016-04-08 12:15:15 UTC:/usr/lib/NetworkManager/nm-dhcp-helper[3976] execd oddly (parent /sbin/dhclient[3952]): Broken pipe: SIG_IGN 2016-04-08 12:15:15 UTC:/usr/lib/NetworkManager/nm-dhcp-helper[4026] execd oddly (parent /sbin/dhclient[3952]): Broken pipe: SIG_IGN 2016-04-08 12:15:16 UTC:lightdm[4148] execd oddly (parent /usr/sbin/lightdm[3294]): Broken pipe: SIG_IGN 2016-04-08 12:15:20 UTC:lightdm[4155] execd oddly (parent /usr/sbin/lightdm[3294]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/gnome-keyring-daemon[4160] execd oddly (parent Permission denied[4155]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/bin/sh[4164] execd oddly (parent Permission denied[4155]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:touch[4165] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:chmod[4166] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:date[4167] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:tempfile[4168] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:rm[4169] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:run-parts[4170] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:cat[4171] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:run-parts[4172] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:xrdb[4173] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:sh[4174] execd oddly (parent /usr/bin/xrdb[4173]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/cpp[4175] execd oddly (parent /bin/dash[4174]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/lib/gcc/x86_64-linux-gnu/5/cc1[4176] execd oddly (parent /usr/bin/cpp-5[4175]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:id[4177] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:xhost[4178] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:basename[4180] execd oddly (parent /bin/dash[4179]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:cut[4181] execd oddly (parent /bin/dash[4179]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/xdg-user-dirs-update[4183] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/dbus-launch[4184] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/xbrlapi[4182] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/dbus-daemon[4186] execd oddly (parent /usr/bin/dbus-launch[4185]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/unclutter[4189] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:dbus-update-activation-environment[4190] execd oddly (parent /bin/dash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/ssh-agent[4164] execd oddly (parent Permission denied[4155]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/bin/bash[4164] execd oddly (parent Permission denied[4155]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:hostname[4193] execd oddly (parent /bin/bash[4192]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:rm[4194] execd oddly (parent /bin/bash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/bin/sh[4195] execd oddly (parent /bin/bash[4164]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:hostname[4196] execd oddly (parent /bin/dash[4195]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:cat[4197] execd oddly (parent /bin/dash[4195]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:/usr/bin/perl[4198] execd oddly (parent /bin/dash[4195]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:tee[4199] execd oddly (parent /bin/dash[4195]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:xauth[4200] execd oddly (parent /usr/bin/perl[4198]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:xdpyinfo[4201] execd oddly (parent /usr/bin/perl[4198]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:uname[4202] execd oddly (parent /usr/bin/perl[4198]): Broken pipe: SIG_IGN 2016-04-08 12:15:22 UTC:rm[4203] execd oddly (parent /bin/dash[4195]): Broken pipe: SIG_IGN