[Pkg-dns-devel] Bug#881462: knot-resolver: kresd in tight on SIGPIPE when offering TLS or TCP

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sun Nov 12 03:59:03 UTC 2017


Package: knot-resolver
Version: 1.3.3-1
Severity: normal
Tags: patch upstream
Control: forwarded -1 https://gitlab.labs.nic.cz/knot/knot-resolver/issues/271

I'm running kresd 1.3.3,  I found it was stuck in a tight loop.  here's the output of strace:

```
write(20, "\27\3\3\1\356\0\0\0\0\0\0\0\2H\364\352e\235\t\274\237YF\244\260\250K\223q\211EW"..., 499) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=24582, si_uid=110} ---
write(20, "\27\3\3\1\356\0\0\0\0\0\0\0\2H\364\352e\235\t\274\237YF\244\260\250K\223q\211EW"..., 499) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=24582, si_uid=110} ---
```

looking at the open file descriptors with `lsof`, i see:

```
kresd   24582 knot-resolver   18ur     REG               0,35      8192   12524 /var/cache/knot-resolver/lock.mdb
kresd   24582 knot-resolver   19u      REG               0,35 104857600   12525 /var/cache/knot-resolver/data.mdb
kresd   24582 knot-resolver   20u     sock                0,8       0t0 4310946 protocol: TCPv6
```

If i kill and restart the daemon, it will likely work fine again.


I mentioned this upstream at
https://gitlab.labs.nic.cz/knot/knot-resolver/issues/271, and upstream
suggested the attached patch as a fix.

          --dkg


-- System Information:
Debian Release: buster/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'testing'), (500, 'oldstable'), (200, 'unstable-debug'), (200, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.13.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages knot-resolver depends on:
ii  adduser            3.116
ii  dns-root-data      2017072601
ii  libbsd0            0.8.6-3
ii  libc6              2.24-17
ii  libdnssec4         2.6.0-1
ii  libedit2           3.1-20170329-1
ii  libgnutls30        3.5.16-1
ii  libhiredis0.13     0.13.3-2
ii  libknot6           2.6.0-1
ii  liblmdb0           0.9.21-1
ii  libluajit-5.1-2    2.1.0~beta3+dfsg-5.1
ii  libmemcached11     1.0.18-4.2
ii  libmemcachedutil2  1.0.18-4.2
ii  libncurses5        6.0+20170902-1
ii  libnettle6         3.3-2
ii  libsystemd0        235-2
ii  libtinfo5          6.0+20170902-1
ii  libuv1             1.9.1-3
ii  libzscanner1       2.6.0-1
ii  lua-sec            0.6-3
ii  lua-socket         3.0~rc1+git+ac3201d-3

Versions of packages knot-resolver recommends:
pn  knot-resolver-module-http  <none>

knot-resolver suggests no packages.

-- no debconf information
-------------- next part --------------
Vladim?r ?un?t commented:

It's been squashed unfortunately.  Let me cut it out:
```diff
diff --git a/daemon/main.c b/daemon/main.c
index 56c2e85a..518a6c2b 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -17,6 +17,7 @@
 #include <arpa/inet.h>
 #include <stdlib.h>
 #include <string.h>
+#include <signal.h>
 #include <getopt.h>
 #include <libgen.h>
 #include <uv.h>
@@ -640,6 +641,14 @@ int main(int argc, char **argv)
 		}
 	}
 
+	/* Workaround for https://github.com/libuv/libuv/issues/45
+	 * (Write after ECONNRESET crash.) */
+	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
+		kr_log_error("[system] can't block SIGPIPE signal: %s\n",
+			     strerror(errno));
+		ret = EXIT_FAILURE;
+	}
+
 	if (ret != 0) {
 		goto cleanup;
 	}
```

---
View it on GitLab: https://gitlab.labs.nic.cz/knot/knot-resolver/issues/271#note_60621
You're receiving this email because of your account on gitlab.labs.nic.cz.


More information about the pkg-dns-devel mailing list