]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process/signal: Add stub for CLONE_SIGHAND
authorMichalis Pappas <michalis@unikraft.io>
Thu, 3 Apr 2025 13:04:25 +0000 (15:04 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Thu, 17 Apr 2025 12:45:48 +0000 (12:45 +0000)
Provide stub for CLONE_SIGHAND when LIBPOSIX_PROCESS_SIGNAL
is not selected. This prevents clone() from returning -ENOTSUP
when signals are not selected.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1628

lib/posix-process/Makefile.uk
lib/posix-process/signal/clone.c

index 86ca80b5f60772ce9cf95182dc813dd4dd1b37bd..9e61777e76feea7dda0ff35847d6425f243a5e48 100644 (file)
@@ -38,10 +38,7 @@ LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/signal/kill.c
 LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/signal/tgkill.c
 LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/signal/tkill.c
 
-ifeq ($(CONFIG_LIBPOSIX_PROCESS_CLONE), y)
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_SIGNAL) += $(LIBPOSIX_PROCESS_BASE)/signal/clone.c|signal
-endif
-
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/signal/clone.c|signal
 LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/clone.c
 LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/clone.S|arch
 LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/clonetab.ld
index e3ad9b33e041e6bd8af0dadceaabc98fd6175c1b..b6a2bb351037ce15f71b63b684669a210ed82cac 100644 (file)
@@ -3,31 +3,8 @@
  * Copyright (c) 2022, NEC Laboratories Europe GmbH, NEC Corporation.
  *                     All rights reserved.
  * Copyright (c) 2024, Unikraft GmbH and The Unikraft Authors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * Licensed under the BSD-3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
  */
 
 #include <string.h>
@@ -37,6 +14,8 @@
 #include <uk/process.h>
 #include <uk/print.h>
 
+#if CONFIG_LIBPOSIX_PROCESS_SIGNAL
+
 #include "signal.h"
 
 static int uk_posix_clone_sighand(const struct clone_args *cl_args,
@@ -163,6 +142,29 @@ fail_tdesc_alloc:
 
        return rc;
 }
+#else /* !CONFIG_LIBPOSIX_PROCESS_SIGNAL */
+static int uk_posix_clone_sighand(const struct clone_args *cl_args,
+                                 size_t cl_args_len __unused,
+                                 struct uk_thread *child __unused,
+                                 struct uk_thread *parent __unused)
+{
+       /* CLONE_SIGHAND and CLONE_CLEAR_SIGHAND should not be together */
+       if (unlikely((cl_args->flags & (CLONE_SIGHAND | CLONE_CLEAR_SIGHAND)) ==
+                    (CLONE_SIGHAND | CLONE_CLEAR_SIGHAND)))
+               return -EINVAL;
+       /* CLONE_SIGHAND requires CLONE_VM */
+       if (unlikely((cl_args->flags & CLONE_SIGHAND) &&
+                    !(cl_args->flags & CLONE_VM)))
+               return -EINVAL;
+       /* CLONE_THREAD requires CLONE_SIGHAND */
+       if (unlikely((cl_args->flags & CLONE_THREAD) &&
+                    !(cl_args->flags & CLONE_SIGHAND)))
+               return -EINVAL;
+
+       UK_WARN_STUBBED();
+       return 0;
+}
+#endif /* !CONFIG_LIBPOSIX_PROCESS_SIGNAL */
 
 UK_POSIX_CLONE_HANDLER(CLONE_SIGHAND | CLONE_CLEAR_SIGHAND, false,
                       uk_posix_clone_sighand, 0x0);