Date: Sun, 2 Jan 2022 19:08:11 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: d00ebd9b9c4e - stable/13 - Pass vdso address to userspace Message-ID: <202201021908.202J8BFO057741@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d00ebd9b9c4e2532a6b714b2576afdb94ca0bb3e commit d00ebd9b9c4e2532a6b714b2576afdb94ca0bb3e Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-11-11 17:29:24 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> 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",
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201021908.202J8BFO057741>