From nobody Thu Dec 18 00:23:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639509057; cv=none; d=zohomail.com; s=zohoarc; b=he5by6XG6YONdVhBaXTWHOWM9PsFyRng2tg7z7LEwDAZ/XpZaY2DwIQUo5E62jlcsAEfG3cJujdza8zcrR1SWE40nNub8EBgGHHessBrL/qkuWOI9KgYjXjSaAS9dXP3vcS/Ntd5ufotBhciBkAl4NrCSDL5okiCFarQ0BWI1E4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639509057; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GwzwBKYGTk1Q8FfYypFEFe+0QvCiskvvzIvmqdGxuE8=; b=cmaVTCidn5nWztcTMNxvfohIbMr+sH+vkCwvqH4ItQv+2DJTzqv5rgNRmBnB5vrrZTHhRQt2GmgWQCH4zV4hXDY+9COk3zvbXSU71yQXMEHUuhteeXqvkpN+qhOXVX1SDDnuXRIpVmCHfqeXzKcNoRsKygb3KF0PZ/afypHncRE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639509057539563.523771058164; Tue, 14 Dec 2021 11:10:57 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-168-dtU2yOjyM8SglK1V1z5Iyw-1; Tue, 14 Dec 2021 14:10:52 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 04DC9192FDA6; Tue, 14 Dec 2021 19:10:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D80C27A220; Tue, 14 Dec 2021 19:10:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A56EA4A7C9; Tue, 14 Dec 2021 19:10:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BEJAkGS001207 for ; Tue, 14 Dec 2021 14:10:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8910C610AE; Tue, 14 Dec 2021 19:10:46 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FCEC610A7 for ; Tue, 14 Dec 2021 19:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639509056; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GwzwBKYGTk1Q8FfYypFEFe+0QvCiskvvzIvmqdGxuE8=; b=XkKTaxUu1NJ1tSm6FI7CQWtWJ3fGasE1I/J07nCI+m60fZYZHe6CK0A5Ezrv7HPWVLAKhi f63hOD5nTyWYNDZfEciGcV4FuQ0YXhb3ieqnuCnwMvH5UjKKIoK35zW7wPhOKk9MW/qWi2 FH2dYrfIRdCRRcqEuoRpGZJ6GTK37aI= X-MC-Unique: dtU2yOjyM8SglK1V1z5Iyw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/17] network: assume DNSMASQ_CAPS_BIND_DYNAMIC Date: Tue, 14 Dec 2021 20:09:23 +0100 Message-Id: <17292dadbb52b4182d766cde9dea0eb56fbe3a34.1639508754.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639509059044100002 Introduced by dnsmasq commit: commit 54dd393f3938fc0c19088fbd319b95e37d81a2b0 CommitDate: 2012-06-20 11:23:38 +0100 Add --bind-dynamic git describe: v2.63test1 contains: v2.63test1^0 Signed-off-by: J=C3=A1n Tomko --- src/network/bridge_driver.c | 68 ++++++------------------------------- 1 file changed, 11 insertions(+), 57 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index e57731742b..dffe4e1574 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1062,7 +1062,6 @@ networkDnsmasqConfContents(virNetworkObj *obj, size_t i; virNetworkDNSDef *dns =3D &def->dns; bool wantDNS =3D dns->enable !=3D VIR_TRISTATE_BOOL_NO; - virNetworkIPDef *tmpipdef; virNetworkIPDef *ipdef; virNetworkIPDef *ipv4def; virNetworkIPDef *ipv6def; @@ -1173,62 +1172,17 @@ networkDnsmasqConfContents(virNetworkObj *obj, virBufferAddLit(&configbuf, "except-interface=3Dlo0\n"); #endif =20 - if (dnsmasqCapsGet(caps, DNSMASQ_CAPS_BIND_DYNAMIC)) { - /* using --bind-dynamic with only --interface (no - * --listen-address) prevents dnsmasq from responding to dns - * queries that arrive on some interface other than our bridge - * interface (in other words, requests originating somewhere - * other than one of the virtual guests connected directly to - * this network). This was added in response to CVE 2012-3411. - */ - virBufferAsprintf(&configbuf, - "bind-dynamic\n" - "interface=3D%s\n", - def->bridge); - } else { - virBufferAddLit(&configbuf, "bind-interfaces\n"); - /* - * --interface does not actually work with dnsmasq < 2.47, - * due to DAD for ipv6 addresses on the interface. - * - * virCommandAddArgList(cmd, "--interface", def->bridge, NULL); - * - * So listen on all defined IPv[46] addresses - */ - for (i =3D 0; - (tmpipdef =3D virNetworkDefGetIPByIndex(def, AF_UNSPEC, i)); - i++) { - g_autofree char *ipaddr =3D virSocketAddrFormat(&tmpipdef->add= ress); - - if (!ipaddr) - return -1; - - /* also part of CVE 2012-3411 - if the host's version of - * dnsmasq doesn't have bind-dynamic, only allow listening on - * private/local IP addresses (see RFC1918/RFC3484/RFC4193) - */ - if (!dnsmasqCapsGet(caps, DNSMASQ_CAPS_BINDTODEVICE) && - !virSocketAddrIsPrivate(&tmpipdef->address)) { - unsigned long version =3D dnsmasqCapsGetVersion(caps); - - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Publicly routable address %s is prohibit= ed. " - "The version of dnsmasq on this host (%d.= %d) " - "doesn't support the bind-dynamic option = or " - "use SO_BINDTODEVICE on listening sockets= , " - "one of which is required for safe operat= ion " - "on a publicly routable subnet " - "(see CVE-2012-3411). You must either " - "upgrade dnsmasq, or use a private/local " - "subnet range for this network " - "(as described in RFC1918/RFC3484/RFC4193= )."), - ipaddr, (int)version / 1000000, - (int)(version % 1000000) / 1000); - return -1; - } - virBufferAsprintf(&configbuf, "listen-address=3D%s\n", ipaddr); - } - } + /* using --bind-dynamic with only --interface (no + * --listen-address) prevents dnsmasq from responding to dns + * queries that arrive on some interface other than our bridge + * interface (in other words, requests originating somewhere + * other than one of the virtual guests connected directly to + * this network). This was added in response to CVE 2012-3411. + */ + virBufferAsprintf(&configbuf, + "bind-dynamic\n" + "interface=3D%s\n", + def->bridge); =20 /* If this is an isolated network, set the default route option * (3) to be empty to avoid setting a default route that's --=20 2.31.1