提交 9eb2b573 编写于 作者: L Laine Stump

network: prevent dnsmasq from listening on localhost

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
753ff83a. 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 d66eb786), 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.)
上级 35472c92
......@@ -510,6 +510,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
......@@ -523,10 +526,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.
......
@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 \
......
@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\
@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 \
......
@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 \
......
@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 \
......
@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 \
......
@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 --enable-tftp \
......
@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 \
......
@DNSMASQ@ --strict-order \
--local=// --domain-needed --conf-file= \
--bind-dynamic --interface virbr1\
--except-interface lo --bind-dynamic --interface virbr1\
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册