]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
network: prevent dnsmasq from listening on localhost
authorLaine Stump <laine@laine.org>
Thu, 13 Dec 2012 06:46:40 +0000 (01:46 -0500)
committerLaine Stump <laine@laine.org>
Thu, 13 Dec 2012 17:29:53 +0000 (12:29 -0500)
This patch resolves the problem reported in:

   https://bugzilla.redhat.com/show_bug.cgi?id=886663

The source of the problem was the fix for CVE 2011-3411:

   https://bugzilla.redhat.com/show_bug.cgi?id=833033

which was originally committed upstream in commit
753ff83a50263d6975f88d6605d4b5ddfcc97560. That commit improperly
removed the "--except-interface lo" from dnsmasq commandlines when
--bind-dynamic was used (based on comments in the latter bug).

It turns out that the problem reported in the CVE could be eliminated
without removing "--except-interface lo", and removing it actually
caused each instance of dnsmasq to listen on localhost on port 53,
which created a new problem:

If another instance of dnsmasq using "bind-interfaces" (instead of
"bind-dynamic") had already been started (or if another instance
started later used "bind-dynamic"), this wouldn't have any immediately
visible ill effects, but if you tried to start another dnsmasq
instance using "bind-interfaces" *after* starting any libvirt
networks, the new dnsmasq would fail to start, because there was
already another process listening on port 53.

This patch changes the network driver to *always* add
"except-interface=lo" to dnsmasq conf files, regardless of whether we use
bind-dynamic or bind-interfaces. This way no libvirt dnsmasq instances
are listening on localhost (and the CVE is still fixed).

The actual code change is miniscule, but must be propogated through all
of the test files as well.

(This is *not* a cherry-pick of the upstream commit that fixes the bug
(commit d66eb7866757dd371560c288dc6201fb9348792a), because subsequent
to the CVE fix, another patch changed the network driver to put
dnsmasq options in a conf file rather than directly on the dnsmasq
commandline preserving the same options), so a cherry-pick is just one
very large conflict.)

src/network/bridge_driver.c
tests/networkxml2argvdata/isolated-network.argv
tests/networkxml2argvdata/nat-network-dns-hosts.argv
tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
tests/networkxml2argvdata/nat-network-dns-srv-record.argv
tests/networkxml2argvdata/nat-network-dns-txt-record.argv
tests/networkxml2argvdata/nat-network.argv
tests/networkxml2argvdata/netboot-network.argv
tests/networkxml2argvdata/netboot-proxy-network.argv
tests/networkxml2argvdata/routed-network.argv

index 1fa7cd021be7af7acb1209cd3cd9f0015a8cc849..ff11364dd9c0519417211146ab88b4ccc2383062 100644 (file)
@@ -672,6 +672,9 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
     /* *no* conf file */
     virCommandAddArg(cmd, "--conf-file=");
 
