⬢ DragonFlyBSD Kernel Audit
DF-5611 / fix.diff
← back to finding ↓ download raw
--- a/sys/platform/vkernel64/platform/machintr.c
+++ b/sys/platform/vkernel64/platform/machintr.c
@@ -186,13 +186,25 @@
 }
 
 /*
+ * Block every host signal whose installed handler dereferences mycpu (%gs)
+ * or dispatches a virtual interrupt.  SIGXCPU must be included: stopsig()
+ * (exception.c) dereferences mycpu and must never run on a cothread
+ * (%gs == 0, cothread.c tls_set_gs(0)) or on a vCPU thread created by
+ * start_all_aps() before init_secondary()'s tls_set_gs().
+ *
+ * This does not interfere with the stop protocol: stop_cpus()/
+ * restart_cpus() pthread_kill() only vCPU threads (ap_tids[]), and a
+ * running vCPU unblocks everything at cpu_idle entry (cpu_enable_intr ->
+ * sigsetmask(0), cpu_regs.c).  stopsig's own sigsuspend(&ss) set never
+ * contained SIGXCPU, so a stopped vCPU can still be woken.
+ *
  * Must block any signal normally handled as maskable interrupt.
  */
 void
 cpu_disable_intr(void)
 {
 	sigblock(sigmask(SIGALRM)|sigmask(SIGIO)|sigmask(SIGUSR1)|
-		 sigmask(SIGURG));
+		 sigmask(SIGURG)|sigmask(SIGXCPU));
 }
 
 void
@@ -206,7 +218,7 @@
 {
 	sigblock(sigmask(SIGALRM)|sigmask(SIGIO)|sigmask(SIGQUIT)|
 		 sigmask(SIGUSR1)|sigmask(SIGTERM)|sigmask(SIGWINCH)|
-		 sigmask(SIGUSR2)|sigmask(SIGURG));
+		 sigmask(SIGUSR2)|sigmask(SIGURG)|sigmask(SIGXCPU));
 }
 
 void