From nobody Mon Dec 06 18:48:19 2021 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 5CA1918B583F; Mon, 6 Dec 2021 18:48:21 +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 4J7C9w5KVNz4SWm; Mon, 6 Dec 2021 18:48:20 +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 EBEF7112D7; Mon, 6 Dec 2021 18:48:19 +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 1B6ImJXm065110; Mon, 6 Dec 2021 18:48:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B6ImJ7l065109; Mon, 6 Dec 2021 18:48:19 GMT (envelope-from git) Date: Mon, 6 Dec 2021 18:48:19 GMT Message-Id: <202112061848.1B6ImJ7l065109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 01c77a436e35 - main - Pass vdso address to userspace 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 01c77a436e35d6dc9660ec7bac477946f563c99d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638816500; 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=gga5lCB+p/9GswSjoLYbPLWccCqhi4tLGG+cV2X0qpI=; b=HYpkKbo0Y+9ivm4tfURKsb77JFq3Woxyy2Nd3hgOzwSqfSpL5hUM9KV66SLWJPbZDwivwr ePCIBTK17iOt5IgkiBM67kM7dKKJkYFioa2PDi90yQasqz/Boulnu270Itl2rMyCR5zczn QnCQOTsgbtuzi4O6WN1Id9bIsL97QaTHy4Fsw6DmEpHt7JWp6KKom2/BfnlwFIAiGfvXUC wr/BbWrow+npYXOAhC8K60yp21aW2767Czq8urqE4nPydFLi1KBOiCuPtkmOyye1aIdOHj Jw2LHMpNHYpgZOwVvZYy7i5LCdEne2T3kAEpa7adjCKcoDCI1wDEuNfQDQlf0g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638816501; a=rsa-sha256; cv=none; b=aTRNc9a7lTKMGLh4BT//jBTc48iN6wnb1aUJuWgtlG0eK8348aTBiC+5jfrnvuFtBSCTCg 627vEdkNExuTO0DA38AmvjfAMrX0tU8LsBTtOafKFGEJ7Hh1KFQNvWu2k5zjhJlwWSwfxl W6hwjM1Gryg9jVg+/qWuJVemYO5GPS4ax7UlycOIAlhIJQ3V71/AYd83yBc39qiVEgDpA3 O+//qh3xpU+SDS14h5h0QOQXf4LT4u80qgG7ROVq22YLH3eLItC8CfwBkfxOeERbmEd833 i/+9OeWWFFHKYY6U0B12iNY7pXHcgsgRjDjnoULo7p6JsCJj0QTIEl5XqbkcZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=01c77a436e35d6dc9660ec7bac477946f563c99d commit 01c77a436e35d6dc9660ec7bac477946f563c99d Author: Konstantin Belousov AuthorDate: 2021-11-11 17:29:24 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-06 18:46:49 +0000 Pass vdso address to userspace Reviewed by: emaste Discussed with: jrtc27 Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D32960 --- libexec/rtld-elf/rtld.c | 1 + sys/kern/imgact_elf.c | 2 ++ sys/kern/kern_sharedpage.c | 7 +++++++ sys/sys/elf_common.h | 3 ++- sys/sys/sysent.h | 1 + usr.bin/procstat/procstat_auxv.c | 6 ++++++ 6 files changed, 19 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 7e970c0215b6..4c9a7a40b3b5 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1414,6 +1414,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..9b36676decd5 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 { @@ -386,12 +387,18 @@ exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2) MPASS((sv2->sv_flags & SV_ABI_MASK) == (sv->sv_flags & SV_ABI_MASK)); MPASS((sv2->sv_flags & SV_TIMEKEEP) == (sv->sv_flags & SV_TIMEKEEP)); MPASS((sv2->sv_flags & SV_SHP) != 0 && (sv->sv_flags & SV_SHP) != 0); + MPASS((sv2->sv_flags & SV_DSO_SIG) != 0 && + (sv->sv_flags & SV_DSO_SIG) != 0); MPASS((sv2->sv_flags & SV_RNG_SEED_VER) == (sv->sv_flags & SV_RNG_SEED_VER)); 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 e8eda4d91260..de09a2172f81 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 81bd1db108f9..84269f233a3a 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -144,6 +144,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",