Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Apr 2023 13:59:00 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 76f8584e49cf - main - linux(4): Don't relie on process osreldata when testing features
Message-ID:  <202304261359.33QDx0Po053703@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=76f8584e49cf7eedaa2e1312593bf46c7225d79a

commit 76f8584e49cf7eedaa2e1312593bf46c7225d79a
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-04-26 13:56:41 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-04-26 13:56:41 +0000

    linux(4): Don't relie on process osreldata when testing features
    
    The ELF note identifyies the operating-system ABI that the executable
    was created for. The note data of the Glibc executable contains the
    earliest release number of the Linux kernel that supports this ABI.
    As of a current 2.37 version of Glibc, it is 3.2.0 for x86, 3.7.0
    for Aarch64.
    Glibc does not use this release number and the current kernel's
    LINUX_VERSION_CODE to detect kernel features, using fallbacks to known
    previous way in case of ENOSYS or something else instead.
    
    A dynamically linked Glibc reads the current kernel's LINUX_VERSION_CODE
    from the ELF note in the vDSO or fallback to uname syscall if the vDSO
    can't be located and parse the release field in struct utsname. Glibc
    uses the current kernel's LINUX_VERSION_CODE for "kernel too old" check.
    
    While here use inlined LINUX_KERNVER for tests to improve readability,
    as suggested by emaste@.
    
    MFC after:              1 month
---
 sys/compat/linux/linux_elf.c | 8 ++++----
 sys/compat/linux/linux_mib.h | 3 ---
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/sys/compat/linux/linux_elf.c b/sys/compat/linux/linux_elf.c
index f335f18e252f..1af861122f81 100644
--- a/sys/compat/linux/linux_elf.c
+++ b/sys/compat/linux/linux_elf.c
@@ -492,6 +492,7 @@ linux_trans_osrel(const Elf_Note *note, int32_t *osrel)
 int
 __linuxN(copyout_auxargs)(struct image_params *imgp, uintptr_t base)
 {
+	struct thread *td = curthread;
 	Elf_Auxargs *args;
 	Elf_Auxinfo *aarray, *pos;
 	struct proc *p;
@@ -526,14 +527,13 @@ __linuxN(copyout_auxargs)(struct image_params *imgp, uintptr_t base)
 	AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
 	AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
 	AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
-	if (p->p_osrel >= LINUX_KERNVER_2006030 || p->p_osrel == 0)
+	if (linux_kernver(td) >= LINUX_KERNVER(2,6,30))
 		AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
-	if ((p->p_osrel >= LINUX_KERNVER_2006026 || p->p_osrel == 0) &&
-	    imgp->execpathp != 0)
+	if (linux_kernver(td) >= LINUX_KERNVER(2,6,26) && imgp->execpathp != 0)
 		AUXARGS_ENTRY(pos, LINUX_AT_EXECFN, PTROUT(imgp->execpathp));
 	if (args->execfd != -1)
 		AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
-	if (p->p_osrel >= LINUX_KERNVER_5013000 || p->p_osrel == 0)
+	if (linux_kernver(td) >= LINUX_KERNVER(5,13,0))
 		AUXARGS_ENTRY(pos, LINUX_AT_MINSIGSTKSZ,
 		    imgp->sysent->sv_minsigstksz);
 	AUXARGS_ENTRY(pos, AT_NULL, 0);
diff --git a/sys/compat/linux/linux_mib.h b/sys/compat/linux/linux_mib.h
index 41b53d40da3a..7022d811959b 100644
--- a/sys/compat/linux/linux_mib.h
+++ b/sys/compat/linux/linux_mib.h
@@ -58,11 +58,8 @@ 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)
-#define	LINUX_KERNVER_5013000	LINUX_KERNVER(5,13,0)
 
 #define	linux_use54(t)		(linux_kernver(t) >= LINUX_KERNVER_5004000)
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304261359.33QDx0Po053703>