From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 44C1B6EC9; Tue, 04 Nov 2025 15:27:06 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id E6F586EBC; Tue, 04 Nov 2025 15:27:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fout-a5-smtp.messagingengine.com (fout-a5-smtp.messagingengine.com [103.168.172.148]) by atuin.qyliss.net (Postfix) with ESMTPS id 647286EBA for ; Tue, 04 Nov 2025 15:27:02 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 43C92EC01B0; Tue, 4 Nov 2025 10:27:01 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Tue, 04 Nov 2025 10:27:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1762270021; x=1762356421; bh=GFuMOz7mta G6gfZGGIYH033TeFjuyV6xuImO9Q3SfXc=; b=fYqk120QVJFMeXMkLWZxeqZJZc R6dUgZIbQ7b8bVSGspckqDIG0iy5VWV9SN5ahStpTv2VjGusu+SrZasiW8mqj8AV K7ZnZCf0HvPjapN/QB5eqNWHCTZnWGq2/yC9p0DZ04YqXFlNqm4gQ1V/sXL4r/Bj g8l/7bJ1rsw8ckJkEQyShaL0qMggQOUoCTugiHwN0PypQS6Bapmb0jdO5I9uzTcs br/x9QZA3zS0NQOmTKZEwslQ6O8FY9n4U6bd9SwvYzR4a/eycLfD03nmDV2iLt4z cUdY7btJOg8jbnIuoPNGXpYyg0mXxYbzQti1Tlf80teJwAyBVpB0v9tifR6Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1762270021; x=1762356421; bh=GFuMOz7mtaG6gfZGGIYH033TeFjuyV6xuIm O9Q3SfXc=; b=XMzd2NTlAfBtv6wG1VPXF0fXpDkoI+kgnDSmDsfR/mvRfuvB4kX 8g/kUumCTsBDs3auXopnCbEGD4MwQSfuFKxK5AbH9eV3wRNfdBpmz4u6kornilZn ZMaOiR5DNG1MWNUijTl+z1nRNRqf3lmSBcjRrS5mmsiPB3oP6Jwjmlkdo+LAxt60 eYBGBtZXCn3BrANbxWzxTNyVxPiQ6r4wjoT0kML4fJkLwqpPGgMSTDyXNuUq8kxc B19GOOdJQsJmkJ60YNu7Not5M0d/1rbMuNp+yTPA1SjvRPf9tY6/FCz2UV7pRooa O6Jz2pkISVoI7L2ddc3wrigP3+llKvJbPog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddukedufeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkgggtsehgtderredttdejnecuhfhrohhmpeetlhihshhsrgcu tfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpeetheevud fgjefghefhieejudelkeeljeegvdekueeuhffhgedvveefteevgeetieenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrd hishdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohep uggvmhhiohgsvghnohhurhesghhmrghilhdrtghomhdprhgtphhtthhopeguvghvvghlse hsphgvtghtrhhumhdqohhsrdhorhhg X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Nov 2025 10:27:00 -0500 (EST) Received: by mbp.qyliss.net (Postfix, from userid 1000) id 84EDC642BBF9; Tue, 04 Nov 2025 16:26:59 +0100 (CET) From: Alyssa Ross To: Demi Marie Obenour Subject: Re: [PATCH 3/7] tools: Add directory checker for updates In-Reply-To: <8f2a4673-b6eb-466f-b42c-17e42f698829@gmail.com> References: <20251029-updates-v1-0-401c1be2a11b@gmail.com> <20251029-updates-v1-3-401c1be2a11b@gmail.com> <87sef1kjbk.fsf@alyssa.is> <72921587-e951-4bfb-b68e-5cb05fc32609@gmail.com> <87bjlmq756.fsf@alyssa.is> <831ecec1-d782-4fab-a6d5-40eae0f9ad92@gmail.com> <87ms54pr0l.fsf@alyssa.is> <8f2a4673-b6eb-466f-b42c-17e42f698829@gmail.com> Date: Tue, 04 Nov 2025 16:26:58 +0100 Message-ID: <87jz05rf7h.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: DM7LIFDHUKHJYJBWUWOFUNXLHTDWYJA3 X-Message-ID-Hash: DM7LIFDHUKHJYJBWUWOFUNXLHTDWYJA3 X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Spectrum OS Development X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Demi Marie Obenour writes: > On 11/2/25 07:43, Alyssa Ross wrote: >> On Sun, Nov 02, 2025 at 01:18:02PM +0100, Alyssa Ross wrote: >>> Demi Marie Obenour writes: >>> >>>> On 11/1/25 08:17, Alyssa Ross wrote: >>>>> Demi Marie Obenour writes: >>>>> >>>>>> On 10/29/25 08:01, Alyssa Ross wrote: >>>>>>> Demi Marie Obenour writes: >>>>>>> >>>>>>>> Spectrum OS's host has no network access. Updates must be downloa= ded by >>>>>>>> VMs. The downloads are placed into a bind-mounted directory. The= VM >>>>>>>> can write whatever it wants into that directory. This includes sy= mlinks >>>>>>>> that subsequent code might open, which would create a path travers= al >>>>>>>> vulnerability. It also includes paths with names containing conta= ining >>>>>>>> terminal escape sequences, newlines, or other nastiness. Furtherm= ore, >>>>>>>> the directory should not have any subdirectories either. >>>>>>>> >>>>>>>> Add a simple C program that checks for such ugliness and indicates >>>>>>>> (via its exit code) if the VM misbehaved. It also ensures that bo= th >>>>>>>> SHA256SUMS and SHA256SUMS.gpg are present. >>>>>>>> >>>>>>>> Signed-off-by: Demi Marie Obenour >>>>>>>> --- >>>>>>>> host/rootfs/Makefile | 6 +- >>>>>>>> lib/kcmdline-utils.mk | 6 ++ >>>>>>>> tools/default.nix | 1 + >>>>>>>> tools/meson.build | 1 + >>>>>>>> tools/updates-dir-check/meson.build | 4 ++ >>>>>>>> tools/updates-dir-check/updates-dir-check.c | 94 ++++++++++++++++= +++++++++++++ >>>>>>>> 6 files changed, 110 insertions(+), 2 deletions(-) >>>>>>> >>>>>>> I still don't really understand why this needs to be a C program in= stead >>>>>>> of find -H /path/to/dir -not -type f. None of the other checks seem >>>>>>> very necessary? >>>>>> >>>>>> I trust this code more than I trust (especially) the Busybox >>>>>> implementation of find. >>>>> >>>>> This doesn't really make sense to me. All of this is quite trivial f= ind >>>>> behaviour =E2=80=94 not the sort of thing that's unlikely to have bee= n widely >>>>> tested. No objection to GNU find though if it helps. >>>> >>>> I see: find with a -exec false to return an error if anything matching >>>> is found? >>>> >>>> I'm way more familiar with C than with find, which is why I missed thi= s. >>> >>> Hmm, thinking about it some more I suppose there's a problem with find: >>> there's no way to get it to exit as soon as it finds a matching file, >>> with a failing error code, so it could end up running way too long. >>> >>> So the C program is fine, I guess. >>=20 >> Actually, we can do it. We just need to make find not responsible for >> exiting. >>=20 >> foreground { >> pipeline { find -H /path/to/dir -mindepth 1 -not -type f -prune } >> grep -q . >> } >> importas -iu ? ? >> if { test $? -eq 1 } >> # We have only regular files. >>=20 >> When find prints a line, grep will exit, and find will receive SIGPIPE >> and exit. > > This version also has a bug: if find exits with an error without > printing anything, the exit status will be ignored. Something like > this (not tested) might work: > > pipeline { find -H /path/to/dir -mindepth 1 -not -type f -prune } > importas -iu ! ! > foreground { grep -q . } > if { importas -iu ? ? test $? -eq 1 } > wait $! > importas -iu ? ? > if { test $? -eq 0 } > > However, it's all way way way way too subtle for me. It's short, > but it's also extremely error-prone. The C program is longer, but > it's also much easier to understand and modify. Okay. :) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRV/neXydHjZma5XLJbRZGEIw/wogUCaQobQgAKCRBbRZGEIw/w ouimAP0WTT5EsE3SSwH8G0fxnLpxsX7ayS8KzhK9sRvnO5ekSgD+ND06EN//6uvc xjWy+uQD9oTIc+iT8gsILQR0YInVFgk= =JRLL -----END PGP SIGNATURE----- --=-=-=--