* [PATCH 1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero @ 2020-04-04 20:37 Sven Schnelle 2020-04-04 20:37 ` [PATCH 2/2] selftests/vDSO: make vDSO test work on s390x Sven Schnelle 2020-04-28 6:20 ` [PATCH 1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero Sven Schnelle 0 siblings, 2 replies; 4+ messages in thread From: Sven Schnelle @ 2020-04-04 20:37 UTC (permalink / raw) To: Shuah Khan Cc: svens, Thomas Gleixner, Steve Winslow, Alexios Zavras, Allison Randal, linux-kselftest, linux-kernel, Sven Schnelle If vdso_info can't be parsed correctly, vdso_info.nbucket might contain zero. Add a check and return NULL which will fail the symbol lookup. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> --- tools/testing/selftests/vDSO/parse_vdso.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c index 1dbb4b87268f..8e5a70a24d9a 100644 --- a/tools/testing/selftests/vDSO/parse_vdso.c +++ b/tools/testing/selftests/vDSO/parse_vdso.c @@ -226,6 +226,9 @@ void *vdso_sym(const char *version, const char *name) return 0; ver_hash = elf_hash(version); + if (!vdso_info.nbucket) + return NULL; + ELF(Word) chain = vdso_info.bucket[elf_hash(name) % vdso_info.nbucket]; for (; chain != STN_UNDEF; chain = vdso_info.chain[chain]) { -- 2.17.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] selftests/vDSO: make vDSO test work on s390x 2020-04-04 20:37 [PATCH 1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero Sven Schnelle @ 2020-04-04 20:37 ` Sven Schnelle 2020-04-28 6:21 ` Sven Schnelle 2020-04-28 6:20 ` [PATCH 1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero Sven Schnelle 1 sibling, 1 reply; 4+ messages in thread From: Sven Schnelle @ 2020-04-04 20:37 UTC (permalink / raw) To: Shuah Khan Cc: svens, Thomas Gleixner, Steve Winslow, Alexios Zavras, Allison Randal, linux-kselftest, linux-kernel, Sven Schnelle s390x used 8 byte (Elf64_Xword) sized hash table entries. Add some code to the vdso test to handle that properly. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> --- tools/testing/selftests/vDSO/parse_vdso.c | 14 ++++++++++---- tools/testing/selftests/vDSO/vdso_test.c | 11 +++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c index 8e5a70a24d9a..2e1e88ebee3d 100644 --- a/tools/testing/selftests/vDSO/parse_vdso.c +++ b/tools/testing/selftests/vDSO/parse_vdso.c @@ -58,6 +58,12 @@ extern void *vdso_sym(const char *version, const char *name); #define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x) #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x) +#if defined(__s390x__) +#define ELF_HASH_TYPE ELF(Xword) +#else +#define ELF_HASH_TYPE ELF(Word) +#endif + static struct vdso_info { bool valid; @@ -69,8 +75,8 @@ static struct vdso_info /* Symbol table */ ELF(Sym) *symtab; const char *symstrings; - ELF(Word) *bucket, *chain; - ELF(Word) nbucket, nchain; + ELF_HASH_TYPE *bucket, *chain; + ELF_HASH_TYPE nbucket, nchain; /* Version table */ ELF(Versym) *versym; @@ -131,7 +137,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) /* * Fish out the useful bits of the dynamic table. */ - ELF(Word) *hash = 0; + ELF_HASH_TYPE *hash = 0; vdso_info.symstrings = 0; vdso_info.symtab = 0; vdso_info.versym = 0; @@ -149,7 +155,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) + vdso_info.load_offset); break; case DT_HASH: - hash = (ELF(Word) *) + hash = (ELF_HASH_TYPE *) ((uintptr_t)dyn[i].d_un.d_ptr + vdso_info.load_offset); break; diff --git a/tools/testing/selftests/vDSO/vdso_test.c b/tools/testing/selftests/vDSO/vdso_test.c index 719d5a6bd664..2b21261a5eba 100644 --- a/tools/testing/selftests/vDSO/vdso_test.c +++ b/tools/testing/selftests/vDSO/vdso_test.c @@ -22,11 +22,14 @@ extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); extern void vdso_init_from_auxv(void *auxv); /* - * ARM64's vDSO exports its gettimeofday() implementation with a different - * name and version from other architectures, so we need to handle it as - * a special case. + * Both ARM64's and s390x' vDSO exports its gettimeofday() implementation + * with a different name and version from other architectures, so we need + * to handle them as a special case. */ -#if defined(__aarch64__) +#if defined(__s390x__) +const char *version = "LINUX_2.6.29"; +const char *name = "__kernel_gettimeofday"; +#elif defined(__aarch64__) const char *version = "LINUX_2.6.39"; const char *name = "__kernel_gettimeofday"; #else -- 2.17.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] selftests/vDSO: make vDSO test work on s390x 2020-04-04 20:37 ` [PATCH 2/2] selftests/vDSO: make vDSO test work on s390x Sven Schnelle @ 2020-04-28 6:21 ` Sven Schnelle 0 siblings, 0 replies; 4+ messages in thread From: Sven Schnelle @ 2020-04-28 6:21 UTC (permalink / raw) To: Shuah Khan Cc: svens, Thomas Gleixner, Steve Winslow, Alexios Zavras, Allison Randal, linux-kselftest, linux-kernel On Sat, Apr 04, 2020 at 10:37:04PM +0200, Sven Schnelle wrote: > s390x used 8 byte (Elf64_Xword) sized hash table entries. > Add some code to the vdso test to handle that properly. Ping? > Signed-off-by: Sven Schnelle <svens@linux.ibm.com> > --- > tools/testing/selftests/vDSO/parse_vdso.c | 14 ++++++++++---- > tools/testing/selftests/vDSO/vdso_test.c | 11 +++++++---- > 2 files changed, 17 insertions(+), 8 deletions(-) > > diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c > index 8e5a70a24d9a..2e1e88ebee3d 100644 > --- a/tools/testing/selftests/vDSO/parse_vdso.c > +++ b/tools/testing/selftests/vDSO/parse_vdso.c > @@ -58,6 +58,12 @@ extern void *vdso_sym(const char *version, const char *name); > #define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x) > #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x) > > +#if defined(__s390x__) > +#define ELF_HASH_TYPE ELF(Xword) > +#else > +#define ELF_HASH_TYPE ELF(Word) > +#endif > + > static struct vdso_info > { > bool valid; > @@ -69,8 +75,8 @@ static struct vdso_info > /* Symbol table */ > ELF(Sym) *symtab; > const char *symstrings; > - ELF(Word) *bucket, *chain; > - ELF(Word) nbucket, nchain; > + ELF_HASH_TYPE *bucket, *chain; > + ELF_HASH_TYPE nbucket, nchain; > > /* Version table */ > ELF(Versym) *versym; > @@ -131,7 +137,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) > /* > * Fish out the useful bits of the dynamic table. > */ > - ELF(Word) *hash = 0; > + ELF_HASH_TYPE *hash = 0; > vdso_info.symstrings = 0; > vdso_info.symtab = 0; > vdso_info.versym = 0; > @@ -149,7 +155,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) > + vdso_info.load_offset); > break; > case DT_HASH: > - hash = (ELF(Word) *) > + hash = (ELF_HASH_TYPE *) > ((uintptr_t)dyn[i].d_un.d_ptr > + vdso_info.load_offset); > break; > diff --git a/tools/testing/selftests/vDSO/vdso_test.c b/tools/testing/selftests/vDSO/vdso_test.c > index 719d5a6bd664..2b21261a5eba 100644 > --- a/tools/testing/selftests/vDSO/vdso_test.c > +++ b/tools/testing/selftests/vDSO/vdso_test.c > @@ -22,11 +22,14 @@ extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); > extern void vdso_init_from_auxv(void *auxv); > > /* > - * ARM64's vDSO exports its gettimeofday() implementation with a different > - * name and version from other architectures, so we need to handle it as > - * a special case. > + * Both ARM64's and s390x' vDSO exports its gettimeofday() implementation > + * with a different name and version from other architectures, so we need > + * to handle them as a special case. > */ > -#if defined(__aarch64__) > +#if defined(__s390x__) > +const char *version = "LINUX_2.6.29"; > +const char *name = "__kernel_gettimeofday"; > +#elif defined(__aarch64__) > const char *version = "LINUX_2.6.39"; > const char *name = "__kernel_gettimeofday"; > #else > -- > 2.17.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero 2020-04-04 20:37 [PATCH 1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero Sven Schnelle 2020-04-04 20:37 ` [PATCH 2/2] selftests/vDSO: make vDSO test work on s390x Sven Schnelle @ 2020-04-28 6:20 ` Sven Schnelle 1 sibling, 0 replies; 4+ messages in thread From: Sven Schnelle @ 2020-04-28 6:20 UTC (permalink / raw) To: Shuah Khan Cc: svens, Thomas Gleixner, Steve Winslow, Alexios Zavras, Allison Randal, linux-kselftest, linux-kernel On Sat, Apr 04, 2020 at 10:37:03PM +0200, Sven Schnelle wrote: > If vdso_info can't be parsed correctly, vdso_info.nbucket might > contain zero. Add a check and return NULL which will fail the > symbol lookup. Ping? > > Signed-off-by: Sven Schnelle <svens@linux.ibm.com> > --- > tools/testing/selftests/vDSO/parse_vdso.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c > index 1dbb4b87268f..8e5a70a24d9a 100644 > --- a/tools/testing/selftests/vDSO/parse_vdso.c > +++ b/tools/testing/selftests/vDSO/parse_vdso.c > @@ -226,6 +226,9 @@ void *vdso_sym(const char *version, const char *name) > return 0; > > ver_hash = elf_hash(version); > + if (!vdso_info.nbucket) > + return NULL; > + > ELF(Word) chain = vdso_info.bucket[elf_hash(name) % vdso_info.nbucket]; > > for (; chain != STN_UNDEF; chain = vdso_info.chain[chain]) { > -- > 2.17.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-28 6:21 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-04-04 20:37 [PATCH 1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero Sven Schnelle 2020-04-04 20:37 ` [PATCH 2/2] selftests/vDSO: make vDSO test work on s390x Sven Schnelle 2020-04-28 6:21 ` Sven Schnelle 2020-04-28 6:20 ` [PATCH 1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero Sven Schnelle
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox