git: 38595c9d739b - stable/14 - linux_pwd_onexec: do not abort image activation if emul path does not exist

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 29 Feb 2024 00:24:32 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=38595c9d739bf69ff1270e575b1cbdcfe47284a7

commit 38595c9d739bf69ff1270e575b1cbdcfe47284a7
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-02-10 05:02:18 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-02-29 00:24:06 +0000

    linux_pwd_onexec: do not abort image activation if emul path does not exist
    
    (cherry picked from commit 99fa799a19abeb70b1034f65407c276b64709bdc)
---
 sys/compat/linux/linux_util.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c
index 020eb57ea68e..e0c010cb5e48 100644
--- a/sys/compat/linux/linux_util.c
+++ b/sys/compat/linux/linux_util.c
@@ -79,22 +79,14 @@ int
 linux_pwd_onexec(struct thread *td)
 {
 	struct nameidata nd;
-	struct pwd *pwd;
 	int error;
 
 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path);
 	error = namei(&nd);
 	if (error != 0) {
-		/*
-		 * Do not bother if we are in chroot or jail.
-		 */
-		pwd = pwd_hold(td);
-		if (pwd->pwd_rdir != rootvnode) {
-			pwd_drop(pwd);
-			return (0);
-		}
-		pwd_drop(pwd);
-		return (error);
+		/* Do not prevent execution if altroot is non-existent. */
+		pwd_altroot(td, NULL);
+		return (0);
 	}
 	NDFREE_PNBUF(&nd);
 	pwd_altroot(td, nd.ni_vp);