⬢ DragonFlyBSD Kernel Audit
DF-5201 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/kern/lwkt_thread.c b/sys/kern/lwkt_thread.c
--- a/sys/kern/lwkt_thread.c
+++ b/sys/kern/lwkt_thread.c
@@ -1692,6 +1692,15 @@ lwkt_exit(void)
      */
     biosched_done(td);
     dsched_exit_thread(td);
+    /*
+     * Release any LinuxKPI task_struct installed on this thread.
+     * Pure kernel threads never pass through lwp_exit(), so without
+     * this hook linux_task_alloc()'s task would leak forever and the
+     * parked gd_freetd td would keep a stale td_linux_task back-pointer
+     * (cleared only later by lwkt_init_thread()'s bzero on reuse).
+     */
+    if (td->td_linux_task && linux_task_drop_callback)
+	linux_task_drop_callback(td);
 
     /*
      * Get us into a critical section to interlock gd_freetd and loop