From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id CF9675A0082 for ; Sat, 5 Nov 2022 02:21:53 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4N408G1rqcz4xGT; Sat, 5 Nov 2022 12:21:50 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1667611310; bh=l1Ka3CFG93TrZNcEKP/4A9jp/S9Wiq8aZfaTcPFCsPA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EkkmMf9feZj55NqHhqNN/1sYdE2ru4hrcRjXpuRKnE2Y3Eg0zjDNdgoKus8GmRAiL 7IccKw4xr3dPALgE8DY13M9ugo4OuP3QiLKI0nZrpYPc7mzH/QaAn1HmlU4nsFpbNm MWsAw9UJ8O5I0NUaSTUiJ5PhUgluHbciIx1dG180= Date: Sat, 5 Nov 2022 12:19:55 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 3/3] udp: Check for answers to forwarded DNS queries before handling local redirects Message-ID: References: <20221102230443.377446-1-sbrivio@redhat.com> <20221102230443.377446-4-sbrivio@redhat.com> <20221103074251.60b2898b@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ggkOoqSmdJct6XKu" Content-Disposition: inline In-Reply-To: <20221103074251.60b2898b@elisabeth> Message-ID-Hash: 2IX7CKSUUZGFZXPSLLCU525RGRV5NJ5K X-Message-ID-Hash: 2IX7CKSUUZGFZXPSLLCU525RGRV5NJ5K X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Paul Holzinger X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: <> Archived-At: List-Archive: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --ggkOoqSmdJct6XKu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 03, 2022 at 07:42:51AM +0100, Stefano Brivio wrote: > On Thu, 3 Nov 2022 14:42:13 +1100 > David Gibson wrote: >=20 > > On Thu, Nov 03, 2022 at 12:04:43AM +0100, Stefano Brivio wrote: > > > Now that we allow loopback DNS addresses to be used as targets for > > > forwarding, we need to check if DNS answers come from those targets, > > > before deciding to eventually remap traffic for local redirects. > > >=20 > > > Otherwise, the source address won't match the one configured as > > > forwarder, which means that the guest or the container will refuse > > > those responses. > > >=20 > > > Signed-off-by: Stefano Brivio > > > --- > > > udp.c | 17 ++++++++--------- > > > 1 file changed, 8 insertions(+), 9 deletions(-) > > >=20 > > > diff --git a/udp.c b/udp.c > > > index 4b201d3..7c77e09 100644 > > > --- a/udp.c > > > +++ b/udp.c > > > @@ -680,8 +680,10 @@ static void udp_sock_fill_data_v4(const struct c= tx *c, int n, > > > src =3D ntohl(b->s_in.sin_addr.s_addr); > > > src_port =3D ntohs(b->s_in.sin_port); > > > =20 > > > - if (src >> IN_CLASSA_NSHIFT =3D=3D IN_LOOPBACKNET || > > > - src =3D=3D INADDR_ANY || src =3D=3D ntohl(c->ip4.addr_seen)) { > > > + if (c->ip4.dns_fwd && src =3D=3D htonl(c->ip4.dns[0]) && src_port = =3D=3D 53) { =20 > >=20 > > I guess this is not a newly introduced bug, but for the case of > > multiple host nameservers, don't you need to check against everything > > in the ip4.dns[] array, not just entry 0? >=20 > No, because that's the only one we're using as target for forwarded > queries -- and DNS answers we want to check here are only the forwarded > ones. *thinks* .. ok, that makes sense. But if that's the case, won't ip4.dns[0] be the only entry in ip4.dns[] we use for anything at all? Can we drop the table and just keep one entry? --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --ggkOoqSmdJct6XKu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmNlujIACgkQgypY4gEw YSKhghAAgDQjXAo4bSV1ryG+qbqr4bbb83Ef9pqLt5YSAn/cHH0xXVHOBdxbpisB ltBflu5vXOo9xiiKwpYSbJjcUGUMOnlu0BYIfNsys76wD/Rfa8465a3wu/oSki/n lvFvIz867I1hEsBenHrEyJeV98AVacQ2HdPoJepZ6PO9xH/p4Ng6OPe8E+OooFnc Znlghg/v0krh76X6ydodNqzIoNhbRZUe/OX5EOIY7aQSqJk1Mm7ggsbbtd8Qsq/6 T1TzWIsvoAWdx4V6IPZlmJYe0PjhGauW7O3Tm6SRbYO4ACDRTuvSQXAEjm5pfTyF bdRByUTe9CreObKpsUjfEceNB4y3ildtlFRZMFU6/teIPe3jYAU/63O9PadEgHzN XckvQ65fpU2KW9c24R6GDgu2Vj2g0hjN0Ro+qRfRIiL2aKrl1pgm8oQKVi9SEHLq xBiUZ/oRyuErUpGMqYxbqCPGzwa6D6/wEoQntQ8Omh7i05dnve+HMVKmk9YcJc2O 0cuzvTjYygo0lsXCqeGbgStdpKHwsMv5K/5u6ICmKtS8LkJ5cZi21Fzjp+DS5uaD F/nQ1aqHaYuqjf/CH/rc6JV4pkJ4WAr5oZL1QuDNGB+0xCPweU3GCU9jo0LR++po AyyENvMXz9Kut0aGdLss0tGgGjh4OMw3qwr9i+uxOxC8n+D4mSQ= =hpNP -----END PGP SIGNATURE----- --ggkOoqSmdJct6XKu--