From nobody Tue Oct 19 13:11:48 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9D09917FD025 for ; Tue, 19 Oct 2021 13:11:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HYYzm1pl8z4d9S for ; Tue, 19 Oct 2021 13:11:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1FABA14D9A for ; Tue, 19 Oct 2021 13:11:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 19JDBm4D018418 for ; Tue, 19 Oct 2021 13:11:48 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 19JDBmDI018417 for bugs@FreeBSD.org; Tue, 19 Oct 2021 13:11:48 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 248184] readlink("/proc/curproc/file") returns arbitrary correct name for programs with more than one link (name) Date: Tue, 19 Oct 2021 13:11:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 12.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: tobik@freebsd.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D248184 Tobias Kortkamp changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tobik@freebsd.org --- Comment #6 from Tobias Kortkamp --- (In reply to Conrad Meyer from comment #1) The problem is also present with AT_EXECPATH. AT_EXECPATH doesn't really make a difference if the wrong name is copied to userspace in the first place. $ freebsd-version 13.0-RELEASE-p4 $ cat execpath.c #include #include #include int main(int argc, char *argv[]) { char pathname[PATH_MAX]; elf_aux_info(AT_EXECPATH, pathname, PATH_MAX); puts(pathname); return 0; } $ make execpath $ ln -f execpath tmp/execpath $ ./execpath /home/tobias/execpath $ ./tmp/execpath /home/tobias/tmp/execpath $ ./execpath # I'd expect this to return /home/tobias/execpath again but: /home/tobias/tmp/execpath Now I'm coming back to this because lang/rust uses hardlinks in the build by default. We have disabled this since it caused intermittent build failur= es because env::current_exe (uses kern.proc.pathname.-1 sysctl internally) mig= ht returns the wrong pathname (one of the hardlinks) sometimes and rustc fails to find the right std crate. This is my working theory anyway. It's diffic= ult to trigger the problem on my package builder. I was going to experiment with switching it over to AT_EXECPATH but I guess that will make no difference because of the current behavior of it. If getexecname() would be just a wrapper for elf_aux_info(AT_EXECPATH) then it wouldn't solve the problem either. Any suggestions what we should use instead of kern.proc.pathname, AT_EXECPA= TH, or /proc/curproc/file? --=20 You are receiving this mail because: You are the assignee for the bug.=