Print this page
OS-4144 panic in lx_freelwp during zone shutdown
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
        
@@ -25,11 +25,11 @@
 
 /*      Copyright (c) 1988 AT&T */
 /*        All Rights Reserved   */
 
 /*
- * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright 2015, Joyent, Inc.
  */
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/sysmacros.h>
@@ -155,11 +155,11 @@
         boolean_t in_arg;
         int argc = 0;
         int error = 0, count = 0;
         proc_t *p = ttoproc(curthread);
         klwp_t *lwp = ttolwp(curthread);
-        int brand_action;
+        int brand_action = EBA_NONE;
 
         if (args == NULL)
                 args = "";
 
         alen = strlen(initpath) + 1 + strlen(args) + 1;
@@ -266,11 +266,19 @@
          * parent process's signal mask.  Clear it now so that we behave in
          * the same way as when started from the global zone.
          */
         sigemptyset(&curthread->t_hold);
 
-        brand_action = ZONE_IS_BRANDED(p->p_zone) ? EBA_BRAND : EBA_NONE;
+        /*
+         * Only instruct exec_common to brand the process if necessary.  It is
+         * possible that the init process is already properly branded due to the
+         * proc_exit -> restart_init -> exec_init call chain.
+         */
+        if (ZONE_IS_BRANDED(p->p_zone) &&
+            p->p_brand != p->p_zone->zone_brand) {
+                brand_action = EBA_BRAND;
+        }
 again:
         error = exec_common((const char *)(uintptr_t)exec_fnamep,
             (const char **)(uintptr_t)uap, NULL, brand_action);
 
         /*