summaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
authorReepca Russelstein <reepca@russelstein.xyz>2025-06-27 00:49:52 -0500
committerLudovic Courtès <ludo@gnu.org>2025-06-30 19:36:41 +0200
commitb79100ef61bf032528939367883f29137ba103b7 (patch)
tree7fd9fd9efd9c11746677b69a37bc3de2a43748f6 /nix
parent25522dab1336bc943a46b0e98821a34f5c104ad4 (diff)
daemon: Conditionally disable seccomp filter on ‘socketcall’ systems.
glibc currently will insist on using 'socketcall' on i686-linux unless built with '--enable-kernel=4.3.0' or above, even on systems that have dedicated system calls available for all the socket-related functionality. This behavior breaks the assumption that socketcall can be safely blocked without impacting functionality in slirp4netns, rendering the seccomp filter unusable with those glibcs. This change makes the slirp4netns seccomp filter opt-in on systems with a 'socketcall' system call. It can either be opted-into at compile-time or at runtime using the NO_SOCKETCALL_LIBC preprocessor define or the GUIX_FORCE_SECCOMP environment variable, respectively. The seccomp filter being disabled on these systems means that it is possible for a compromised slirp4netns to access abstract unix domain sockets in the root network namespace. It does not affect any of the other mechanisms used to isolate slirp4netns (e.g. chroot, namespaces, etc). Fixes guix/guix#808. * nix/libstore/build.cc (spawnSlirp4netns) [__NR_socketcall]: Do not add seccomp filter, unless ‘GUIX_FORCE_SECCOMP’ is set. Change-Id: Ibfe8becc9431f5aff11a21f06858b20496f9cb4a Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'nix')
-rw-r--r--nix/libstore/build.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index eee3a33a58d..e77869fc3e4 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -2219,8 +2219,24 @@ static pid_t spawnSlirp4netns(int tapfd, int notifyReadyFD,
2219 slirpCtx.supplementaryGroups = {}; 2219 slirpCtx.supplementaryGroups = {};
2220 slirpCtx.setSupplementaryGroups = true; 2220 slirpCtx.setSupplementaryGroups = true;
2221 } 2221 }
2222 slirpCtx.seccompFilter = slirpSeccompFilter(); 2222 /* Unless built with '--enable-kernel=4.3.0' or similar, glibc on i686
2223 slirpCtx.addSeccompFilter = true; 2223 uses 'socketcall' instead of dedicated system calls like 'socket' and
2224 'bind'. Since the seccomp filter cannot inspect 'socketcall' arguments
2225 in a meaningful way, it can only prohibit all 'socketcall' calls; the
2226 other option is to disable the seccomp filter entirely, meaning that
2227 slirp4netns would have access to abstract unix sockets in the root
2228 network namespace. */
2229#ifdef __NR_socketcall
2230#ifndef NO_SOCKETCALL_LIBC
2231 if(getenv("GUIX_FORCE_SECCOMP") == NULL)
2232 printMsg(lvlInfo, "warning: seccomp filter for slirp4netns presumed unusable with this libc, disabling it");
2233 else
2234#endif
2235#endif
2236 {
2237 slirpCtx.seccompFilter = slirpSeccompFilter();
2238 slirpCtx.addSeccompFilter = true;
2239 }
2224 2240
2225 /* Silence slirp4netns output unless requested */ 2241 /* Silence slirp4netns output unless requested */
2226 if(verbosity <= lvlInfo) { 2242 if(verbosity <= lvlInfo) {