From nobody Wed Apr 26 13:59:00 2023 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 4Q60pY1TpPz46YG0; Wed, 26 Apr 2023 13:59:01 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q60pY0mp1z4JcV; Wed, 26 Apr 2023 13:59:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682517541; 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=bVQENq6gkyTUQnWLfhH3NWKqynRUj8AlvkCLI76eur0=; b=MY+2FmmBUSkYJ7YXkRQ4E5kE36teTxJExeNiZU9QOMM4IfZX+hQjOEwuHNB+rMmvOx60aY RTXAIXuqtM1s+BLRedQxHXvz7pAC6EeIvamaQ0Wg6IVoRsIDp14ljfVzb/A9dld7y1DZN/ aAbjdiogxg32voE2tJBIGG9Krs7K/4CPP4QoYR/2k5cXvK4L+t9xcRBNTxds4+VXhFscO8 xYeXTlhBuLag7h/jZhDnwMpXToiyq5r5PnPzr34edeQ0OD9xXN3JTnohlNiE8F08tnsJMH 7XHXNzOndxoCoNxuWzOnC5AVM6IWBxcSQ/+QoWefVLUDpc5cFMooXcNhP7cI3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682517541; 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=bVQENq6gkyTUQnWLfhH3NWKqynRUj8AlvkCLI76eur0=; b=P+LgoqaPa9u/n/DIr38zyZmtoCCKWYgaD1CfQxKafpFXQwUpFRACtERADk7KfVyajFRDqz PlvDf9x82IpGHaDIqM8Mp0TQ7ZFLjJpJo3k/iVVJRwR7rype5PkBpzarubyy8UN+eOR3Kw pA7lubtKZs4EIdK/uiwG3P73bLeWy7BqWgccBqUxKdM4n/ZPDoaO3YstGEtpZdj6IFwb58 O0dUl+wUfxfAsc+Xyv1S8s/7rnufk7SVcvo5KEEPE2xeUt5fb4MTSqP1QjXMQS9YzGINg9 QcqN/C8jQcfQeegGDxL+lPavfmpOQ9QZKDVtubz97pK/D6v4F19Fuh6UUvZcvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682517541; a=rsa-sha256; cv=none; b=hIIeYEliaZkBeX1BTtHg4RuIhGIBON5+jQ4z01ayiK9kT699xfjUp/PBWpU3JlqpQO5FLT FPSL9UfPsmLKVqMxTtJc/3Tz7+nTK73zti61l3LVciNsNJDjicc0KTVS9PwS4W1q+XIoMk If9rTEJZoOowr1RGISviGoht4RVuZvvI7jntPRsWMlR/BtMdUjStR/30zAjiI2y2rvH415 B8x/MWAIjd2u+toLaqwfbcstADlvOBjgu7r/JZkR5/Mnn/j20tR/sbz0e8GPV+ecumXAhY 591E3dWh7TB9jXdQPbMviFV/IG5N1qHgo3M3h/5TtUmM3LHldJbGnyu6a+4uvg== 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 4Q60pX6ycBzcPl; Wed, 26 Apr 2023 13:59:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33QDx0OB053704; Wed, 26 Apr 2023 13:59:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33QDx0Po053703; Wed, 26 Apr 2023 13:59:00 GMT (envelope-from git) Date: Wed, 26 Apr 2023 13:59:00 GMT Message-Id: <202304261359.33QDx0Po053703@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 76f8584e49cf - main - linux(4): Don't relie on process osreldata when testing features 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 76f8584e49cf7eedaa2e1312593bf46c7225d79a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=76f8584e49cf7eedaa2e1312593bf46c7225d79a commit 76f8584e49cf7eedaa2e1312593bf46c7225d79a Author: Dmitry Chagin AuthorDate: 2023-04-26 13:56:41 +0000 Commit: Dmitry Chagin 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)