From nobody Tue Apr 22 18:12:44 2025 X-Original-To: dev-commits-src-all@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 4Zhr1n0Q9Hz5t0gK; Tue, 22 Apr 2025 18:12:45 +0000 (UTC) (envelope-from git@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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Zhr1m68D1z3hbV; Tue, 22 Apr 2025 18:12:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745345564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9fGuhqWr0PMHCLt8DrjerneIoJL2WCG2CgfQunuyrek=; b=sh63KGVB7WLLAZu2MvkiKzY2i5qOL2i3ONBuF43yHmkSPAhI8bRu9q4IIJEdecSf+34yhg S9brB4u+uM3Ngnjc4OqU51Ajr9HwpLyOPO6AKfb1cacIHRuF7S1I5aOiB7zNJWplfzt60H q/PPfaOmmAfe/lRXKT5QoUV4k9Md5RpHGrwz/Rqbx0/fDVkJdaePE3yAWUfKAXI6iEqE64 RspdkSmo+ISQqUZxq9lJ3o9S0w+1TYBOPyD/xnujlHMftvxAcJAXdA3GXd4KKN2ccMTo31 ffUG57BoqukZnj3nK6N2UQntWk8+kP+tqvhIlYMmMqQA225rAGfYz02EWATPpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745345564; a=rsa-sha256; cv=none; b=bGg431FRR1NlgRKSK+V+Mnd8IdcccuKfq2iuAbcij/AheSk9PiGoIsSAgKptcYDnMO2L9S UizVDXkl5twfiRo5EbY30CHKHYeH4FxCD+YzVBSCHhv50qO4dpYJsIPCKDtrXR83Q5wWwP ZuyQ+cOOtpnjfdKav1fSQVbOeGCE9XSe77UHnXPJjtbS4OVbpc0srstpenTXsCN///FdR2 eMwFoOwAf5KG3almP27jyS6TWVskYWNfafykxWsr6I5UJJRePTd/r/qGbOIScCZMpykI5s SIPHYvMl71vzBknOib5/0V5MFeG1IhKQF356FOMHaMM2gfjYZtUrNoWsOhcaRA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745345564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9fGuhqWr0PMHCLt8DrjerneIoJL2WCG2CgfQunuyrek=; b=ck+ZYTUjwaVqsPJHD+GHERtGPfrktFqdJb3L0smoUeInJfZHcjV4g0TAaSEQae/0T9iFEl 7Uj8FqRKH/tdimzTySFvis2eP+hZiBGGhxF7m/fBiChxLp+WNwe8jEGhoZbDSwsJWGbJOo vB+N0lDsKy77yuQlxpf1AYBuVv9hfLAkUg8J6x6FFRTJbbw+OA6aNPFv7GV8jEr0HGjZ4f DA4ZgcNBqrKip4zcYCLNGzZSymd3nTdFoqn42UP5WclpRBxT3aCrwdl/TIk01GzfKfjaKB TRn+xS1j07NZjC03UVAGkk805KMA8+D/hIQryCkfxQTn9TYXXR7OFGsdzk3Pbw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4Zhr1m515CzTtr; Tue, 22 Apr 2025 18:12:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53MICitK092879; Tue, 22 Apr 2025 18:12:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53MICiwJ092876; Tue, 22 Apr 2025 18:12:44 GMT (envelope-from git) Date: Tue, 22 Apr 2025 18:12:44 GMT Message-Id: <202504221812.53MICiwJ092876@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: d8e841a9aa1f - main - libc: treat execvpe as a week symbol List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d8e841a9aa1f8c4ce50d98b01f1ba1376cdd9705 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d8e841a9aa1f8c4ce50d98b01f1ba1376cdd9705 commit d8e841a9aa1f8c4ce50d98b01f1ba1376cdd9705 Author: SHENGYI HONG AuthorDate: 2025-04-02 20:35:13 +0000 Commit: Ed Maste CommitDate: 2025-04-22 18:12:26 +0000 libc: treat execvpe as a week symbol Some program intercepts the execvpe call in runtime. At the same time, the implementation of posix_spwan use execvpe. If execvpe is intercepted and then calls posix_spawn when intercepted. It wil create a infinite loop because the intercepted execvpe will spawn a posix_spwan call and will be intercepted again. See https://github.com/rizsotto/Bear/issues/557 for reference. Reviewed by: brooks, kib, emaste Sponsored by: FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49733 --- lib/libc/gen/exec.c | 6 ++++-- lib/libc/gen/posix_spawn.c | 2 +- lib/libc/include/libc_private.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index d9285733e965..926c50d64852 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -136,7 +136,7 @@ execv(const char *name, char * const *argv) int execvp(const char *name, char * const *argv) { - return (execvpe(name, argv, environ)); + return (__libc_execvpe(name, argv, environ)); } static int @@ -288,7 +288,7 @@ execvP(const char *name, const char *path, char * const argv[]) } int -execvpe(const char *name, char * const argv[], char * const envp[]) +__libc_execvpe(const char *name, char * const argv[], char * const envp[]) { const char *path; @@ -298,3 +298,5 @@ execvpe(const char *name, char * const argv[], char * const envp[]) return (execvPe(name, path, argv, envp)); } + +__weak_reference(__libc_execvpe, execvpe); diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index ee2ce05ff317..a5b732696b8c 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -261,7 +261,7 @@ _posix_spawn_thr(void *data) } envp = psa->envp != NULL ? psa->envp : environ; if (psa->use_env_path) - execvpe(psa->path, psa->argv, envp); + __libc_execvpe(psa->path, psa->argv, envp); else _execve(psa->path, psa->argv, envp); psa->error = errno; diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index 4c244f962b2b..41b44456b6ee 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -345,6 +345,7 @@ struct __ucontext; struct __wrusage; enum idtype; +int __libc_execvpe(const char *, char * const *, char * const *); int __libc_sigaction(int, const struct sigaction *, struct sigaction *) __hidden; int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *)