signals: Fix signal during exit block bug
authorAlan Cox <alan@linux.intel.com>
Sun, 30 Oct 2016 10:46:09 +0000 (10:46 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 30 Oct 2016 10:46:09 +0000 (10:46 +0000)
Issue #449 from Bret. Slightly extended from Bret's fix to ensure no further
signals also try and get themselves delivered.

Kernel/process.c

index c46cdf7..34799dd 100644 (file)
@@ -497,10 +497,15 @@ rescan:
                                /* Other things may have happened */
                                goto rescan;
                        }
+
+                       /* The signal is being handled, so clear it even if
+                          we are exiting (otherwise we'll loop in
+                          chksigs) */
+                       udata.u_ptab->p_pending &= ~m;
+
                        if ((m & clear) || udata.u_ptab->p_pid == 1) {
                        /* SIGCONT is subtle - we woke the process to handle
                           the signal so ignoring here works fine */
-                               udata.u_ptab->p_pending &= ~m;  // unset the bit
                                continue;
                        }
 #ifdef DEBUG
@@ -633,6 +638,11 @@ void doexit(uint16_t val)
 
        irq = di();
 
+       /* We are exiting, hold all signals  (they will never be
+          delivered). If we don't do this we might take a signal
+          while exiting which would be ... unfortunate */
+       udata.u_ptab->p_held = 0xFFFFFFFFUL;
+
        /* Discard our memory before we blow away and reuse the memory */
        pagemap_free(udata.u_ptab);