Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/proc/prcontrol.c
          +++ new/usr/src/uts/common/fs/proc/prcontrol.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
  28      - * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
       28 + * Copyright 2015, Joyent, Inc.
  29   29   * Copyright 2023 Oxide Computer Company
  30   30   */
  31   31  
  32   32  #include <sys/types.h>
  33   33  #include <sys/uio.h>
  34   34  #include <sys/param.h>
  35   35  #include <sys/cmn_err.h>
  36   36  #include <sys/cred.h>
  37   37  #include <sys/policy.h>
  38   38  #include <sys/debug.h>
↓ open down ↓ 1566 lines elided ↑ open up ↑
1605 1605                                  } while ((tx = tx->t_forw) != p->p_tlist);
1606 1606                          }
1607 1607                  }
1608 1608                  thread_lock(t);
1609 1609                  if (ISWAKEABLE(t) || ISWAITING(t)) {
1610 1610                          /* Set signaled sleeping/waiting lwp running */
1611 1611                          setrun_locked(t);
1612 1612                  } else if (t->t_state == TS_STOPPED && sig == SIGKILL) {
1613 1613                          /* If SIGKILL, set stopped lwp running */
1614 1614                          p->p_stopsig = 0;
1615      -                        t->t_schedflag |= TS_XSTART | TS_PSTART;
     1615 +                        t->t_schedflag |= TS_XSTART | TS_PSTART | TS_BSTART;
1616 1616                          t->t_dtrace_stop = 0;
1617 1617                          setrun_locked(t);
1618 1618                  }
1619 1619                  t->t_sig_check = 1;     /* so ISSIG will be done */
1620 1620                  thread_unlock(t);
1621 1621                  /*
1622 1622                   * More jobcontrol side-effects.
1623 1623                   */
1624 1624                  if (sig == SIGCONT && (tx = p->p_tlist) != NULL) {
1625 1625                          p->p_stopsig = 0;
↓ open down ↓ 753 lines elided ↑ open up ↑
2379 2379          kthread_t *t;
2380 2380          cred_t *oldcred;
2381 2381          cred_t *newcred;
2382 2382          zone_t *zptr;
2383 2383          zoneid_t oldzoneid;
2384 2384  
2385 2385          if (secpolicy_zone_config(cr) != 0)
2386 2386                  return (EPERM);
2387 2387          if (zoneid != GLOBAL_ZONEID && zoneid != p->p_zone->zone_id)
2388 2388                  return (EINVAL);
2389      -        if ((zptr = zone_find_by_id(zoneid)) == NULL)
2390      -                return (EINVAL);
     2389 +        /*
     2390 +         * We cannot hold p_lock when we call zone_find_by_id since that can
     2391 +         * lead to a deadlock. zone_find_by_id() takes zonehash_lock.
     2392 +         * zone_enter() can hold the zonehash_lock and needs p_lock when it
     2393 +         * calls task_join.
     2394 +         */
2391 2395          mutex_exit(&p->p_lock);
     2396 +        if ((zptr = zone_find_by_id(zoneid)) == NULL) {
     2397 +                mutex_enter(&p->p_lock);
     2398 +                return (EINVAL);
     2399 +        }
2392 2400          mutex_enter(&p->p_crlock);
2393 2401          oldcred = p->p_cred;
2394 2402          crhold(oldcred);
2395 2403          mutex_exit(&p->p_crlock);
2396 2404          newcred = crdup(oldcred);
2397 2405          oldzoneid = crgetzoneid(oldcred);
2398 2406          crfree(oldcred);
2399 2407  
2400 2408          crsetzone(newcred, zptr);
2401 2409          zone_rele(zptr);
↓ open down ↓ 253 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX