futex_waitv03: fix SIGSEGV in TCONF cleanup
PATCH 1/1 futex_waitv03: fix SIGSEGV in TCONF cleanup
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!
--- testcases/kernel/syscalls/futex/futex_waitv03.c | 5 +++++ 1 file changed, 5 insertions(+)
testcases/kernel/syscalls/futex/futex_waitv03.c +5 -0
@@ -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 ;
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 2 lines
Pushed the two
futex_waitv03related patches, thanks!
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp