[LTP] [PATCH] futex_waitv03: fix SIGSEGV in TCONF cleanup
Chunyu Hu
chuhu@redhat.com
Fri Mar 25 02:48:21 CET 2022
When futex_time64 is not supported, TCONF will do the test cleanup
and test quit, in this case, the waitv array and shms are not allocated,
we can get a segment fault if accessing the waitv[*]. Add the flag
to record if the memory allocation is done, so the cleanup can do
correctly in TCONF case.
We can hit the issue on ppc64le:
tst_test.c:1456: TINFO: Timeout per run is 0h 05m 00s
futex_waitv03.c:36: TINFO: Testing variant: syscall with old kernel spec
tst_buffers.c:55: TINFO: Test is using guarded buffers
futex_waitv03.c:108: TPASS: futex_waitv returned correctly
tst_test.c:1456: TINFO: Timeout per run is 0h 05m 00s
futex_waitv03.c:36: TINFO: Testing variant: syscall time64 with kernel spec
../../../../include/tst_timer.h:271: TCONF: syscall(422) __NR_futex_time64 not supported on your arch
tst_test.c:1512: TBROK: Test killed by SIGSEGV!
Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
testcases/kernel/syscalls/futex/futex_waitv03.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/testcases/kernel/syscalls/futex/futex_waitv03.c b/testcases/kernel/syscalls/futex/futex_waitv03.c
index 1f53addac..ffe5c66cd 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv03.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv03.c
@@ -26,6 +26,7 @@ static char *str_numfutex;
static int numfutex = 30;
static struct futex_waitv *waitv;
+static unsigned int waitv_allocated;
static int *shmids;
static void setup(void)
@@ -50,12 +51,16 @@ static void setup(void)
waitv[i].flags = FUTEX_32;
waitv[i].val = 0;
}
+ waitv_allocated = tst_variant + 1;
}
static void cleanup(void)
{
int i;
+ if (waitv_allocated != (tst_variant + 1))
+ return;
+
for (i = 0; i < numfutex; i++) {
if (!waitv[i].uaddr)
continue;
--
2.35.1
More information about the ltp
mailing list