git.iko.soy/typeable/nixpkgs
on master help sign in
ntpd: Allow additional syscalls in seccomp filter.

Fixes issue #21136. The problem is that the seccomp system call filter configured by ntpd did not include some system calls that were apparently needed. For example the program hanged in getpid just after the filter was installed: 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=41, filter=0x5620d7f0bd90}) = 0 getpid() = ? I do not know exactly why this is a problem on NixOS only, perhaps we have getpid caching disabled. The fcntl and setsockopt system calls also had to be added.

commit35e0eea053d81f7aa933cd2747f43d3b4524c326 authorAmbroz Bizjak <ambrop7@gmail.com> dateSun 2 Apr 2017, 20:29 (10 years ago) parenta775713
2 files changed+48
pkgs/tools/networking/ntp/default.nix+4 pkgs/tools/networking/ntp/seccomp.patch+44
pkgs/tools/networking/ntp/default.nix+4
@@ -15,6 +15,10 @@ stdenv.mkDerivation rec {
1515 sha256 = "0whbyf82lrczbri4adbsa4hg1ppfa6c7qcj7nhjwdfp1g1vjh95p";
1616 };
1717
18+ # The hardcoded list of allowed system calls for seccomp is
19+ # insufficient for NixOS, add more to make it work (issue #21136).
20+ patches = [ ./seccomp.patch ];
21+
1822 configureFlags = [
1923 "--sysconfdir=/etc"
2024 "--localstatedir=/var"
pkgs/tools/networking/ntp/seccomp.patchnew file+44
@@ -0,0 +1,44 @@
1+diff -urN ntp-4.2.8p10.orig/ntpd/ntpd.c ntp-4.2.8p10/ntpd/ntpd.c
2+--- ntp-4.2.8p10.orig/ntpd/ntpd.c 2017-04-02 20:21:17.371319663 +0200
3++++ ntp-4.2.8p10/ntpd/ntpd.c 2017-04-02 21:26:02.766178723 +0200
4+@@ -1157,10 +1157,12 @@
5+ SCMP_SYS(close),
6+ SCMP_SYS(connect),
7+ SCMP_SYS(exit_group),
8++ SCMP_SYS(fcntl),
9+ SCMP_SYS(fstat),
10+ SCMP_SYS(fsync),
11+ SCMP_SYS(futex),
12+ SCMP_SYS(getitimer),
13++ SCMP_SYS(getpid),
14+ SCMP_SYS(getsockname),
15+ SCMP_SYS(ioctl),
16+ SCMP_SYS(lseek),
17+@@ -1179,6 +1181,7 @@
18+ SCMP_SYS(sendto),
19+ SCMP_SYS(setitimer),
20+ SCMP_SYS(setsid),
21++ SCMP_SYS(setsockopt),
22+ SCMP_SYS(socket),
23+ SCMP_SYS(stat),
24+ SCMP_SYS(time),
25+@@ -1195,9 +1198,11 @@
26+ SCMP_SYS(clock_settime),
27+ SCMP_SYS(close),
28+ SCMP_SYS(exit_group),
29++ SCMP_SYS(fcntl),
30+ SCMP_SYS(fsync),
31+ SCMP_SYS(futex),
32+ SCMP_SYS(getitimer),
33++ SCMP_SYS(getpid),
34+ SCMP_SYS(madvise),
35+ SCMP_SYS(mmap),
36+ SCMP_SYS(mmap2),
37+@@ -1211,6 +1216,7 @@
38+ SCMP_SYS(select),
39+ SCMP_SYS(setitimer),
40+ SCMP_SYS(setsid),
41++ SCMP_SYS(setsockopt),
42+ SCMP_SYS(sigprocmask),
43+ SCMP_SYS(sigreturn),
44+ SCMP_SYS(socketcall),