<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 11, 2019 at 3:44 PM Jan Stancek <<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Test crashes with SIGBUS when using child stack. Align stack to 256 bytes,<br>
which is more than enough for any arch.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Neither parent or library is waiting for child process. Add SIGCHLD to<br>
clone flags.<br><div><br></div>
Check return value of ltp_clone(), and TBROK on failure.<br><div><br></div>
Fix warning about unused *arg.<br><div><br></div>
Signed-off-by: Jan Stancek <<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>><br>
---<br>
testcases/kernel/syscalls/ioctl/ioctl_ns01.c | 10 +++++++---<br>
1 file changed, 7 insertions(+), 3 deletions(-)<br><div><br></div>
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ns01.c b/testcases/kernel/syscalls/ioctl/ioctl_ns01.c<br>
index dfde4da6c5d6..625de9bd832d 100644<br>
--- a/testcases/kernel/syscalls/ioctl/ioctl_ns01.c<br>
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ns01.c<br>
@@ -23,7 +23,7 @@<br><div><br></div>
#define STACK_SIZE (1024 * 1024)<br><div><br></div>
-static char child_stack[STACK_SIZE];<br>
+static char child_stack[STACK_SIZE] __attribute__((aligned(256)));<br></blockquote><div><br></div><div><div class="gmail_default">This patch makes sense. And maybe we'd better change that for ioctl_nfs05/06 too?</div></div></div></div></blockquote><div>Yes, you're right. Trying an unaligned address yields same result:<br></div><div><br></div><div></div><div>Starting program: /root/ltp/testcases/kernel/syscalls/ioctl/ioctl_ns05 <br>tst_test.c:1111: INFO: Timeout per run is 0h 05m 00s<br>[Attaching after process 19449 fork to child process 19452]<br>[New inferior 2 (process 19452)]<br>[Detaching after fork from parent process 19449]<br>[Inferior 1 (process 19449) detached]<br>0x4306a0<br>[New LWP 19453]<br>ioctl_ns05.c:80: PASS: child and parent are consistent<br><br>Thread 2.2 received signal SIGBUS, Bus error.<br>[Switching to LWP 19453]<br>child (arg=0x0) at ioctl_ns05.c:37<br>37 if (getpid() != 1)<br>(gdb) disassemble <br>Dump of assembler code for function child:<br>=> 0x00000000004032e8 <+0>: stp x29, x30, [sp, #-32]!<br> 0x00000000004032ec <+4>: mov x29, sp<br> 0x00000000004032f0 <+8>: str x19, [sp, #16]<br><br></div><div><br></div><div> I'll send v2.<br></div><div><br></div><div>Thanks,<br></div><div>Jan<br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr"><div class="gmail_quote"><div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small">BTW, another way we could try is to allocate the child_stack memory dynamically via malloc(STACK_SIZE) in setup() function. </div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
static void setup(void)<br>
{<br>
@@ -53,7 +53,7 @@ static void test_ns_get_parent(void)<br>
}<br>
}<br><div><br></div>
-static int child(void *arg)<br>
+static int child(void *arg LTP_ATTRIBUTE_UNUSED)<br>
{<br>
test_ns_get_parent();<br>
return 0;<br>
@@ -61,10 +61,14 @@ static int child(void *arg)<br><div><br></div>
static void run(void)<br>
{<br>
+ int child_pid;<br>
+<br>
test_ns_get_parent();<br><div><br></div>
- ltp_clone(CLONE_NEWPID, &child, 0,<br>
+ child_pid = ltp_clone(CLONE_NEWPID | SIGCHLD, &child, 0,<br>
STACK_SIZE, child_stack);<br>
+ if (child_pid == -1)<br>
+ tst_brk(TBROK | TERRNO, "ltp_clone failed");<br>
}<br><div><br></div>
static struct tst_test test = {<br>
-- <br>
1.8.3.1<br><div><br></div><br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div></blockquote><div><br></div></div></body></html>