git: 364bdf887ae3 - stable/13 - linux(4): Export the AT_EXECFN depending on the process osreldata

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Thu, 29 Jun 2023 08:20:06 UTC
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=364bdf887ae3d9298834038b1a755e4c27719888

commit 364bdf887ae3d9298834038b1a755e4c27719888
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-04-22 19:17:36 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-06-29 08:15:27 +0000

    linux(4): Export the AT_EXECFN depending on the process osreldata
    
    AT_EXECFN has appeared in the 2.6.26 Linux kernel first time.
    
    Reviewed by:            emaste
    Differential Revision:  https://reviews.freebsd.org/D39647
    MFC after:              1 month
    
    (cherry picked from commit 70eab81d6ffecf0ba4c7f19a8b6389178eda5259)
---
 sys/compat/linux/linux_elf.c | 3 ++-
 sys/compat/linux/linux_mib.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linux/linux_elf.c b/sys/compat/linux/linux_elf.c
index d0e547c1b882..a1a04e23d43d 100644
--- a/sys/compat/linux/linux_elf.c
+++ b/sys/compat/linux/linux_elf.c
@@ -528,7 +528,8 @@ __linuxN(copyout_auxargs)(struct image_params *imgp, uintptr_t base)
 	AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
 	if (p->p_osrel >= LINUX_KERNVER_2006030 || p->p_osrel == 0)
 		AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
-	if (imgp->execpathp != 0)
+	if ((p->p_osrel >= LINUX_KERNVER_2006026 || p->p_osrel == 0) &&
+	    imgp->execpathp != 0)
 		AUXARGS_ENTRY(pos, LINUX_AT_EXECFN, PTROUT(imgp->execpathp));
 	if (args->execfd != -1)
 		AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
diff --git a/sys/compat/linux/linux_mib.h b/sys/compat/linux/linux_mib.h
index b1d5a0981a7d..05068bbf1029 100644
--- a/sys/compat/linux/linux_mib.h
+++ b/sys/compat/linux/linux_mib.h
@@ -58,6 +58,7 @@ int	linux_kernver(struct thread *td);
 #define	LINUX_VERSION_STR	LINUX_XKERNVERSTR(LINUX_KVERSION.LINUX_KPATCHLEVEL.LINUX_KSUBLEVEL)
 
 #define	LINUX_KERNVER_2004000	LINUX_KERNVER(2,4,0)
+#define	LINUX_KERNVER_2006026	LINUX_KERNVER(2,6,26)
 #define	LINUX_KERNVER_2006030	LINUX_KERNVER(2,6,30)
 #define	LINUX_KERNVER_2006039	LINUX_KERNVER(2,6,39)
 #define	LINUX_KERNVER_5004000	LINUX_KERNVER(5,4,0)