From b2cab453f134ede6e674fc12c23238ad8a3659bf Mon Sep 17 00:00:00 2001 From: "bgerofi@riken.jp" Date: Thu, 4 Dec 2014 16:49:10 +0900 Subject: [PATCH] clone(): do not allow setting CLONE_THREAD and CLONE_VM separately XXX: When CLONE_VM is set but CLONE_THREAD is not the new thread is meant to have its own thread group, i.e., when calling exit_group() the cloner thread wouldn't be killed. However, this is a problem on the Linux side because we do not invoke clone in mcexec when threads are created. Thus, currently no support for this combination is provided. --- kernel/syscall.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/syscall.c b/kernel/syscall.c index d00b8402..228e18a7 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -1619,6 +1619,12 @@ unsigned long do_fork(int clone_flags, unsigned long newsp, dkprintf("do_fork(): stack_pointr passed in: 0x%lX, stack pointer of caller: 0x%lx\n", newsp, cursp); + + if (((clone_flags & CLONE_VM) && !(clone_flags & CLONE_THREAD)) || + (!(clone_flags & CLONE_VM) && (clone_flags & CLONE_THREAD))) { + kprintf("%s: ERROR: CLONE_VM and CLONE_THREAD should be set together\n"); + return -EINVAL; + } cpuid = obtain_clone_cpuid(); if (cpuid == -1) {