aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorAditya Merchant <adityamerchant08@gmail.com>2026-12-04 13:01:19 +0530
committerStefano Brivio <sbrivio@redhat.com>2026-12-04 22:54:33 +0100
commit0ae06bb610806d3f7567da5c8115076b14b82ef5 (patch)
tree8dea82e0a05fa9a08e2b9987ffb010bffa7334f8
parent08e09ec2bc76e667559abef6e06a8e1429a615fb (diff)
downloadpasst-0ae06bb610806d3f7567da5c8115076b14b82ef5.tar
passt-0ae06bb610806d3f7567da5c8115076b14b82ef5.tar.gz
passt-0ae06bb610806d3f7567da5c8115076b14b82ef5.tar.bz2
passt-0ae06bb610806d3f7567da5c8115076b14b82ef5.tar.lz
passt-0ae06bb610806d3f7567da5c8115076b14b82ef5.tar.xz
passt-0ae06bb610806d3f7567da5c8115076b14b82ef5.tar.zst
passt-0ae06bb610806d3f7567da5c8115076b14b82ef5.zip
conf: Follow changes to the host nameserver in passt mode, too
We follow changes to the host's resolv.conf in pasta mode only, as passt doesn't allow openat() in its seccomp profile. But guests using --dns-forward are affected just like containers: once the host switches to another network, or connects to a VPN, their DNS queries keep going to a stale nameserver until passt restarts. Allow openat() for passt, too, and drop the check on the mode. We only use it to open resolv.conf through the read-only, detached copy of its directory: everything else conf_resolv_watch() needs happens before we apply seccomp filters, and, once we're sandboxed, there's nothing else we could open by path anyway. This brings passt to 35 allowed system calls on x86_64. Move the AppArmor rule for resolv.conf under /run from the pasta abstraction to the passt one, which pasta includes, and let passt watch the same directories as pasta with SELinux. Extend the dns_host_follow test to check that passt, without a guest, picks up a new nameserver and forgets a removed one. Suggested-by: Stefano Brivio <sbrivio@redhat.com> Link: https://archives.passt.top/passt-dev/20261130013444.57add0dc@elisabeth/ Link: https://archives.passt.top/passt-dev/20261130013439.0a40738a@elisabeth/ Signed-off-by: Aditya Merchant <adityamerchant08@gmail.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--README.md2
-rw-r--r--conf.c5
-rw-r--r--contrib/apparmor/abstractions/passt4
-rw-r--r--contrib/apparmor/abstractions/pasta4
-rw-r--r--contrib/selinux/passt.te4
-rw-r--r--passt.12
-rw-r--r--test/pasta_options/dns_host_follow13
7 files changed, 24 insertions, 10 deletions
diff --git a/README.md b/README.md
index 43caf49..2f865fc 100644
--- a/README.md
+++ b/README.md
@@ -291,7 +291,7 @@ speeding up local connections, and usually requiring NAT. _pasta_:
* ✅ all capabilities dropped, other than `CAP_NET_BIND_SERVICE` (if granted)
* ✅ with default options, user, mount, IPC, UTS, PID namespaces are detached
* ✅ no external dependencies (other than a standard C library)
-* ✅ restrictive seccomp profiles (34 syscalls allowed for _passt_, 43 for
+* ✅ restrictive seccomp profiles (35 syscalls allowed for _passt_, 43 for
_pasta_ on x86_64)
* ✅ examples of [AppArmor](/passt/tree/contrib/apparmor) and
[SELinux](/passt/tree/contrib/selinux) profiles available
diff --git a/conf.c b/conf.c
index 7a271ff..925b94d 100644
--- a/conf.c
+++ b/conf.c
@@ -322,7 +322,7 @@ out:
*
* Return: 0 on success, negative error code if the file can't be opened
*
- * #syscalls:pasta openat
+ * #syscalls openat
*/
static int conf_resolv_update(struct ctx *c)
{
@@ -413,9 +413,6 @@ void conf_resolv_watch(struct ctx *c)
char dir[PATH_MAX], *base;
int fd = -1, dir_fd, rc;
- if (c->mode != MODE_PASTA)
- return;
-
if (IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns_match))
c->ip4.dns_host_resolv = false;
if (IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns_match))
diff --git a/contrib/apparmor/abstractions/passt b/contrib/apparmor/abstractions/passt
index 0aeb19d..d4a65a0 100644
--- a/contrib/apparmor/abstractions/passt
+++ b/contrib/apparmor/abstractions/passt
@@ -17,6 +17,10 @@
include <abstractions/nameservice> # get_dns(), conf.c
+ # Host's resolv.conf in /run, read via a detached copy of its directory,
+ # with paths relative to /run: conf_resolv_watch(), conf_resolv_update()
+ /{NetworkManager,connman,netconfig,resolvconf,systemd/resolve}/resolv.conf r,
+
capability net_bind_service, # isolation.c, conf.c
capability setuid,
capability setgid,
diff --git a/contrib/apparmor/abstractions/pasta b/contrib/apparmor/abstractions/pasta
index 7ee892b..89fa427 100644
--- a/contrib/apparmor/abstractions/pasta
+++ b/contrib/apparmor/abstractions/pasta
@@ -29,10 +29,6 @@
@{run}/user/@{uid}/** rw, # pasta_open_ns()
- # Host's resolv.conf in /run, read via a detached copy of its directory,
- # with paths relative to /run: conf_resolv_watch(), conf_resolv_update()
- /{NetworkManager,connman,netconfig,resolvconf,systemd/resolve}/resolv.conf r,
-
@{PROC}/[0-9]*/ns/ r, # pasta_netns_quit_init(),
@{PROC}/[0-9]*/ns/net r, # pasta_wait_for_ns(),
@{PROC}/[0-9]*/ns/user r, # conf_pasta_ns()
diff --git a/contrib/selinux/passt.te b/contrib/selinux/passt.te
index e540473..f2628ec 100644
--- a/contrib/selinux/passt.te
+++ b/contrib/selinux/passt.te
@@ -131,6 +131,10 @@ corenet_tcp_sendrecv_all_ports(passt_t)
corenet_udp_sendrecv_all_ports(passt_t)
sysnet_read_config(passt_t)
+# Watch the directory holding resolv.conf for changes: conf_resolv_watch()
+files_watch_etc_dirs(passt_t)
+networkmanager_watch_pid_dirs(passt_t)
+systemd_resolved_watch_pid_dirs(passt_t)
allow passt_t node_t:icmp_socket { name_bind node_bind };
allow passt_t port_t:icmp_socket name_bind;
diff --git a/passt.1 b/passt.1
index c743889..bf7a95b 100644
--- a/passt.1
+++ b/passt.1
@@ -287,7 +287,7 @@ Configure the host nameserver which guest or namespace queries to the
\fB\-\-dns-forward\fR address will be redirected to. This option can
be specified zero to two times (once for IPv4, once for IPv6).
By default, the first nameserver from the host's
-\fI/etc/resolv.conf\fR. In pasta mode, on Linux 5.12 or later, this
+\fI/etc/resolv.conf\fR. On Linux 5.12 or later, this
default follows changes to that file: new DNS flows go to the first
nameserver listed for each IP version, while existing flows keep their
target until they expire.
diff --git a/test/pasta_options/dns_host_follow b/test/pasta_options/dns_host_follow
index d8cc232..fa8228f 100644
--- a/test/pasta_options/dns_host_follow
+++ b/test/pasta_options/dns_host_follow
@@ -30,5 +30,18 @@ passt echo "nameserver 2001:db8::1" > /etc/r && mv /etc/r /etc/resolv.conf
sleep 1
passt touch __DONE__ && wait
check grep -q "removed nameserver 192.0.2.2" __LOG_FILE__
+
+test Host nameserver follows changes to resolv.conf in passt mode
+set PASST_LOG __STATEDIR__/resolv_passt.log
+set PIDFILE __STATEDIR__/resolv_passt.pid
+passt echo "nameserver 192.0.2.1" > /etc/r && mv /etc/r /etc/resolv.conf
+passt ./passt -d -l __PASST_LOG__ -P __PIDFILE__ -s __STATEDIR__/resolv.sock --dns-forward 192.0.2.53
+passt echo "nameserver 192.0.2.2" > /etc/r && mv /etc/r /etc/resolv.conf
+sleep 1
+passt echo "nameserver 2001:db8::1" > /etc/r && mv /etc/r /etc/resolv.conf
+sleep 1
+passt kill $(cat __PIDFILE__)
passt umount /etc
passt exit
+check grep -q "new host nameserver 192.0.2.2" __PASST_LOG__
+check grep -q "removed nameserver 192.0.2.2" __PASST_LOG__