Skip to content

Commit a22ee38

Browse files
t-8chVasily Gorbik
authored andcommitted
selftests/vDSO: Fix GNU hash table entry size for s390x
Commit 14be4e6 ("selftests: vDSO: fix ELF hash table entry size for s390x") changed the type of the ELF hash table entries to 64bit on s390x. However the *GNU* hash tables entries are always 32bit. The "bucket" pointer is shared between both hash algorithms. On s390, this caused the GNU hash algorithm to access its 32-bit entries as if they were 64-bit, triggering compiler warnings (assignment between "Elf64_Xword *" and "Elf64_Word *") and runtime crashes. Introduce a new dedicated "gnu_bucket" pointer which is used by the GNU hash. Fixes: e0746bd ("selftests/vDSO: support DT_GNU_HASH") Reviewed-by: Jens Remus <jremus@linux.ibm.com> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Shuah Khan <skhan@linuxfoundation.org> Link: https://lore.kernel.org/r/20250217-selftests-vdso-s390-gnu-hash-v2-1-f6c2532ffe2a@linutronix.de Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 5623bc2 commit a22ee38

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/testing/selftests/vDSO/parse_vdso.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static struct vdso_info
5353
/* Symbol table */
5454
ELF(Sym) *symtab;
5555
const char *symstrings;
56-
ELF(Word) *gnu_hash;
56+
ELF(Word) *gnu_hash, *gnu_bucket;
5757
ELF_HASH_ENTRY *bucket, *chain;
5858
ELF_HASH_ENTRY nbucket, nchain;
5959

@@ -185,8 +185,8 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)
185185
/* The bucket array is located after the header (4 uint32) and the bloom
186186
* filter (size_t array of gnu_hash[2] elements).
187187
*/
188-
vdso_info.bucket = vdso_info.gnu_hash + 4 +
189-
sizeof(size_t) / 4 * vdso_info.gnu_hash[2];
188+
vdso_info.gnu_bucket = vdso_info.gnu_hash + 4 +
189+
sizeof(size_t) / 4 * vdso_info.gnu_hash[2];
190190
} else {
191191
vdso_info.nbucket = hash[0];
192192
vdso_info.nchain = hash[1];
@@ -268,11 +268,11 @@ void *vdso_sym(const char *version, const char *name)
268268
if (vdso_info.gnu_hash) {
269269
uint32_t h1 = gnu_hash(name), h2, *hashval;
270270

271-
i = vdso_info.bucket[h1 % vdso_info.nbucket];
271+
i = vdso_info.gnu_bucket[h1 % vdso_info.nbucket];
272272
if (i == 0)
273273
return 0;
274274
h1 |= 1;
275-
hashval = vdso_info.bucket + vdso_info.nbucket +
275+
hashval = vdso_info.gnu_bucket + vdso_info.nbucket +
276276
(i - vdso_info.gnu_hash[1]);
277277
for (;; i++) {
278278
ELF(Sym) *sym = &vdso_info.symtab[i];

0 commit comments

Comments
 (0)