From: Sergiu Moga Date: Thu, 20 Mar 2025 18:46:01 +0000 (+0200) Subject: lib/posix-process: Init signal files ctx on signal desc creation X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=835b50ab272ffc9b2fd9996d6d45e235dc1378c7;p=unikraft%2Funikraft.git lib/posix-process: Init signal files ctx on signal desc creation 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 Approved-by: Michalis Pappas Reviewed-by: Michalis Pappas Reviewed-by: Andrei Tatar GitHub-Closes: #1619 --- diff --git a/lib/posix-process/signal/clone.c b/lib/posix-process/signal/clone.c index b6a2bb351..a7a66ca1f 100644 --- a/lib/posix-process/signal/clone.c +++ b/lib/posix-process/signal/clone.c @@ -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: diff --git a/lib/posix-process/signal/signal.c b/lib/posix-process/signal/signal.c index 0620b4cba..9758fee22 100644 --- a/lib/posix-process/signal/signal.c +++ b/lib/posix-process/signal/signal.c @@ -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; }