From nobody Sun Jan 02 19:08:11 2022 X-Original-To: dev-commits-src-branches@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 733FA191F50F; Sun, 2 Jan 2022 19:08:13 +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 4JRpLN4WmWz4XrL; Sun, 2 Jan 2022 19:08:12 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 06C451763C; Sun, 2 Jan 2022 19:08:12 +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 202J8BJn057742; Sun, 2 Jan 2022 19:08:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 202J8BFO057741; Sun, 2 Jan 2022 19:08:11 GMT (envelope-from git) Date: Sun, 2 Jan 2022 19:08:11 GMT Message-Id: <202201021908.202J8BFO057741@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: d00ebd9b9c4e - stable/13 - Pass vdso address to userspace List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d00ebd9b9c4e2532a6b714b2576afdb94ca0bb3e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641150492; 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=FtZqJmxa/knZrHjHoDbL5egMq/idqjM7KupzJC8PfpE=; b=KBmIhoe7oUUf5vTrWysVXiWfvKwq2yRqFD0Ol2FX1Si8oEbbtoZgb+7djZFTZbhNFeghNH ot124X2jKWTRLGaCdN6mLKeJAOC+SRiCheNWsAIQMQlYJrB3HmNIDmk0NZSonEBznE1AhQ /OIpN7HL9NVEJtSoHaEpTn0WlnJVhOwJZVjGcR2Hd1GR7B0UNuLql+H0naoPbuSHC0uR9d Ujgsn+lfkyoXCgNNBTgiWKWh99ncOWHt9NpuC1ORBFO9aJrTfNzKpG5KSn0fRAGkwG77be rSu9KYXx0zqFGglMVvp3DR0vNEBI52/YyVUHd3q06xwEf9xDqJ7tY/kuWVLpog== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641150492; a=rsa-sha256; cv=none; b=rAF0FFQXiQdRw0xGTGFCXh4PmSDxDK1L3FbSgwHmX652xnPqvpM3YLRrQ6EIBQYNdC33Ie BG1MpLBTlfYAhuKf+syfawpE6/TnFtCIm67mUz92IJPQpg1Ir3PQIbg4hVRsdBouRO3piz xGzWVRhyXIlzb+Ym0xOuIjl9T6p48uoImQCXG6WpuUPvfY1Mc5rONsytUonlR3n9QdFe4H EUPWJwI8zdbmbfuVQL/ybBKHMT8z6b+2yGqQbhTYbz/DQgrNXob9FO1m9GP1lobO0GKa4Y O8yyTe1mrFNUKAsTbZKPeQNOS41T4Qf/klRO2dNhb2Nn5KGtRuGmMfuLjKbJ1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d00ebd9b9c4e2532a6b714b2576afdb94ca0bb3e commit d00ebd9b9c4e2532a6b714b2576afdb94ca0bb3e Author: Konstantin Belousov AuthorDate: 2021-11-11 17:29:24 +0000 Commit: Konstantin Belousov CommitDate: 2022-01-02 16:43:01 +0000 Pass vdso address to userspace (cherry picked from commit 01c77a436e35d6dc9660ec7bac477946f563c99d) --- libexec/rtld-elf/rtld.c | 1 + sys/kern/imgact_elf.c | 2 ++ sys/kern/kern_sharedpage.c | 5 +++++ sys/sys/elf_common.h | 3 ++- sys/sys/sysent.h | 1 + usr.bin/procstat/procstat_auxv.c | 6 ++++++ 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index d5c3d2893582..af29d3ead390 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -6103,6 +6103,7 @@ static const struct auxfmt { AUXFMT(AT_ENVV, "%p"), AUXFMT(AT_PS_STRINGS, "%p"), AUXFMT(AT_FXRNG, "%p"), + AUXFMT(AT_KPRELOAD, "%p"), }; static bool diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 102863026a9a..c01b9eb7b8a4 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1452,6 +1452,8 @@ __elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t base) AUXARGS_ENTRY_PTR(pos, AT_PS_STRINGS, imgp->ps_strings); if (imgp->sysent->sv_fxrng_gen_base != 0) AUXARGS_ENTRY(pos, AT_FXRNG, imgp->sysent->sv_fxrng_gen_base); + if (imgp->sysent->sv_vdso_base != 0) + AUXARGS_ENTRY(pos, AT_KPRELOAD, imgp->sysent->sv_vdso_base); AUXARGS_ENTRY(pos, AT_NULL, 0); free(imgp->auxargs, M_TEMP); diff --git a/sys/kern/kern_sharedpage.c b/sys/kern/kern_sharedpage.c index 98f7b619e0b7..411965180fcb 100644 --- a/sys/kern/kern_sharedpage.c +++ b/sys/kern/kern_sharedpage.c @@ -328,6 +328,7 @@ exec_sysvec_init(void *param) if (res == -1) panic("copying sigtramp to shared page"); sb += res; + sv->sv_vdso_base = sb; sb += sv->sv_sigcodeoff; sv->sv_sigcode_base = sb; } else { @@ -392,6 +393,10 @@ exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2) sv2->sv_shared_page_obj = sv->sv_shared_page_obj; sv2->sv_sigcode_base = sv2->sv_shared_page_base + (sv->sv_sigcode_base - sv->sv_shared_page_base); + if ((sv2->sv_flags & SV_DSO_SIG) != 0) { + sv2->sv_vdso_base = sv2->sv_shared_page_base + + (sv->sv_vdso_base - sv->sv_shared_page_base); + } if ((sv2->sv_flags & SV_ABI_MASK) != SV_ABI_FREEBSD) return; if ((sv2->sv_flags & SV_TIMEKEEP) != 0) { diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index 3243a8aca13c..f65c64af30ff 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -981,8 +981,9 @@ typedef struct { #define AT_ENVV 31 /* Environment vector */ #define AT_PS_STRINGS 32 /* struct ps_strings */ #define AT_FXRNG 33 /* Pointer to root RNG seed version. */ +#define AT_KPRELOAD 34 /* Base of vdso, preloaded by rtld */ -#define AT_COUNT 34 /* Count of defined aux entry types. */ +#define AT_COUNT 35 /* Count of defined aux entry types. */ /* * Relocation types. diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index cc3f183ff7cd..4296b47182a2 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -139,6 +139,7 @@ struct sysentvec { vm_offset_t sv_shared_page_len; vm_offset_t sv_sigcode_base; void *sv_shared_page_obj; + vm_offset_t sv_vdso_base; void (*sv_schedtail)(struct thread *); void (*sv_thread_detach)(struct thread *); int (*sv_trap)(struct thread *); diff --git a/usr.bin/procstat/procstat_auxv.c b/usr.bin/procstat/procstat_auxv.c index f868b7ed2381..d62ed6028569 100644 --- a/usr.bin/procstat/procstat_auxv.c +++ b/usr.bin/procstat/procstat_auxv.c @@ -239,6 +239,12 @@ procstat_auxv(struct procstat *procstat, struct kinfo_proc *kipp) xo_emit("{dw:/%s}{Lw:/%-16s/%s}{:AT_FXRNG/%p}\n", prefix, "AT_FXRNG", auxv[i].a_un.a_ptr); break; +#endif +#ifdef AT_KPRELOAD + case AT_KPRELOAD: + xo_emit("{dw:/%s}{Lw:/%-16s/%s}{:AT_KPRELOAD/%p}\n", + prefix, "AT_KPRELOAD", auxv[i].a_un.a_ptr); + break; #endif default: xo_emit("{dw:/%s}{Lw:/%16ld/%ld}{:UNKNOWN/%#lx}\n",