Print this page
Extra lint fixes
OS-5642 containerbuddy unable to fork while using syslog driver, causing container services to hang
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Patrick Mooney <patrick.mooney@joyent.com>
OS-4781 would like to be able to add CT_PR_EV_EXIT to fatal event set of current contract

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/contract/process.c
          +++ new/usr/src/uts/common/contract/process.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + * Copyright 2016 Joyent, Inc.
  24   25   */
  25   26  
  26   27  #include <sys/mutex.h>
  27   28  #include <sys/debug.h>
  28   29  #include <sys/types.h>
  29   30  #include <sys/param.h>
  30   31  #include <sys/kmem.h>
  31   32  #include <sys/thread.h>
  32   33  #include <sys/id_space.h>
  33   34  #include <sys/avl.h>
↓ open down ↓ 914 lines elided ↑ open up ↑
 948  949                  VERIFY(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) == 0);
 949  950                  VERIFY(nvlist_add_uint32(nvl, CTPE_PID, p->p_pid) == 0);
 950  951                  VERIFY(nvlist_add_int32(nvl, CTPE_EXITSTATUS, exitstatus) == 0);
 951  952  
 952  953                  event = kmem_zalloc(sizeof (ct_kevent_t), KM_SLEEP);
 953  954                  event->cte_flags = EVINFOP(ctp, CT_PR_EV_EXIT) ? CTE_INFO : 0;
 954  955                  event->cte_type = CT_PR_EV_EXIT;
 955  956                  (void) cte_publish_all(ct, event, nvl, NULL);
 956  957                  mutex_enter(&ct->ct_lock);
 957  958          }
      959 +
      960 +        /*
      961 +         * CT_PR_EV_EXIT is not part of the CT_PR_ALLFATAL definition since
      962 +         * we never allow including this in the fatal set via a user-land
      963 +         * application, but we do allow CT_PR_EV_EXIT in the contract's fatal
      964 +         * set for a process setup for zone init. See zone_start_init().
      965 +         */
      966 +        if (EVFATALP(ctp, CT_PR_EV_EXIT)) {
      967 +                ASSERT(MUTEX_HELD(&ct->ct_lock));
      968 +                contract_process_kill(ct, p, B_TRUE);
      969 +        }
      970 +
 958  971          if (empty) {
 959  972                  /*
 960  973                   * Send EMPTY message.
 961  974                   */
 962  975                  if (EVSENDP(ctp, CT_PR_EV_EMPTY)) {
 963  976                          nvlist_t *nvl;
 964  977  
 965  978                          mutex_exit(&ct->ct_lock);
 966  979                          VERIFY(nvlist_alloc(&nvl, NV_UNIQUE_NAME,
 967  980                              KM_SLEEP) == 0);
↓ open down ↓ 82 lines elided ↑ open up ↑
1050 1063  
1051 1064                  VERIFY(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) == 0);
1052 1065                  VERIFY(nvlist_add_uint32(nvl, CTPE_PID, cp->p_pid) == 0);
1053 1066                  VERIFY(nvlist_add_uint32(nvl, CTPE_PPID, pp->p_pid) == 0);
1054 1067  
1055 1068                  event = kmem_zalloc(sizeof (ct_kevent_t), KM_SLEEP);
1056 1069                  event->cte_flags = EVINFOP(ctp, CT_PR_EV_FORK) ? CTE_INFO : 0;
1057 1070                  event->cte_type = CT_PR_EV_FORK;
1058 1071                  (void) cte_publish_all(ct, event, nvl, NULL);
1059 1072          }
     1073 +
     1074 +        /*
     1075 +         * Because the CT_PR_KEEP_EXEC flag is meant to be used by applications
     1076 +         * which are not contract aware, we can assume that these applications
     1077 +         * will never explicitly abandon the child's new contract. Thus, we
     1078 +         * abandon it now.
     1079 +         */
     1080 +        if (ctp->conp_params & CT_PR_KEEP_EXEC) {
     1081 +                (void) contract_abandon(ct, pp, 1);
     1082 +        }
     1083 +
1060 1084          return (ctp);
1061 1085  }
1062 1086  
1063 1087  /*
1064 1088   * contract_process_core
1065 1089   *
1066 1090   * Called on core file generation attempts.  Generates a core event, if
1067 1091   * requested, containing the names of the process, global, and
1068 1092   * system-global ("zone") core files.  If dumping core is in the fatal
1069 1093   * event set, calls contract_process_kill().
↓ open down ↓ 126 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX