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=202606 header.b=JnorUfZg; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 3A53F5A0262 for ; Thu, 16 Jul 2026 07:45:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1784180742; bh=UQGR0rbU59VuJ8OgzeE4wDKycrGZORIcauTNwfvzqSc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JnorUfZgfq1+DBfKLz4XUZzUCb9V6CQT9dQfBcJWalC4Rel9AZGlnlSBSpXyqMeLt 7WSpMeTSYorh4onlP+Xl+QpRftc7uFZHj1O8DMFBf69EPjUVqu1w+roptmwGeDZPOE nuhqUgmT2YInefJclEtRFORf6S44nVyiCWxwNVuML9Ns24WE0bb9ZELYduqunLiPZe WEKlVqK9RiqysPv6ID6Nng8BAGKZ6co7JXr/S/1gQpCfyNkc7nKpgMTrI3rEhFlPJC 8kxymFf9thKLmsrY6ChdohNPXKfXGD1XP4mFYZ1dGQvnwSDkKjFndOnl80R9C0mJEN VLdTZUKbCuLjg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4h12866sRpz4wCC; Thu, 16 Jul 2026 15:45:42 +1000 (AEST) Date: Thu, 16 Jul 2026 15:12:44 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 2/6] isolation, conf: Set c->fd_tap from eary parse of --fd Message-ID: References: <20260714092926.2881848-1-david@gibson.dropbear.id.au> <20260714092926.2881848-3-david@gibson.dropbear.id.au> <20260715091234.603c7963@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JavhjYqSr+w5QIpq" Content-Disposition: inline In-Reply-To: <20260715091234.603c7963@elisabeth> Message-ID-Hash: MYRCJHGCR32VUVV5Q2S42VHQUDDAJET6 X-Message-ID-Hash: MYRCJHGCR32VUVV5Q2S42VHQUDDAJET6 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: --JavhjYqSr+w5QIpq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 15, 2026 at 09:12:35AM +0200, Stefano Brivio wrote: > On Tue, 14 Jul 2026 19:29:22 +1000 > David Gibson wrote: >=20 > > We parse --fd twice: once in isolate_initial() just to avoid clobbering > > the passed in fd. Then we parse it "for real" in conf(), to set c->fd_= tap > > and other configuration variables. > >=20 > > Change this, so that we return the value parsed early from > > isolate_initial() and set c->fd_tap from that. This doesn't accomplish > > much immediately, but will make some further cleanups possible. > >=20 > > Signed-off-by: David Gibson > > --- > > conf.c | 2 +- > > isolation.c | 6 +++++- > > isolation.h | 2 +- > > passt.c | 2 +- > > 4 files changed, 8 insertions(+), 4 deletions(-) > >=20 > > diff --git a/conf.c b/conf.c > > index 6d83daef..41c9d557 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -1593,7 +1593,7 @@ void conf(struct ctx *c, int argc, char **argv) > > c->fd_control_listen =3D c->fd_control =3D -1; > > break; > > case 'F': > > - c->fd_tap =3D conf_tap_fd(optarg); > > + /* --fd was parsed early and c->fd_tap set in main() */ > > c->one_off =3D true; > > *c->sock_path =3D 0; > > break; > > diff --git a/isolation.c b/isolation.c > > index 07b281bb..4bb79e34 100644 > > --- a/isolation.c > > +++ b/isolation.c > > @@ -203,8 +203,10 @@ static int move_root(void) > > * - close all open files except for standard streams and the one fro= m --fd > > * Mustn't: > > * - remove filesystem access (we need to access files during setup) > > + * > > + * Return: fd number from --fd, or -1 if not specified >=20 > I think this is a rather weird value to return for a function that's > called isolate_initial(). Agreed, but there are reasons.. > Are patches 1/2 and 2/2 really needed for the > rest of the series? I don't quite see the connection. 1) (minor) The new semantics of conf_tap_fd() introduced in 3/6 work better (IMO) for its use in close_open_files(), but don't work for its reuse during the "main" arg parse. Removing that second parse avoids the problem. 2) (major) 4/6 significantly simplifies the close_range() logic, but it involves *moving* the tap descriptor given with --fd (using dup2(2). That means if we parsed it again, it would now be wrong. I think the weirdness would also be mitigated, if close_open_files() became isolate_fds(), and was called directly from main() rather than via isolate_initial(). >=20 > I'm still reviewing the rest of the series. >=20 > --=20 > Stefano >=20 --=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 --JavhjYqSr+w5QIpq Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmpYaEEACgkQzQJF27ox 2Gehlw/9GZQj0J5e3TtRfW0vwQsHV1HnTykdfaEFSPsLv7YgGKX35+gamwZHLq31 2W4xVDc/aImRSW5nDpMUWAFp2Zmpzanrq69UpNCGIOiUjJkQdZIzEEaY5Nsyz9bP VL2D0z6RHg/D9ZMQxuKO6+IP57V+Nn1PhwzZ4fmKDjrcgS7PsXrRfCeVOespIZcv yMzVRGa9JCLYBY0xpMTToJgAQEkTVQxmsGvPwfyrEhneLo1+3KPNfSMMokO3A7cn VtuQXzdT0bMLhwULawF3MqqAXDFKSs77C5lj2RwaAzCOslU1ydsPZg1LzTYcJbN3 uPkge4tUfBgZyRVH5s0D04sMHkau1duZ1OhNaRsYOgk+gK4Sva935AVxioTrsjyV t+lY0XsuxwFKmcULkColbUkVSxoHl9s3Nxba17ehngFm1lo33gDI/eEQeNHAjZR3 OC5wdX4xyBwqqxtPHELivBCday4onIEx6pvD0bXV7vJzNcGDXCdekgW80SN0XGwN 8ExV66FZQYZinA++KLfhyZjMATsfbitLV41yL9LCLfHOoYV20/+EwRqNNPIlCOJ0 xP8D+bOVY21CN4utYXs83Gnm654o0fJlGgi/fir37Cgz0Ei+WjBteeTGS/ESYxZd ZxTE2ZTGFn2ih6btXH2HdE7BgI6HRvu2Z04D+j7lHPc/ELxQ0eM= =bg4V -----END PGP SIGNATURE----- --JavhjYqSr+w5QIpq--