From d02f43293e4d802cd45466b11a7946b541bd9fc8 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Wed, 15 Nov 2023 16:24:52 +0100 Subject: [PATCH] lib/vfscore: Handle CLONE_VM vfork() sets the CLONE_VM and CLONE_VFORK flags. This triggers an error in the clone handlers of vfscore as CLONE_FS is not set. Update the handlers to additionally check against CLONE_VM, as that also implies that the parent and child share filesystem state. Signed-off-by: Michalis Pappas Approved-by: Andrei Tatar Reviewed-by: Sergiu Moga Reviewed-by: Andrei Tatar GitHub-Closes: #1386 --- lib/vfscore/fd.c | 3 ++- lib/vfscore/syscalls.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/vfscore/fd.c b/lib/vfscore/fd.c index eb2c667e5..52e8c3110 100644 --- a/lib/vfscore/fd.c +++ b/lib/vfscore/fd.c @@ -79,7 +79,8 @@ static int uk_posix_clone_files(const struct clone_args *cl_args, struct uk_thread *child __unused, struct uk_thread *parent __unused) { - if (unlikely(!(cl_args->flags & CLONE_FILES))) { + if (unlikely(!(cl_args->flags & CLONE_FILES) && + !(cl_args->flags & CLONE_VM))) { uk_pr_warn("CLONE_FILES not set"); return -ENOTSUP; } diff --git a/lib/vfscore/syscalls.c b/lib/vfscore/syscalls.c index ab7eaeab6..40d379838 100644 --- a/lib/vfscore/syscalls.c +++ b/lib/vfscore/syscalls.c @@ -1237,7 +1237,8 @@ static int uk_posix_clone_fs(const struct clone_args *cl_args, struct uk_thread *child __unused, struct uk_thread *parent __unused) { - if (unlikely(!(cl_args->flags & CLONE_FS))) { + if (unlikely(!(cl_args->flags & CLONE_FS) && + !(cl_args->flags & CLONE_VM))) { uk_pr_warn("Separate filesystem information for children are not supported (CLONE_FS absent)\n"); return -ENOTSUP; } -- 2.39.5