From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202510 header.b=frmVgzdI; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id ECABD5A0272 for ; Wed, 26 Nov 2025 06:42:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1764135746; bh=ZDitvRe4ejZkg0hYHVGGkpBSJILJ2/GsTFZC6fekQtY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=frmVgzdIhG9VUBH/vd80iJ+oxqGm0wFcrTLXVOzpdCmVtm86XTYUgR2TI/xaEMttr v/oj3afuvXTKDQtqt96hGsMfOJZJgUBiRf2XQr+SsSz/Pdkfweh4x+76nAgqZsJhnI M5a8J7rGW2GAuDY4m5IvC1cyaTKa8/WJ+27tXpMhWIHMEcMaLy+AXIglTtbsfvM8uE /APHlRktRwjI54cwp7rFT7/nrDkPWOIL5LMMdL9kY3ybAnJsCRbglN5kAy/EyCI9he 12CYzmW+kdqQ4keC/Twf5s8Gq1ZKWh60kh8/CkKBTVSNHw7ZAcsekEdvQcMbzMLHtG YECeyCqT7LACA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dGT3Q5Wm2z4wGK; Wed, 26 Nov 2025 16:42:26 +1100 (AEDT) Date: Wed, 26 Nov 2025 16:42:22 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v4 9/9] tcp, udp: Bind outbound listening sockets by interface instead of address Message-ID: References: <20251119052257.3004500-1-david@gibson.dropbear.id.au> <20251119052257.3004500-10-david@gibson.dropbear.id.au> <20251121045601.021b1793@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fcPTGpOIdsAUrHEN" Content-Disposition: inline In-Reply-To: <20251121045601.021b1793@elisabeth> Message-ID-Hash: KTVKOEGSIZF4KF6UDB3554SLYX7S6KNG X-Message-ID-Hash: KTVKOEGSIZF4KF6UDB3554SLYX7S6KNG 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 X-Mailman-Version: 3.3.8 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: --fcPTGpOIdsAUrHEN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 21, 2025 at 04:56:01AM +0100, Stefano Brivio wrote: > The series looks good to me in general, except that: >=20 > On Wed, 19 Nov 2025 16:22:57 +1100 > David Gibson wrote: >=20 > > Currently, outbound forwards (-T, -U) are handled by sockets bound to t= he > > loopback address. Typically we create two sockets, one for 127.0.0.1 a= nd > > one for ::1. > >=20 > > This has some disadvantages: > > * The guest can't connect via 127.0.0.0/8 addresses other than 127.0.0= =2E1 > > * We can't use dual-stack sockets, we have to have separate sockets for > > IPv4 and IPv6. > >=20 > > The restriction exists for a reason though. If the guest has any > > interfaces other than pasta (e.g. a VPN tunnel) external hosts could re= ach > > the host via the forwards. Especially combined with -T auto / -U auto = this > > would make it very easy to make a mistake with nasty security implicati= ons. > >=20 > > We can achieve this a different way, however. Don't bind to a specific > > address, but _do_ use SO_BINDTODEVICE to restrict the sockets to the "l= o" > > interface. >=20 > ...this means, as I pointed out on: >=20 > https://archives.passt.top/passt-dev/20251022105916.53925523@elisabeth/ >=20 > that we might break functionality for a number of pasta(1) users. >=20 > I don't have a complete version of the SO_BINDTODEVICE fallback I > sketched there, so I can't just add one on top of this series at the > moment, but we need something like that before I can merge this. I re-examined your proposed approach, but realised it doesn't quite work. The problem is that to complete it, sock_l4_sa() would need to create both an IPv4 and IPv6. That works right now, but it breaks the assumption that tcp_sock_init() and udp_sock_init() create (at most) a single socket. That wasn't the case until 8/9 in this series, but part of the reason for 8/9 is because establishing that invariant makes a bunch of stuff in the works much saner. So, I'm working to figure out a different approach for an SO_BINDTODEVICE fallback. --=20 David Gibson (he or they) | 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 --fcPTGpOIdsAUrHEN Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmkmkz0ACgkQzQJF27ox 2GdcbhAAmQxddVHR8a1NoPrSo9whAKKJw49moervR+Cl2lllmxjsaxOzPp7QMOdt AHoCNB8aisnqbEmf7/etOtOMQv+/MvBfUGuEIlu5AxPaAI3ZWd2KY+3PqhpyF+ad 3C2EiRlibxietVkMWOxnRq2q1PTICVqEd6cc7bRVdsM04T1SL4MFcCLAGwKvY7vd m0v2aNJKv6gIYUupk/HFrHqaHfB1v37K+mDAy773xAAjAextvZa+QGK+qHndIT/J ml3+WVxnOoXfMN6C4Ow3MSukIqEPYzIDs3dPgT8uDgwvZ24NzBSs7f24SNR5xA5O 84IY20hvBaRXIHbNnx19LkJxb/oYRxzPgMZiVOfgTq6CH76NBGlWsxlGCmq2zxGO UoD2V43XMSDhbtHn4m8KyFk/nTCvuqQcoho5LgnfoMQRZUDrl3gn111Hqh7iF17b Xm1HAHoeIjBu/Ur3IyjXt37rL95jjL15pq+3TPBa2sSQEyc7G+8xPA3u8k/YGpUo CJLdu/nZr9/eUslmIHuq/IKUbj0eIldAgSoCFLg9/RFRko17EOZWeOog2H1zrvFs ohs2uSz3LtNv3827wYs1UIe1KxOL/HbVY/vVVSudCQrM1Q9jBNCkN8ix5hbOE3rT SogOnifrAry+tsqwbL3f1s+psT+PqqFjxd0Y2HxoAnLISBSaLdk= =fvZZ -----END PGP SIGNATURE----- --fcPTGpOIdsAUrHEN--