Package: stress-ng Version: 0.15.07-1 Severity: serious Tags: patch Justification: autopkgtest failures User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu mantic ubuntu-patch X-Debbugs-Cc: bdr...@debian.org
Dear Maintainer, The autopkg tests on 32 bit architectures fail. In Ubuntu, the attached patch was applied to fix the autopkgtest: * Cherry-pick upstream commit "stress-pthread: use 64 bit tid_addr to fix stack clobbering on 32 bit platforms" and "stress-pthread: fix big endian tid addr for 32 bit systems" to fix test failures on 32 bit architectures (LP: #2019079) Thanks for considering the patch. -- Benjamin Drung Debian & Ubuntu Developer
diff -Nru stress-ng-0.15.07/debian/patches/series stress-ng-0.15.07/debian/patches/series --- stress-ng-0.15.07/debian/patches/series 1970-01-01 01:00:00.000000000 +0100 +++ stress-ng-0.15.07/debian/patches/series 2023-05-17 18:45:53.000000000 +0200 @@ -0,0 +1,2 @@ +stress-pthread_use_64_bit_tid_addr.patch +stress-pthread_fix_big_endian_tid_addr_for_32_bit_systems.patch diff -Nru stress-ng-0.15.07/debian/patches/stress-pthread_fix_big_endian_tid_addr_for_32_bit_systems.patch stress-ng-0.15.07/debian/patches/stress-pthread_fix_big_endian_tid_addr_for_32_bit_systems.patch --- stress-ng-0.15.07/debian/patches/stress-pthread_fix_big_endian_tid_addr_for_32_bit_systems.patch 1970-01-01 01:00:00.000000000 +0100 +++ stress-ng-0.15.07/debian/patches/stress-pthread_fix_big_endian_tid_addr_for_32_bit_systems.patch 2023-05-17 18:45:53.000000000 +0200 @@ -0,0 +1,46 @@ +From 63c0b414f6ec70dbd0498d59ca34fffbf2642b61 Mon Sep 17 00:00:00 2001 +From: Colin Ian King <colin.i.k...@gmail.com> +Date: Wed, 10 May 2023 20:39:13 +0100 +Subject: [PATCH] stress-pthread: fix big endian tid addr for 32 bit systems + +The PR_GET_TID_ADDR does not have 32 bit compat, so it always returns +a 64 bit tid addr. For 32 bit systems this needs to be either truncated +for 32 little endian or shifted down to the bottom 32 bits for big endian +systems such as big endian HPPA or MIPS32. + +Signed-off-by: Colin Ian King <colin.i.k...@gmail.com> +Origin: upstream, https://github.com/ColinIanKing/stress-ng/commit/63c0b414f6ec70dbd0498d59ca34fffbf2642b61 +--- + stress-pthread.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/stress-pthread.c b/stress-pthread.c +index 5c0ee9e4..2190c333 100644 +--- a/stress-pthread.c ++++ b/stress-pthread.c +@@ -177,14 +177,23 @@ static void OPTIMIZE3 stress_pthread_tid_address(const stress_args_t *args) + uint64_t tid_addr = 0; + + if (LIKELY(prctl(PR_GET_TID_ADDRESS, &tid_addr, 0, 0, 0) == 0)) { +- if (tid_addr) { ++ unsigned long set_tid_addr; ++ ++ if (sizeof(void *) == 4) { ++ set_tid_addr = stress_little_endian() ? ++ (tid_addr & 0xffffffff) : (tid_addr >> 32); ++ } else { ++ set_tid_addr = (unsigned long)tid_addr; ++ } ++ ++ if (set_tid_addr) { + pid_t tid1, tid2; + + /* Nullify */ + VOID_RET(pid_t, (pid_t)syscall(__NR_set_tid_address, NULL)); + + /* This always succeeds */ +- tid1 = (pid_t)syscall(__NR_set_tid_address, tid_addr); ++ tid1 = (pid_t)syscall(__NR_set_tid_address, set_tid_addr); + + errno = 0; + tid2 = shim_gettid(); diff -Nru stress-ng-0.15.07/debian/patches/stress-pthread_use_64_bit_tid_addr.patch stress-ng-0.15.07/debian/patches/stress-pthread_use_64_bit_tid_addr.patch --- stress-ng-0.15.07/debian/patches/stress-pthread_use_64_bit_tid_addr.patch 1970-01-01 01:00:00.000000000 +0100 +++ stress-ng-0.15.07/debian/patches/stress-pthread_use_64_bit_tid_addr.patch 2023-05-17 16:07:26.000000000 +0200 @@ -0,0 +1,37 @@ +From 637662d92865fbf5f3469d7754584f6d810fb902 Mon Sep 17 00:00:00 2001 +From: Colin Ian King <colin.i.k...@gmail.com> +Date: Wed, 19 Apr 2023 08:46:17 +0100 +Subject: [PATCH] stress-pthread: use 64 bit tid_addr to fix stack clobbering + on 32 bit platforms + +Closes: https://github.com/ColinIanKing/stress-ng/issues/283 + +Signed-off-by: Colin Ian King <colin.i.k...@gmail.com> +Origin: upstream, https://github.com/ColinIanKing/stress-ng/commit/637662d92865fbf5f3469d7754584f6d810fb902 +--- + stress-pthread.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/stress-pthread.c b/stress-pthread.c +index 24431869b..a568f8167 100644 +--- a/stress-pthread.c ++++ b/stress-pthread.c +@@ -163,7 +163,17 @@ static void OPTIMIZE3 stress_pthread_tid_address(const stress_args_t *args) + defined(__NR_set_tid_address) && \ + defined(HAVE_KERNEL_ULONG_T) && \ + defined(HAVE_SYSCALL) +- __kernel_ulong_t tid_addr = 0; ++ /* ++ * prctl(2) states: ++ * "Note that since the prctl() system call does not have a compat ++ * implementation for the AMD64 x32 and MIPS n32 ABIs, and ++ * the kernel writes out a pointer using the kernel's pointer ++ * size, this operation expects a user-space buffer of 8 (not ++ * 4) bytes on these ABIs." ++ * ++ * Use 64 bit tid_addr as default. ++ */ ++ uint64_t tid_addr = 0; + + if (LIKELY(prctl(PR_GET_TID_ADDRESS, &tid_addr, 0, 0, 0) == 0)) { + if (tid_addr) {