Print this page
OS-4144 panic in lx_freelwp during zone shutdown
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/main.c
          +++ new/usr/src/uts/common/os/main.c
↓ open down ↓ 19 lines elided ↑ open up ↑
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
  26   26  /*      Copyright (c) 1988 AT&T */
  27   27  /*        All Rights Reserved   */
  28   28  
  29   29  /*
  30      - * Copyright (c) 2013, Joyent, Inc. All rights reserved.
       30 + * Copyright 2015, Joyent, Inc.
  31   31   */
  32   32  
  33   33  #include <sys/types.h>
  34   34  #include <sys/param.h>
  35   35  #include <sys/sysmacros.h>
  36   36  #include <sys/pcb.h>
  37   37  #include <sys/systm.h>
  38   38  #include <sys/signal.h>
  39   39  #include <sys/cred.h>
  40   40  #include <sys/user.h>
↓ open down ↓ 109 lines elided ↑ open up ↑
 150  150          caddr32_t *argv;
 151  151          caddr32_t exec_fnamep;
 152  152          char *scratchargs;
 153  153          int i, sarg;
 154  154          size_t argvlen, alen;
 155  155          boolean_t in_arg;
 156  156          int argc = 0;
 157  157          int error = 0, count = 0;
 158  158          proc_t *p = ttoproc(curthread);
 159  159          klwp_t *lwp = ttolwp(curthread);
 160      -        int brand_action;
      160 +        int brand_action = EBA_NONE;
 161  161  
 162  162          if (args == NULL)
 163  163                  args = "";
 164  164  
 165  165          alen = strlen(initpath) + 1 + strlen(args) + 1;
 166  166          scratchargs = kmem_alloc(alen, KM_SLEEP);
 167  167          (void) snprintf(scratchargs, alen, "%s %s", initpath, args);
 168  168  
 169  169          /*
 170  170           * We do a quick two state parse of the string to sort out how big
↓ open down ↓ 90 lines elided ↑ open up ↑
 261  261          curthread->t_post_sys = 1;
 262  262          curthread->t_sysnum = SYS_execve;
 263  263  
 264  264          /*
 265  265           * If we are executing init from zsched, we may have inherited its
 266  266           * parent process's signal mask.  Clear it now so that we behave in
 267  267           * the same way as when started from the global zone.
 268  268           */
 269  269          sigemptyset(&curthread->t_hold);
 270  270  
 271      -        brand_action = ZONE_IS_BRANDED(p->p_zone) ? EBA_BRAND : EBA_NONE;
      271 +        /*
      272 +         * Only instruct exec_common to brand the process if necessary.  It is
      273 +         * possible that the init process is already properly branded due to the
      274 +         * proc_exit -> restart_init -> exec_init call chain.
      275 +         */
      276 +        if (ZONE_IS_BRANDED(p->p_zone) &&
      277 +            p->p_brand != p->p_zone->zone_brand) {
      278 +                brand_action = EBA_BRAND;
      279 +        }
 272  280  again:
 273  281          error = exec_common((const char *)(uintptr_t)exec_fnamep,
 274  282              (const char **)(uintptr_t)uap, NULL, brand_action);
 275  283  
 276  284          /*
 277  285           * Normally we would just set lwp_argsaved and t_post_sys and
 278  286           * let post_syscall reset lwp_ap for us.  Unfortunately,
 279  287           * exec_init isn't always called from a system call.  Instead
 280  288           * of making a mess of trap_cleanup, we just reset the args
 281  289           * pointer here.
↓ open down ↓ 373 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX