]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process: Init signal files ctx on signal desc creation
authorSergiu Moga <sergiu@unikraft.io>
Thu, 20 Mar 2025 18:46:01 +0000 (20:46 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Wed, 23 Apr 2025 10:01:21 +0000 (10:01 +0000)
We have two initialization places for the signal files context of a
signal files context:
- on vfork when a child process is born and its signal descriptor is
correspondingly inherited from the parent
- on signal descriptor initialization on regular process creation

For the former, at this time, we do not support proper open file
inheritance across vfork/execve for those that do not have the
O_CLOEXEC flag. Therefore, for now, simply just initialize child
process' signal descriptor signal file context as empty.

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

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

index b6a2bb351037ce15f71b63b684669a210ed82cac..a7a66ca1fd755faa29b1b312530ba93d42593560 100644 (file)
@@ -132,6 +132,16 @@ static int uk_posix_clone_sighand(const struct clone_args *cl_args,
        if ((cl_args->flags & CLONE_VM) && !(cl_args->flags & CLONE_VFORK))
                cp->signal->altstack.ss_flags = SS_DISABLE;
 
+#if CONFIG_LIBPOSIX_PROCESS_SIGNALFD
+       /*
+        * TODO: At this time we do not support proper open file inheritance
+        * across vfork/execve for those that do not have the O_CLOEXEC flag.
+        * Therefore, for now, simply just initialize child process' signal
+        * descriptor signal file context as empty.
+        */
+       uk_signal_files_ctx_init(&cp->signal->sigfiles_ctx);
+#endif /* CONFIG_LIBPOSIX_PROCESS_SIGNALFD */
+
        return 0;
 
 fail_malloc:
index 0620b4cbafb6638a521c5c672c30fc57b4ee8718..9758fee222904329510ecfcffbaf0925a589738e 100644 (file)
@@ -364,6 +364,10 @@ int pprocess_signal_pdesc_init(struct posix_process *process)
 
        pd->altstack.ss_flags = SS_DISABLE;
 
+#if CONFIG_LIBPOSIX_PROCESS_SIGNALFD
+       uk_signal_files_ctx_init(&pd->sigfiles_ctx);
+#endif /* CONFIG_LIBPOSIX_PROCESS_SIGNALFD */
+
        return 0;
 }