]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-fdtab: Fix exec handler target fdtab stable
authorAndrei Tatar <andrei@unikraft.io>
Thu, 24 Apr 2025 13:07:31 +0000 (15:07 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Thu, 24 Apr 2025 14:05:10 +0000 (14:05 +0000)
This change makes the exec handler cloexec the target thread's fdtab
instead of that of the calling thread's.

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

lib/posix-fdtab/fdtab.c

index b3e91b7924dfd33d6ea08654976dde465061f867..1349ce67ffddffed3319aff0c8d163e83d2acfbe 100644 (file)
@@ -366,11 +366,22 @@ void uk_fdtab_cloexec(void)
 }
 
 #if CONFIG_LIBPOSIX_PROCESS_EXECVE
-static int fdtab_handle_execve(void *data __unused)
+#if CONFIG_LIBPOSIX_FDTAB_MULTITAB
+static int fdtab_handle_execve(void *data)
+{
+       struct posix_process_execve_event_data *edat = data;
+       struct uk_fdtab *tab = uk_thread_uktls_var(edat->thread, active_fdtab);
+
+       fdtab_cleanup(tab, 0);
+       return UK_EVENT_HANDLED_CONT;
+}
+#else /* !CONFIG_LIBPOSIX_FDTAB_MULTITAB */
+static int fdtab_handle_execve(void *data)
 {
        uk_fdtab_cloexec();
        return UK_EVENT_HANDLED_CONT;
 }
+#endif /* !CONFIG_LIBPOSIX_FDTAB_MULTITAB */
 
 UK_EVENT_HANDLER_PRIO(POSIX_PROCESS_EXECVE_EVENT, fdtab_handle_execve,
                      UK_PRIO_EARLIEST);