All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] futex_waitv03: fix SIGSEGV in TCONF cleanup
@ 2022-03-25  1:48 Chunyu Hu
  2022-03-25  7:40 ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Chunyu Hu @ 2022-03-25  1:48 UTC (permalink / raw)
  To: ltp

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] futex_waitv03: fix SIGSEGV in TCONF cleanup
  2022-03-25  1:48 [LTP] [PATCH] futex_waitv03: fix SIGSEGV in TCONF cleanup Chunyu Hu
@ 2022-03-25  7:40 ` Li Wang
  2022-03-29  4:54   ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2022-03-25  7:40 UTC (permalink / raw)
  To: Chunyu Hu; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 64 bytes --]

Reviewed-by: Li Wang <liwang@redhat.com>


-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 401 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] futex_waitv03: fix SIGSEGV in TCONF cleanup
  2022-03-25  7:40 ` Li Wang
@ 2022-03-29  4:54   ` Li Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Li Wang @ 2022-03-29  4:54 UTC (permalink / raw)
  To: Chunyu Hu; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 80 bytes --]

>
> Pushed the two futex_waitv03 related patches, thanks!

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 475 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-29  4:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25  1:48 [LTP] [PATCH] futex_waitv03: fix SIGSEGV in TCONF cleanup Chunyu Hu
2022-03-25  7:40 ` Li Wang
2022-03-29  4:54   ` Li Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.