signal: add new testcase signal06.c
PATCH v2 1/1 signal: add new testcase signal06.c
v1 --> v2
1. define LOOPS as 10000
2. use -pthread in Makefile
3. add volatile to FLAGE
4. include linux_syscall_numbers.h
5. use __NR_tkill and SIGHUP
6. use tst_exit() and TEST()
the comments from Oleg's patch:
save_xstate_sig()->drop_init_fpu() doesn't look right. setup_rt_frame() can fail after that, in this case the next setup_rt_frame() triggered by SIGSEGV won't save fpu simply because the old state was lost. This obviously mean that fpu won't be restored after sys_rt_sigreturn() from SIGSEGV handler.
this issue was fixed on kernel v3.17-rc3-3:
commit df24fb859a4e200d9324e2974229fbb7adf00aef
Author: Oleg Nesterov <[email protected]>
Date: Tue Sep 2 19:57:17 2014 +0200
commit 66463db4fc5605d51c7bb81d009d5bf30a783a2c
Author: Oleg Nesterov <[email protected]>
Date: Tue Sep 2 19:57:13 2014 +0200--- runtest/ltplite | 1 + runtest/stress.part3 | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/signal/Makefile | 2 + testcases/kernel/syscalls/signal/signal06.c | 156 ++++++++++++++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 testcases/kernel/syscalls/signal/signal06.c
runtest/ltplite +1 -0
@@ -840,6 +840,7 @@ signal02 signal02 signal03 signal03 signal04 signal04 signal05 signal05 +signal06 signal06 sigpending02 sigpending02
runtest/stress.part3 +1 -0
@@ -744,6 +744,7 @@ signal02 signal02 signal03 signal03 signal04 signal04 signal05 signal05 +signal06 signal06 sigpending02 sigpending02
runtest/syscalls +1 -0
@@ -1143,6 +1143,7 @@ signal02 signal02 signal03 signal03 signal04 signal04 signal05 signal05 +signal06 signal06 signalfd01 signalfd01
testcases/kernel/syscalls/signal/Makefile +2 -0
@@ -21,3 +21,5 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk + +signal06: CFLAGS+=-pthread
testcases/kernel/syscalls/signal/signal06.c new file +156 -0
156 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 1/1 signal: add new testcase signal06.c
----- Original Message -----
Quoted 6 lines
From: "Li Wang" <[email protected]>
To: [email protected]
Cc: [email protected]
Sent: Tuesday, 10 November, 2015 11:32:37 AM
Subject: [PATCH v2] signal: add new testcasesignal06.c
Quoted 7 lines
v1 --> v2
1. define LOOPS as 10000
2. use -pthread inMakefile
3. add volatile to FLAGE
4. includelinux_syscall_numbers.h
5. use__NR_tkilland SIGHUP
6. usetst_exit()andTEST()
Hi,
just some minor comments below, I missed some in last email.
Other than that it looked ok to me and I could reproduce the bug on older kernels.
Regards,
Jan
Quoted 11 lines
the comments from Oleg's patch:
save_xstate_sig()->drop_init_fpu() doesn't look right.
setup_rt_frame()can fail after that, in this case the nextsetup_rt_frame()triggered by SIGSEGV won't save fpu simply because the old state was lost. This obviously mean that fpu won't be restored aftersys_rt_sigreturn()from SIGSEGV handler.this issue was fixed on kernel v3.17-rc3-3:
Quoted 7 lines
commit
df24fb859a4e200d9324e2974229fbb7adf00aef
Author: Oleg Nesterov <[email protected]>
Date: Tue Sep 2 19:57:17 2014 +0200commit 66463db4fc5605d51c7bb81d009d5bf30a783a2c Author: Oleg Nesterov <[email protected]> Date: Tue Sep 2 19:57:13 2014 +0200
one of these is using spaces, the other one tabs
Quoted 8 lines
Signed-off-by Li Wang <[email protected]>--- runtest/ltplite | 1 + runtest/stress.part3 | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/signal/Makefile | 2 + testcases/kernel/syscalls/signal/signal06.c | 156
We should add it to .gitignore too.
Quoted 89 lines
++++++++++++++++++++++++++++
5 files changed, 161 insertions(+) create mode 100644 testcases/kernel/syscalls/signal/signal06.cruntest/ltplite +1
-0@@ -840,6 +840,7 @@ signal02 signal02 signal03 signal03 signal04 signal04 signal05 signal05 +signal06 signal06 sigpending02 sigpending02runtest/stress.part3 +1
-0@@ -744,6 +744,7 @@ signal02 signal02 signal03 signal03 signal04 signal04 signal05 signal05 +signal06 signal06 sigpending02 sigpending02runtest/syscalls +1
-0@@ -1143,6 +1143,7 @@ signal02 signal02 signal03 signal03 signal04 signal04 signal05 signal05 +signal06 signal06 signalfd01 signalfd01testcases/kernel/syscalls/signal/Makefile +2
-0@@ -21,3 +21,5 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk + +signal06: CFLAGS+=-pthreadtestcases/kernel/syscalls/signal/signal06.c new file +21
-0@@ -0,0 +1,156 @@ +/* +* Copyright (c) 2015 Author: Oleg Nesterov <[email protected]> +* Modify: Li Wang <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* you should have received a copy of the GNU General Public License along +* with this program; if not, write the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +/* +* Description: +* +* save_xstate_sig()->drop_init_fpu() doesn't look right.
setup_rt_frame()
+ * can fail after that, in this case the nextsetup_rt_frame()
triggered
+ * by SIGSEGV won't save fpu simply because the old state was lost.
This
+ * obviously mean that fpu won't be restored aftersys_rt_sigreturn()
from
+ * SIGSEGV handler.
+ *
+ * These commits fix the issue on v3.17-rc3-3 stable kernel:
Quoted 8 lines
+ *
+ * commitdf24fb859a4e200d9324e2974229fbb7adf00aef
+ * Author: Oleg Nesterov <[email protected]>
+ * Date: Tue Sep 2 19:57:17 2014 +0200
+ *
+ * commit66463db4fc5605d51c7bb81d009d5bf30a783a2c
+ * Author: Oleg Nesterov <[email protected]>
+ * Date: Tue Sep 2 19:57:13 2014 +0200
one of these is using spaces, the other one tabs.
Quoted 56 lines
+ *
+ * Reproduce:
+ * Test-case (needs -O2).
+ */testcases/kernel/syscalls/signal/signal06.c new file +52
-0+ +#include <stdio.h> +#include <signal.h> +#include <unistd.h> +#include <sys/syscall.h> +#include <sys/mman.h> +#include <pthread.h> +#include <assert.h> +#include <errno.h> + +#include "test.h" +#include "linux_syscall_numbers.h" + +char *TCID ="signal06" ; +int TST_TOTAL =5 ; + +#if __x86_64__ + +#define LOOPS 10000 + +volatile double D ; +volatile int FLAGE ; + +char altstack[4096 * 10] __attribute__((aligned(4096))); + +void test (double d) +{ +int loop =0 ; +int pid =getpid (); + +D = d; +while (D == d && loop <LOOPS ) { +/* sys_tkill(pid, SIGHUP); asm to avoid save/reload +* fp regs around c call */ + asm ("" : :"a" (__NR_tkill),"D" (pid),"S" (SIGHUP )); + asm ("syscall" : : :"ax" ); + + loop++; + } + +FLAGE =1 ; +tst_resm (TINFO ,"loop = %d" , loop); + +if (loop ==LOOPS ) { +tst_resm (TPASS ,"%s call succeeded" ,TCID ); + }else { +tst_resm (TFAIL ,"Bug Reproduced!" ); +tst_exit (); + } +} + +void sigh(int sig LTP_ATTRIBUTE_UNUSED)
testcases/kernel/syscalls/signal/signal06.c line 101
Quoted 10 lines
testcases/kernel/syscalls/signal/signal06.c new file +10
-0+{ +} + +void *tfunc(void *arg LTP_ATTRIBUTE_UNUSED) +{ +FLAGE =0 ; + +for (; ;) { +mprotect (altstack,sizeof (altstack),PROT_READ ); +mprotect (altstack,sizeof (altstack),PROT_READ |PROT_WRITE );
We should also check ret code here.
Quoted 17 lines
testcases/kernel/syscalls/signal/signal06.c new file +17
-0+ +if (FLAGE ==1 ) +return NULL ; + } +} + +int main (int ac,char **av) +{ +int i, lc; +pthread_t pt; + +tst_parse_opts (ac, av,NULL ,NULL ); + +stack_t st = { + .ss_sp = altstack, + .ss_size =sizeof (altstack), + .ss_flags =SS_ONSTACK ,
testcases/kernel/syscalls/signal/signal06.c line 128
Quoted 10 lines
testcases/kernel/syscalls/signal/signal06.c new file +10
-0+ }; + +struct sigaction sa = { + .sa_handler = sigh, + }; + +sigaction (SIGSEGV , &sa,NULL ); +sigaltstack (&st,NULL ); + sa.sa_flags =SA_ONSTACK ; +sigaction (SIGHUP , &sa,NULL );
We should check return value from sigaction.
testcases/kernel/syscalls/signal/signal06.c line 138
Quoted 10 lines
testcases/kernel/syscalls/signal/signal06.c new file +10
-0+ +for (lc =0 ;TEST_LOOPING (lc); lc++) { + tst_count =0 ; + +for (i =0 ; i <TST_TOTAL ; i++) { + +TEST (pthread_create (&pt,NULL , tfunc,NULL )); +if (TEST_RETURN ) +tst_brkm (TBROK |TTERRNO ,NULL , +"pthread_create failed" );
TRERRNO
testcases/kernel/syscalls/signal/signal06.c line 144
Quoted 6 lines
testcases/kernel/syscalls/signal/signal06.c new file +6
-0+ +test (123.456 ); + +TEST (pthread_join (pt,NULL )); +if (TEST_RETURN ) +tst_brkm (TBROK ,NULL ,"pthread_join failed" );
TRERRNO
Quoted 16 lines
testcases/kernel/syscalls/signal/signal06.c new file +12
-1+ } + } + +tst_exit (); +} + +#else +int main (void ) +{ +tst_brkm (TCONF ,NULL ,"Only test on x86_64." ); +} +#endif --1.8.3.1
PATCH v2 1/1 signal: add new testcase signal06.c
Hi,
Quoted 18 lines · Jan Stancek
----- Original Message -----
Quoted 6 lines
From: "Li Wang" <[email protected]>
To: [email protected]
Cc: [email protected]
Sent: Tuesday, 10 November, 2015 11:32:37 AM
Subject: [PATCH v2] signal: add new testcasesignal06.cQuoted 7 lines
v1 --> v2
1. define LOOPS as 10000
2. use -pthread inMakefile
3. add volatile to FLAGE
4. includelinux_syscall_numbers.h
5. use__NR_tkilland SIGHUP
6. usetst_exit()andTEST()
Quoted 4 lines
Hi,
just some minor comments below, I missed some in last email.
I have read it, agree all.
Quoted 4 lines
Other than that it looked ok to me and I could reproduce the bug on older kernels.
ok, I will sent V3 later. thanks!
Signature · 6 lines
Regards, Li Wang Email: [email protected] -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20151111/acf1adf3/attachment-0001.html>