Article View: muc.lists.netbsd.tech.userlevel
Article #67Re: Proposal: getexecpath(3)
From: David Holland
Date: Sun, 01 Nov 2026 19:34
Date: Sun, 01 Nov 2026 19:34
39 lines
3641 bytes
3641 bytes
On Mon, Oct 26, 2026 at 12:17:00PM +0000, Taylor R Campbell wrote: > > > You can always pass the original verbatim exec path to realpath(3) if > > > you want to canonicalize it, > > > > True, though that - at best - returns the hard path at the time of > > realpath (or more precisely with pieces fetched at various times > > scattered throughout the execution of realpath), which may not be the > > same as the one at the time of exec. > > If the path resolution may have concurrently changed between the > execve call and the realpath call, it may as well have concurrently > changed between the execve call and the open call. > > In other words, this race condition is inherent to the nature of > passing a path around; it cannot be avoided by asking the kernel to do > (the equivalent of) realpath. If the realpathing is done as part of namei, then there's only one lookup sequence and the resulting realpath points to the same file as the program gets loaded from, as of the time the lookup in exec is completed. Mostly. If it's an absolute path. Relative paths create further issues. Nothing prevents elements of that path from changing later before it's looked up again. But I suspect the intent is to canonicalize it into something the invoking user has no write access to. Note that our namei does this and what gets dumped into the ELF auxiliary vector has been handled this way. I don't know if OpenBSD merged my code or reimplemented it (and if they reimplemented it, whether they got it right) but that's their problem :-) -- David A. Holland dholland@netbsd.org -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<aueUVN7AxY-phkJO@netbsd.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mailReferences:
<> <20261026121701.83CF784D39@mail.netbsd.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail From: David Holland <dholland-tech@netbsd.org> Newsgroups: muc.lists.netbsd.tech.userlevel Subject: Re: Proposal: getexecpath(3) Date: Sun, 1 Nov 2026 19:34:44 +0000 Organization: Newsgate at muc.de e.V. Sender: tech-userlevel-owner@NetBSD.org Approved: news-admin@muc.de Distribution: world Message-ID: <aueUVN7AxY-phkJO@netbsd.org> References: <> <20261026121701.83CF784D39@mail.netbsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="52537"; mail-complaints-to="news-admin@muc.de" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netbsd.org; s=20240131; t=1793561687; bh=zXPl1kFW58CezMapc3MwkNJD3aiMG9SxnaL19jp/EDY=; h=Date:From:To:Subject:References:In-Reply-To:List-Id: List-Unsubscribe; b=K5FKnYy0mTKd+aeXIDV2Ur6JvLQGl3QhG716mxtm4IwjW/FQGELbLPSClxLfMXCbx KQ2jhDcZvoYkUaEh1aGRDqI5tENA9lXIYoTSdySgKJVoSRBAZuaE9wlX6i1a4e0Svh FocWC3VOuQDe5VeywOrbD2QSkqaO0228xRmmSQj4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netbsd.org; s=20240131; t=1793561684; bh=zXPl1kFW58CezMapc3MwkNJD3aiMG9SxnaL19jp/EDY=; h=Date:From:To:Subject:References:In-Reply-To; b=XEU1QH+zS4TgVj/dOHyey3hMYIrkyqSIQhyVAy0XJhgbFL0yUNg//CIud00jNA+Tn u19BuoTj8QUb5JaNaM9DeCkQvMMegO+e6gbPLi/Fu/Xkl1kzVDOe3pLhpVjLwWTrVY PriaEOCXO9QEa0S/BZq8rMHfxw1fOneVvdT92bY8= Content-Disposition: inline In-Reply-To: <20261026121701.83CF784D39@mail.netbsd.org> Precedence: bulk X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes