syscalls/ioctl_ns01: fix crash on aarch64
PATCH 1/1 syscalls/ioctl_ns01: fix crash on aarch64
Test crashes with SIGBUS when using child stack. Align stack to 256 bytes, which is more than enough for any arch.
Neither parent or library is waiting for child process. Add SIGCHLD to clone flags.
Check return value of ltp_clone(), and TBROK on failure.
Fix warning about unused *arg.
--- testcases/kernel/syscalls/ioctl/ioctl_ns01.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl_ns01.c +7 -3
@@ -23,7 +23,7 @@#define STACK_SIZE (1024 * 1024) -static char child_stack[STACK_SIZE ]; +static char child_stack[STACK_SIZE] __attribute__((aligned(256)));static void setup (void ) {
@@ -53,7 +53,7 @@ static void test_ns_get_parent(void) } } -static int child (void *arg) +static int child(void *arg LTP_ATTRIBUTE_UNUSED) {test_ns_get_parent ();return 0 ;
@@ -61,10 +61,14 @@ static int child(void *arg)static void run (void ) { +int child_pid; +test_ns_get_parent (); -ltp_clone (CLONE_NEWPID , &child,0 , + child_pid =ltp_clone (CLONE_NEWPID |SIGCHLD , &child,0 ,STACK_SIZE , child_stack); +if (child_pid ==-1 ) +tst_brk (TBROK |TERRNO ,"ltp_clone failed" ); }static struct tst_test test = {
Signature · 1 line
1.8.3.1
PATCH 1/1 syscalls/ioctl_ns01: fix crash on aarch64
Quoted 22 lines · Jan Stancek
Test crashes with SIGBUS when using child stack. Align stack to 256 bytes, which is more than enough for any arch.
Neither parent or library is waiting for child process. Add SIGCHLD to clone flags.
Check return value of
ltp_clone(), and TBROK on failure.Fix warning about unused *arg.
Signed-off-by Jan Stancek <[email protected]>--- testcases/kernel/syscalls/ioctl/ioctl_ns01.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)testcases/kernel/syscalls/ioctl/ioctl_ns01.c +0
-0
testcases/kernel/syscalls/ioctl/ioctl_ns01.c line 27
Quoted 6 lines
testcases/kernel/syscalls/ioctl/ioctl_ns01.c +1
-1@@ -23,7 +23,7 @@#define STACK_SIZE (1024 * 1024) -static char child_stack[STACK_SIZE ]; +static char child_stack[STACK_SIZE] __attribute__((aligned(256)));
This patch makes sense. And maybe we'd better change that for ioctl_nfs05/06 too?
BTW, another way we could try is to allocate the child_stack memory dynamically via malloc(STACK_SIZE) in setup() function.
Quoted 35 lines
testcases/kernel/syscalls/ioctl/ioctl_ns01.c +6
-3static void setup (void ) {@@ -53,7 +53,7 @@ static void test_ns_get_parent(void) } } -static int child (void *arg) +static int child(void *arg LTP_ATTRIBUTE_UNUSED) {test_ns_get_parent ();return 0 ;@@ -61,10 +61,14 @@ static int child(void *arg)static void run (void ) { +int child_pid; +test_ns_get_parent (); -ltp_clone (CLONE_NEWPID , &child,0 , + child_pid =ltp_clone (CLONE_NEWPID |SIGCHLD , &child,0 ,STACK_SIZE , child_stack); +if (child_pid ==-1 ) +tst_brk (TBROK |TERRNO ,"ltp_clone failed" ); }static struct tst_test test = { --1.8.3.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20190611/7b298d1c/attachment.html>
PATCH 1/1 syscalls/ioctl_ns01: fix crash on aarch64
----- Original Message -----
Quoted 41 lines · Jan Stancek
Quoted 38 lines
Test crashes with SIGBUS when using child stack. Align stack to 256 bytes,
which is more than enough for any arch.
Neither parent or library is waiting for child process. Add SIGCHLD to
clone flags.
Check return value of
ltp_clone(), and TBROK on failure.Fix warning about unused *arg.
Signed-off-by Jan Stancek < [email protected] >---
testcases/kernel/syscalls/ioctl/ioctl_ns01.c| 10 +++++++---1 file changed, 7 insertions(+), 3 deletions(-)testcases/kernel/syscalls/ioctl/ioctl_ns01.c +0
-0index
dfde4da6c5d6..625de9bd832d100644---
a/testcases/kernel/syscalls/ioctl/ioctl_ns01.c+++
b/testcases/kernel/syscalls/ioctl/ioctl_ns01.ctestcases/kernel/syscalls/ioctl/ioctl_ns01.c +0
-0@@ -23,7 +23,7 @@#define STACK_SIZE (1024 * 1024)
Quoted 7 lines
testcases/kernel/syscalls/ioctl/ioctl_ns01.c
Quoted 3 lines
testcases/kernel/syscalls/ioctl/ioctl_ns01.c +1
-1-static char child_stack[STACK_SIZE ]; +static char child_stack[STACK_SIZE] __attribute__((aligned(256)));This patch makes sense. And maybe we'd better change that for ioctl_nfs05/06 too?
Yes, you're right. Trying an unaligned address yields same result:
Starting program: /root/ltp/testcases/kernel/syscalls/ioctl/ioctl_ns05 tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s [Attaching after process 19449 fork to child process 19452] [New inferior 2 (process 19452)]
[Detaching after fork from parent process 19449]
[Inferior 1 (process 19449) detached]0x4306a0
[New LWP 19453]
ioctl_ns05.c:80: PASS: child and parent are consistent
Thread 2.2 received signal SIGBUS, Bus error. [Switching to LWP 19453]
child (arg=0x0) at ioctl_ns05.c:37
37 if (getpid() != 1)
(gdb) disassemble
Dump of assembler code for function child:
=> 0x00000000004032e8 <+0>: stp x29, x30, [sp, #-32]! 0x00000000004032ec <+4>: mov x29, sp 0x00000000004032f0 <+8>: str x19, [sp, #16]
I'll send v2.
Thanks,
Jan
Quoted 58 lines
BTW, another way we could try is to allocate the
child_stackmemory dynamically viamalloc(STACK_SIZE)insetup()function.Quoted 53 lines
testcases/kernel/syscalls/ioctl/ioctl_ns01.c +0
-0static void setup (void ){
testcases/kernel/syscalls/ioctl/ioctl_ns01.c +1
-1@@ -53,7 +53,7 @@ static void test_ns_get_parent(void) } } -static int child (void *arg) +static int child(void *arg LTP_ATTRIBUTE_UNUSED){
test_ns_get_parent();return 0;
testcases/kernel/syscalls/ioctl/ioctl_ns01.c +3
-1@@ -61,10 +61,14 @@ static int child(void *arg)static void run (void ) { +int child_pid; +test_ns_get_parent (); - ltp_clone(CLONE_NEWPID, &child, 0, + child_pid = ltp_clone(CLONE_NEWPID | SIGCHLD, &child, 0,
STACK_SIZE,child_stack);+ if (
child_pid== -1)+
tst_brk(TBROK | TERRNO, "ltp_clone failed");}
static struct
tst_testtest = {--
1.8.3.1
Quoted 8 lines
Quoted 3 lines
--
Mailing list info: https://lists.linux.it/listinfo/ltp
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190611/4f053da3/attachment.html>