+    /* dnsmasq will *always* listen on localhost unless told otherwise */
+    virCommandAddArgList(cmd, "--except-interface", "lo", NULL);
+
     if (dnsmasqCapsGet(caps, DNSMASQ_CAPS_BIND_DYNAMIC)) {
         /* using --bind-dynamic with only --interface (no
          * --listen-address) prevents dnsmasq from responding to dns
@@ -685,10 +688,7 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
                              "--interface", network->def->bridge,
                              NULL);
     } else {
-        virCommandAddArgList(cmd,
-                             "--bind-interfaces",
-                             "--except-interface", "lo",
-                             NULL);
+        virCommandAddArg(cmd, "--bind-interfaces");
         /*
          * --interface does not actually work with dnsmasq < 2.47,
          * due to DAD for ipv6 addresses on the interface.
index 3d8601e686fe57bbae3647aca404265f51f4dc90..861fd743372427b60d1446ee2f16dcd27575674b 100644 (file)
@@ -1,6 +1,6 @@
 @DNSMASQ@ --strict-order \
 --local=// --domain-needed --conf-file= \
---bind-interfaces --except-interface lo \
+--except-interface lo --bind-interfaces \
 --listen-address 192.168.152.1 \
 --dhcp-option=3 --no-resolv \
 --dhcp-range 192.168.152.2,192.168.152.254 \
index e5143acbbecb6ec518a457c2c423547d2946514f..431e98744f404863dc5781015e135ed9d47f1e4d 100644 (file)
@@ -1,5 +1,5 @@
 @DNSMASQ@ --strict-order --domain=example.com \
 --local=/example.com/ --domain-needed \
 --conf-file= \
---bind-dynamic --interface virbr0 \
+--except-interface lo --bind-dynamic --interface virbr0 \
 --expand-hosts --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts\
index 031da3fc3cd2def96a0f978219ace34927a6f22a..24d88ad13837e2debe652b2a8f7641732124a27a 100644 (file)
@@ -1,7 +1,7 @@
 @DNSMASQ@ \
 --strict-order \
 --local=// --domain-needed --conf-file= \
---bind-interfaces --except-interface lo \
+--except-interface lo --bind-interfaces \
 --listen-address 192.168.122.1 \
 --listen-address 192.168.123.1 \
 --listen-address fc00:db8:ac10:fe01::1 \
index beff591a34dbe5b59bc0f25e8df11017a4924542..f417af80bdcbece557c0ffda978b7cbe7326367b 100644 (file)
@@ -1,7 +1,7 @@
 @DNSMASQ@ \
 --strict-order \
 --local=// --domain-needed --conf-file= \
---bind-dynamic --interface virbr0 \
+--except-interface lo --bind-dynamic --interface virbr0 \
 --srv-host=name.tcp.test-domain-name,.,1024,10,10 \
 --dhcp-range 192.168.122.2,192.168.122.254 \
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases \
index fc164f6d78c37add9038616727b631c55de7d6b3..86b7ba327a76b0abd7dab4a40704d665724b5c79 100644 (file)
@@ -1,6 +1,6 @@
 @DNSMASQ@ --strict-order \
 --local=// --domain-needed --conf-file= \
---bind-dynamic --interface virbr0 \
+--except-interface lo --bind-dynamic --interface virbr0 \
 '--txt-record=example,example value' \
 --dhcp-range 192.168.122.2,192.168.122.254 \
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases \
index 6303f76a1f7e5000d55befd3a21d8152c7aeabfe..8a540d52196d2486a6feec9bddf1bd22f1e7f6e4 100644 (file)
@@ -1,6 +1,6 @@
 @DNSMASQ@ --strict-order \
 --local=// --domain-needed --conf-file= \
---bind-dynamic --interface virbr0 \
+--except-interface lo --bind-dynamic --interface virbr0 \
 --dhcp-range 192.168.122.2,192.168.122.254 \
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases \
 --dhcp-lease-max=253 --dhcp-no-override \
index 9699e5c8ebac9717a1d0d0085a49be7fb4cc71d9..0e17a71809060eb7846b4627fb6c8f1a443ff14d 100644 (file)
@@ -1,6 +1,6 @@
 @DNSMASQ@ --strict-order --domain=example.com \
 --local=/example.com/ --domain-needed --conf-file= \
---bind-interfaces --except-interface lo --listen-address 192.168.122.1 \
+--except-interface lo --bind-interfaces --listen-address 192.168.122.1 \
 --dhcp-range 192.168.122.2,192.168.122.254 \
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \
 --dhcp-lease-max=253 --dhcp-no-override --expand-hosts \
index 9ac301832eb84a799af2ccc337a33b03cb60478d..8764ef57a572a42b652980cdc575243da1510539 100644 (file)
@@ -1,6 +1,6 @@
 @DNSMASQ@ --strict-order --domain=example.com \
 --local=/example.com/ --domain-needed --conf-file= \
---bind-interfaces --except-interface lo \
+--except-interface lo --bind-interfaces \
 --listen-address 192.168.122.1 \
 --dhcp-range 192.168.122.2,192.168.122.254 \
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \
index 700c904a3fb97f0e8d5053dc71d50fc156c3c915..3221f6518284fd158dba780ff75ff51b2b497e8c 100644 (file)
@@ -1,4 +1,4 @@
 @DNSMASQ@ --strict-order \
 --local=// --domain-needed --conf-file= \
---bind-dynamic --interface virbr1 \
+--except-interface lo --bind-dynamic --interface virbr1 \
 --addn-hosts=/var/lib/libvirt/dnsmasq/local.addnhosts\