git: 95030a914349 - stable/15 - bhyve/slirp: Drop privileges before entering capability mode
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 25 Jun 2026 17:24:52 UTC
The branch stable/15 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=95030a9143491eb237627b1d7d9b7e8c0661cbea
commit 95030a9143491eb237627b1d7d9b7e8c0661cbea
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-11-24 14:15:27 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-06-25 15:33:22 +0000
bhyve/slirp: Drop privileges before entering capability mode
When in restricted mode, the slirp-helper process enters a capsicum
sandbox, after which we cannot look up the uid for the "nobody" user.
Reverse the order.
Reported by: kp
Fixes: 0e62ebd20172 ("bhyve: Move the slirp backend out into a separate process")
(cherry picked from commit b0c7eaf83d21bbc333e247ab9e136965b3ca54ed)
---
usr.sbin/bhyve/slirp/slirp-helper.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/usr.sbin/bhyve/slirp/slirp-helper.c b/usr.sbin/bhyve/slirp/slirp-helper.c
index 5ad941524e19..ec0f8a3486e0 100644
--- a/usr.sbin/bhyve/slirp/slirp-helper.c
+++ b/usr.sbin/bhyve/slirp/slirp-helper.c
@@ -553,6 +553,11 @@ main(int argc, char **argv)
priv.slirp = slirp;
+ /*
+ * Drop root privileges if we have them.
+ */
+ drop_privs();
+
/*
* In restricted mode, we can enter a Capsicum sandbox without losing
* functionality.
@@ -560,11 +565,6 @@ main(int argc, char **argv)
if (restricted && caph_enter() != 0)
err(1, "caph_enter");
- /*
- * Drop root privileges if we have them.
- */
- drop_privs();
-
/*
* Enter our main loop. If bhyve goes away, we should observe a hangup
* on the socket and exit.