<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 6:25 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 (SIGBUS) when using child stack have been observed for<br>
ioctl_ns01. Align stack to 64 bytes for all testcases using clone,<br>
which should work 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>
Add SIGCHLD to clone flags, so that LTP library can reap all children<br>
and check their return code. Also check ltp_clone() return value.<br>
<br>
Suppress warning for unused *arg in child().<br>
<br>
Signed-off-by: Jan Stancek <<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>><br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>></div><br class="m_7615400080412838853gmail-Apple-interchange-newline"><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
testcases/kernel/syscalls/ioctl/ioctl_ns01.c | 9 +++++----<br>
testcases/kernel/syscalls/ioctl/ioctl_ns05.c | 8 +++++---<br>
testcases/kernel/syscalls/ioctl/ioctl_ns06.c | 11 +++++++----<br>
3 files changed, 17 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ns01.c b/testcases/kernel/syscalls/ioctl/ioctl_ns01.c<br>
index dfde4da6c5d6..a6ff57d4cbf9 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>
<br>
#define STACK_SIZE (1024 * 1024)<br>
<br>
-static char child_stack[STACK_SIZE];<br>
+static char child_stack[STACK_SIZE] __attribute__((aligned(64)));<br>
<br>
static void setup(void)<br>
{<br>
@@ -53,7 +53,7 @@ static void test_ns_get_parent(void)<br>
}<br>
}<br>
<br>
-static int child(void *arg)<br>
+static int child(void *arg LTP_ATTRIBUTE_UNUSED)<br>
{<br>
test_ns_get_parent();<br>
return 0;<br>
@@ -63,8 +63,9 @@ static void run(void)<br>
{<br>
test_ns_get_parent();<br>
<br>
- ltp_clone(CLONE_NEWPID, &child, 0,<br>
- STACK_SIZE, child_stack);<br>
+ if (ltp_clone(CLONE_NEWPID | SIGCHLD, &child, 0,<br>
+ STACK_SIZE, child_stack) == -1)<br>
+ tst_brk(TBROK | TERRNO, "ltp_clone failed");<br>
}<br>
<br>
static struct tst_test test = {<br>
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ns05.c b/testcases/kernel/syscalls/ioctl/ioctl_ns05.c<br>
index a8dee07a1154..685a5f683b25 100644<br>
--- a/testcases/kernel/syscalls/ioctl/ioctl_ns05.c<br>
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ns05.c<br>
@@ -22,7 +22,7 @@<br>
<br>
#define STACK_SIZE (1024 * 1024)<br>
<br>
-static char child_stack[STACK_SIZE];<br>
+static char child_stack[STACK_SIZE] __attribute__((aligned(64)));<br>
<br>
static void setup(void)<br>
{<br>
@@ -32,7 +32,7 @@ static void setup(void)<br>
tst_res(TCONF, "namespace not available");<br>
}<br>
<br>
-static int child(void *arg)<br>
+static int child(void *arg LTP_ATTRIBUTE_UNUSED)<br>
{<br>
if (getpid() != 1)<br>
tst_res(TFAIL, "child should think its pid is 1");<br>
@@ -44,8 +44,10 @@ static int child(void *arg)<br>
<br>
static void run(void)<br>
{<br>
- pid_t pid = ltp_clone(CLONE_NEWPID, &child, 0,<br>
+ pid_t pid = ltp_clone(CLONE_NEWPID | SIGCHLD, &child, 0,<br>
STACK_SIZE, child_stack);<br>
+ if (pid == -1)<br>
+ tst_brk(TBROK | TERRNO, "ltp_clone failed");<br>
<br>
char child_namespace[20];<br>
int my_fd, child_fd, parent_fd;<br>
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ns06.c b/testcases/kernel/syscalls/ioctl/ioctl_ns06.c<br>
index 805a0a072e2f..bf5800434723 100644<br>
--- a/testcases/kernel/syscalls/ioctl/ioctl_ns06.c<br>
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ns06.c<br>
@@ -23,7 +23,7 @@<br>
<br>
#define STACK_SIZE (1024 * 1024)<br>
<br>
-static char child_stack[STACK_SIZE];<br>
+static char child_stack[STACK_SIZE] __attribute__((aligned(64)));<br>
<br>
static void setup(void)<br>
{<br>
@@ -33,7 +33,7 @@ static void setup(void)<br>
tst_res(TCONF, "namespace not available");<br>
}<br>
<br>
-static int child(void *arg)<br>
+static int child(void *arg LTP_ATTRIBUTE_UNUSED)<br>
{<br>
TST_CHECKPOINT_WAIT(0);<br>
return 0;<br>
@@ -41,10 +41,13 @@ static int child(void *arg)<br>
<br>
static void run(void)<br>
{<br>
- pid_t pid = ltp_clone(CLONE_NEWUSER, &child, 0,<br>
- STACK_SIZE, child_stack);<br>
char child_namespace[20];<br>
<br>
+ pid_t pid = ltp_clone(CLONE_NEWUSER | SIGCHLD, &child, 0,<br>
+ STACK_SIZE, child_stack);<br>
+ if (pid == -1)<br>
+ tst_brk(TBROK | TERRNO, "ltp_clone failed");<br>
+<br>
sprintf(child_namespace, "/proc/%i/ns/user", pid);<br>
int my_fd, child_fd, parent_fd;<br>
<br>
-- <br>
1.8.3.1<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_7615400080412838853gmail_signature"><div dir="ltr"><div><div dir="ltr">Regards,<br>Li Wang<br></div></div></div></div></div>