FS#55987 - [bind] glibc-2.26 breaks bind

Attached to Project: Arch Linux
Opened by Daniel Schregenberger (SuperBFG7) - Saturday, 14 October 2017, 11:51 GMT
Last edited by Sébastien Luttringer (seblu) - Sunday, 10 December 2017, 16:09 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Sébastien Luttringer (seblu)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
When running bind as user named (as in the standard systemd.service file) the process will go defunct immediately after the start.
No output to console, no debug logs, no entries in journal.

Running as root (no user change) works fine.

Downgrade to glibc-2.25-7 fixes this issue for me.
I suspect bind needs to be re-built as well when glibc changes.

Additional info:
* bind-9.11.2-2
* glibc-2.26-3 / glibc-2.26-4 / glibc-2.26-5

Steps to reproduce:
# /usr/sbin/named -f -u named -L /dev/stdout

Running as root works:
# /usr/sbin/named -f -L /dev/stdout
This task depends upon

Closed by  Sébastien Luttringer (seblu)
Sunday, 10 December 2017, 16:09 GMT
Reason for closing:  Fixed
Comment by loqs (loqs) - Saturday, 14 October 2017, 14:51 GMT
Can you attach an strace of both the running and failing commands please.
Comment by Daniel Schregenberger (SuperBFG7) - Saturday, 14 October 2017, 15:25 GMT
Sure, attached. And below the exact commandline I used to generate them.
Note that both of them were taken inside a docker container.

# strace -o running.strace /usr/sbin/named -f -u named -L named.log
# strace -o failing.strace /usr/sbin/named -f -u named -L named.log

It looks as if the failing one fails on opening the log file.
Comment by loqs (loqs) - Saturday, 14 October 2017, 16:13 GMT
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) = 0
seccomp(SECCOMP_SET_MODE_STRICT, 1, NULL) = -1 EINVAL (Invalid argument)
seccomp(SECCOMP_SET_MODE_FILTER, 0, {len=38, filter=0x5576afc1f2b0}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=127, ...}) = 0
stat("named.log", 0x7ffd578da800) = -1 EACCES (Permission denied)
openat(AT_FDCWD, "named.log", O_WRONLY|O_CREAT|O_APPEND, 0666) = ?
+++ killed by SIGKILL +++
Setup the secccomp filtering then seccomp kills because of openat?
Edit:
But unless the platform is i686 it seems openat should be allowed https://source.isc.org/cgi-bin/gitweb.cgi?p=bind9.git;a=blob;f=bin/named/include/named/seccomp.h;h=2e7f6b41a179ca4ad37070861c75d671184ea58b;hb=HEAD
Comment by Daniel Schregenberger (SuperBFG7) - Saturday, 14 October 2017, 16:24 GMT
Sorry, the kill was by me (kill -9).
Ctrl-C does not work and the process does not react in any way, so I killed it.
ps shows the process as <defunct>

# ps faux
root 18157 0.0 0.0 20532 3484 pts/0 Ss 17:07 0:00 | \_ /bin/bash
root 18798 0.0 0.0 18316 1848 pts/0 S+ 17:23 0:00 | \_ strace -o failing.strace /usr/sbin/named -f -u named -L named.log
named 18800 0.0 0.0 0 0 pts/0 Zl+ 17:23 0:00 | \_ [named] <defunct>

And the permission denied also happens for /dev/stdout (that's the only entry in the journal when starting named):
named[19047]: isc_log_open '/dev/stdout' failed: permission denied
Comment by loqs (loqs) - Saturday, 14 October 2017, 21:06 GMT
switching seccomp to SCMP_ACT_TRAP
--- SIGSYS {si_signo=SIGSYS, si_code=SYS_SECCOMP, si_call_addr=0x7f8350da2610, si_syscall=__NR_openat, si_arch=AUDIT_ARCH_X86_64} ---
Not sure which of https://sourceware.org/git/?p=glibc.git&a=search&h=1c9a5c270d8b66f30dcfaf1cb2d6cf39d3e18369&st=commit&s=openat was the trigger
Comment by Sébastien Luttringer (seblu) - Saturday, 14 October 2017, 21:18 GMT
My servers currently run bind 9.11.2-2 and glibc 2.26-5 with user named and so far everything works.

Did you rebuild bind with the new glibc to check your suspicion?
Comment by loqs (loqs) - Saturday, 14 October 2017, 21:41 GMT
Yes in order to switch seccomp to SCMP_ACT_TRAP at https://source.isc.org/cgi-bin/gitweb.cgi?p=bind9.git;a=blob;f=bin/named/main.c;h=4fb056636dd29c3ccf021ddb272b1e916baaace9;hb=HEAD#l922
Rebuilding with seccomp disabled named seems to start correctly system is not configured for named but no zombie process is created named can be terminated without resorting to SIGKILL.
named from 9.11.2-2 matches the failing.strace from SuperBFG7 with the exception named.log is replaced by /dev/stdout.
My local build could well be suspect can not explain why your system is not seeing the issue when running as root "/usr/sbin/named -f -u named -L /dev/stdout"
Edit:
If you mean just rebuild against glibc 2.26-5 without any other changes the result was the same as using named from 9.11.2-2
Edit2:
Moving SCMP_SYS(openat), from the https://source.isc.org/cgi-bin/gitweb.cgi?p=bind9.git;a=blob;f=bin/named/include/named/seccomp.h;h=2e7f6b41a179ca4ad37070861c75d671184ea58b;hb=HEAD#l86 to line 60
and "openat", fromhttps://source.isc.org/cgi-bin/gitweb.cgi?p=bind9.git;a=blob;f=bin/named/include/named/seccomp.h;h=2e7f6b41a179ca4ad37070861c75d671184ea58b;hb=HEAD#l153 to line 127
so that they are outside of #ifndef ISC_PLATFORM_USETHREADS meaning it will be used on threaded builds which is what the strace seems to show is required.
named as built with the above modification no longer results in a zombie process requiring SIGKILL.
Comment by Daniel Schregenberger (SuperBFG7) - Sunday, 15 October 2017, 17:15 GMT
@seblu: You are right: simply rebuilding bind against glibc-2.26-5 does not resolve this.
@loqs: With "running as root" I meant without the option "-u named", still works for me. But for security reasons I'd rather not do that.
Comment by loqs (loqs) - Sunday, 15 October 2017, 17:27 GMT
@SuperBFG7 and if you disable seccomp or make the adjustment I noted to bin/named/include/named/seccomp.h ?
@seblu https://phabricator.kde.org/D7806 indicates another project having to add support for openat attributed to glibc 2.26
Looking at other linux distributions that package named I could not trivially find another that is on glibc 2.26 and builds named with seccomp support for comparison.
Comment by loqs (loqs) - Sunday, 15 October 2017, 18:00 GMT
example patch that moves the openat syscall out of #ifndef ISC_PLATFORM_USETHREADS on x86_64
Comment by Daniel Schregenberger (SuperBFG7) - Monday, 16 October 2017, 18:21 GMT
I can confirm that the patch works and named does not go defunct anymore. Thank you!
Strange is however, that no output is generated to stdout (no idea why) while writting output to a file works as expected (with correct permissions of course).

Loading...