summaryrefslogtreecommitdiff
path: root/tests/ioctl_nsfs.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2019-12-29 22:25:26 +0000
committerDmitry V. Levin <ldv@altlinux.org>2019-12-29 22:25:26 +0000
commit7b942af2f7b3de9bb5cefd9a026a30af899cea57 (patch)
tree30d8dec20c5968bb3efed408b770a824a3de686a /tests/ioctl_nsfs.c
parent0c29141a0808f07d59ef9208c404c39dc0b0ce21 (diff)
downloadstrace-7b942af2f7b3de9bb5cefd9a026a30af899cea57.tar.gz
tests: increase the child stack size in some tests that invoke clone
Increase the child stack size from the half page size to the full page size in those few tests that invoke clone syscall. The former size appears to be insufficient in some build setups. For example, clang 7 on Ubuntu bionic x86_64 makes ioctl_nsfs test fail due to child process segfaults. * tests/clone_parent.c (child_stack_size, clone): Remove. (do_clone): New macro. (main): Use it. * tests/clone_ptrace.c: Likewise. * tests/ioctl_nsfs.c (child_stack_size, clone): Remove. (do_clone): New macro. (test_user_namespace): Use it.
Diffstat (limited to 'tests/ioctl_nsfs.c')
-rw-r--r--tests/ioctl_nsfs.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/ioctl_nsfs.c b/tests/ioctl_nsfs.c
index 74dbe6e94..fd82b4adb 100644
--- a/tests/ioctl_nsfs.c
+++ b/tests/ioctl_nsfs.c
@@ -86,22 +86,27 @@ child(void *arg)
#ifdef IA64
extern int __clone2(int (*)(void *), void *, size_t, int, void *, ...);
-# define clone(fn, child_stack, flags, arg) \
- __clone2(fn, child_stack, get_page_size() / 2, flags, arg)
+# define do_clone(fn_, stack_, size_, flags_, arg_, ...) \
+ __clone2((fn_), (stack_), (size_), (flags_), (arg_), ## __VA_ARGS__)
+#else
+# define do_clone(fn_, stack_, size_, flags_, arg_, ...) \
+ clone((fn_), (stack_), (flags_), (arg_), ## __VA_ARGS__)
#endif
static void
test_user_namespace(void)
{
- pid_t pid;
int pipefd[2];
- int status;
-
if (pipe(pipefd))
perror_msg_and_fail("pipe");
- pid = clone(child, tail_alloc(get_page_size() / 2),
- CLONE_NEWUSER | CLONE_UNTRACED | SIGCHLD, pipefd);
+ const unsigned long child_stack_size = get_page_size();
+ void *const child_stack =
+ tail_alloc(child_stack_size * 2) + child_stack_size;
+
+ const pid_t pid = do_clone(child, child_stack, child_stack_size,
+ CLONE_NEWUSER | CLONE_UNTRACED | SIGCHLD,
+ pipefd);
if (pid == -1) {
perror("clone");
return;
@@ -109,6 +114,8 @@ test_user_namespace(void)
close(pipefd[0]);
test_clone(pid);
close(pipefd[1]);
+
+ int status;
if (wait(&status) != pid) {
perror_msg_and_fail("wait");
} else if (status != 0) {