Print this page
    
Reduce lint
OS-5462 lxbrand kernel should be lint clean
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
OS-5354 lx shebang argument handling is incorrect
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
OS-5189 lx dev enumeration can deadlock with zfs
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
OS-4937 lxbrand ptracer count updates can race
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-3742 lxbrand add support for signalfd
OS-4382 remove obsolete brand hooks added during lx development
OS-4306 lxbrand setsockopt(IP_MULTICAST_TTL) handles optlen poorly
OS-4303 lxbrand ltp ptrace05 fails
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-4188 NULL dereference in lwp_hash_in
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-4119 lxbrand panic when running native perl inside lx zone
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
OS-4151 setbrand hooks should be sane during fork
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-4129 lxbrand should not abuse p_brand_data for storing exit signal
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
OS-3825 lxbrand rsyslogd abort on centos6
OS-4047 lxbrand vsyscall while SIGSEGV? on next trap we're handler-free!
Reviewed by: Bryan Cantrill <bryan@joyent.com>
OS-3926 lxbrand in-kernel fchownat(2), fchown(2), lchown(2), chown(2) and 16-bit ID counterparts
OS-3920 lxbrand use native *at(2) system calls for LX emulation
OS-3561 lxbrand emulation library should execute on alternate stack
OS-3558 lxbrand add support for full in-kernel syscall handling
OS-3545 lx_syscall_regs should not walk stack
OS-3868 many LTP testcases now hang
OS-3901 lxbrand lx_recvmsg fails to translate control messages when 64-bit
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Bryan Cantrill <bryan@joyent.com>
OS-3712 lx brand: DTrace pid provider induces core dumps on 64-bit processes
OS-3594 lx brand: need support for MAP_32BIT
OS-3554 lx brand: node.js test test-fs-append-file.js hangs on 64-bit
OS-3517 lx brand: branded zones don't interpret .interp section
OS-2844 lx brand should support 64-bit user-land
OS-3280 need a way to specify the root of a native system in the lx brand
OS-3279 lx brand should allow delegated datasets
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
OS-3149 lx brand always sends SIGCHLD to parent processes, regardless of how clone was invoked
OS-2887 lxbrand add WALL, WCLONE, WNOTHREAD support to waitid
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
OS-2834 ship lx brand
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/brand/sn1/sn1_brand.c
          +++ new/usr/src/uts/common/brand/sn1/sn1_brand.c
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  
    | 
      ↓ 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  /*
  23   23   * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright 2016 Joyent, Inc.
  24   25   */
  25   26  
  26   27  #include <sys/errno.h>
  27   28  #include <sys/exec.h>
  28   29  #include <sys/kmem.h>
  29   30  #include <sys/modctl.h>
  30   31  #include <sys/model.h>
  31   32  #include <sys/proc.h>
  32   33  #include <sys/syscall.h>
  33   34  #include <sys/systm.h>
  34   35  #include <sys/thread.h>
  
    | 
      ↓ open down ↓ | 
    1 lines elided | 
    
      ↑ open up ↑ | 
  
  35   36  #include <sys/cmn_err.h>
  36   37  #include <sys/archsystm.h>
  37   38  #include <sys/pathname.h>
  38   39  
  39   40  #include <sys/machbrand.h>
  40   41  #include <sys/brand.h>
  41   42  #include "sn1_brand.h"
  42   43  
  43   44  char *sn1_emulation_table = NULL;
  44   45  
  45      -void    sn1_init_brand_data(zone_t *);
       46 +void    sn1_init_brand_data(zone_t *, kmutex_t *);
  46   47  void    sn1_free_brand_data(zone_t *);
  47   48  void    sn1_setbrand(proc_t *);
  48   49  int     sn1_getattr(zone_t *, int, void *, size_t *);
  49   50  int     sn1_setattr(zone_t *, int, void *, size_t);
  50   51  int     sn1_brandsys(int, int64_t *, uintptr_t, uintptr_t, uintptr_t,
  51      -                uintptr_t, uintptr_t, uintptr_t);
       52 +                uintptr_t);
  52   53  void    sn1_copy_procdata(proc_t *, proc_t *);
  53      -void    sn1_proc_exit(struct proc *, klwp_t *);
       54 +void    sn1_proc_exit(struct proc *);
  54   55  void    sn1_exec();
  55      -int     sn1_initlwp(klwp_t *);
       56 +void    sn1_initlwp(klwp_t *, void *);
  56   57  void    sn1_forklwp(klwp_t *, klwp_t *);
  57   58  void    sn1_freelwp(klwp_t *);
  58   59  void    sn1_lwpexit(klwp_t *);
  59   60  int     sn1_elfexec(vnode_t *, execa_t *, uarg_t *, intpdata_t *, int,
  60      -        long *, int, caddr_t, cred_t *, int);
       61 +        long *, int, caddr_t, cred_t *, int *);
  61   62  
  62   63  /* sn1 brand */
  63   64  struct brand_ops sn1_brops = {
  64      -        sn1_init_brand_data,
  65      -        sn1_free_brand_data,
  66      -        sn1_brandsys,
  67      -        sn1_setbrand,
  68      -        sn1_getattr,
  69      -        sn1_setattr,
  70      -        sn1_copy_procdata,
  71      -        sn1_proc_exit,
  72      -        sn1_exec,
  73      -        lwp_setrval,
  74      -        sn1_initlwp,
  75      -        sn1_forklwp,
  76      -        sn1_freelwp,
  77      -        sn1_lwpexit,
  78      -        sn1_elfexec,
  79      -        NULL,
  80      -        NULL,
  81      -        NSIG,
       65 +        sn1_init_brand_data,            /* b_init_brand_data */
       66 +        sn1_free_brand_data,            /* b_free_brand_data */
       67 +        sn1_brandsys,                   /* b_brandsys */
       68 +        sn1_setbrand,                   /* b_setbrand */
       69 +        sn1_getattr,                    /* b_getattr */
       70 +        sn1_setattr,                    /* b_setattr */
       71 +        sn1_copy_procdata,              /* b_copy_procdata */
       72 +        sn1_proc_exit,                  /* b_proc_exit */
       73 +        sn1_exec,                       /* b_exec */
       74 +        lwp_setrval,                    /* b_lwp_setrval */
       75 +        NULL,                           /* b_lwpdata_alloc */
       76 +        NULL,                           /* b_lwpdata_free */
       77 +        sn1_initlwp,                    /* b_initlwp */
       78 +        NULL,                           /* b_initlwp_post */
       79 +        sn1_forklwp,                    /* b_forklwp */
       80 +        sn1_freelwp,                    /* b_freelwp */
       81 +        sn1_lwpexit,                    /* b_lwpexit */
       82 +        sn1_elfexec,                    /* b_elfexec */
       83 +        NULL,                           /* b_sigset_native_to_brand */
       84 +        NULL,                           /* b_sigset_brand_to_native */
       85 +        NULL,                           /* b_sigfd_translate */
       86 +        NSIG,                           /* b_nsig */
       87 +        NULL,                           /* b_exit_with_sig */
       88 +        NULL,                           /* b_wait_filter */
       89 +        NULL,                           /* b_native_exec */
       90 +        NULL,                           /* b_map32limit */
       91 +        NULL,                           /* b_stop_notify */
       92 +        NULL,                           /* b_waitid_helper */
       93 +        NULL,                           /* b_sigcld_repost */
       94 +        NULL,                           /* b_issig_stop */
       95 +        NULL,                           /* b_sig_ignorable */
       96 +        NULL,                           /* b_savecontext */
       97 +#if defined(_SYSCALL32_IMPL)
       98 +        NULL,                           /* b_savecontext32 */
       99 +#endif
      100 +        NULL,                           /* b_restorecontext */
      101 +        NULL,                           /* b_sendsig_stack */
      102 +        NULL,                           /* b_sendsig */
      103 +        NULL,                           /* b_setid_clear */
      104 +        NULL,                           /* b_pagefault */
      105 +        B_TRUE                          /* b_intp_parse_arg */
  82  106  };
  83  107  
  84  108  #ifdef  sparc
  85  109  
  86  110  struct brand_mach_ops sn1_mops = {
  87  111          sn1_brand_syscall_callback,
  88  112          sn1_brand_syscall32_callback
  89  113  };
  90  114  
  91  115  #else   /* sparc */
  92  116  
  93  117  #ifdef  __amd64
  94  118  
  95  119  struct brand_mach_ops sn1_mops = {
  96  120          sn1_brand_sysenter_callback,
      121 +        NULL,
  97  122          sn1_brand_int91_callback,
  98  123          sn1_brand_syscall_callback,
  99      -        sn1_brand_syscall32_callback
      124 +        sn1_brand_syscall32_callback,
      125 +        NULL,
      126 +        NULL
 100  127  };
 101  128  
 102  129  #else   /* ! __amd64 */
 103  130  
 104  131  struct brand_mach_ops sn1_mops = {
 105  132          sn1_brand_sysenter_callback,
 106  133          NULL,
      134 +        NULL,
 107  135          sn1_brand_syscall_callback,
      136 +        NULL,
      137 +        NULL,
 108  138          NULL
 109  139  };
 110  140  #endif  /* __amd64 */
 111  141  
 112  142  #endif  /* _sparc */
 113  143  
 114  144  struct brand    sn1_brand = {
 115  145          BRAND_VER_1,
 116  146          "sn1",
 117  147          &sn1_brops,
 118      -        &sn1_mops
      148 +        &sn1_mops,
      149 +        sizeof (brand_proc_data_t),
 119  150  };
 120  151  
 121  152  static struct modlbrand modlbrand = {
 122  153          &mod_brandops,          /* type of module */
 123  154          "Solaris N-1 Brand",    /* description of module */
 124  155          &sn1_brand              /* driver ops */
 125  156  };
 126  157  
 127  158  static struct modlinkage modlinkage = {
 128  159          MODREV_1, (void *)&modlbrand, NULL
 129  160  };
 130  161  
 131  162  void
 132  163  sn1_setbrand(proc_t *p)
 133  164  {
 134  165          brand_solaris_setbrand(p, &sn1_brand);
 135  166  }
 136  167  
 137  168  /* ARGSUSED */
 138  169  int
 139  170  sn1_getattr(zone_t *zone, int attr, void *buf, size_t *bufsize)
 140  171  {
  
    | 
      ↓ open down ↓ | 
    12 lines elided | 
    
      ↑ open up ↑ | 
  
 141  172          return (EINVAL);
 142  173  }
 143  174  
 144  175  /* ARGSUSED */
 145  176  int
 146  177  sn1_setattr(zone_t *zone, int attr, void *buf, size_t bufsize)
 147  178  {
 148  179          return (EINVAL);
 149  180  }
 150  181  
 151      -/*ARGSUSED*/
      182 +/* ARGSUSED5 */
 152  183  int
 153  184  sn1_brandsys(int cmd, int64_t *rval, uintptr_t arg1, uintptr_t arg2,
 154      -    uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, uintptr_t arg6)
      185 +    uintptr_t arg3, uintptr_t arg4)
 155  186  {
 156  187          int     res;
 157  188  
 158  189          *rval = 0;
 159  190  
 160  191          res = brand_solaris_cmd(cmd, arg1, arg2, arg3, &sn1_brand, SN1_VERSION);
 161  192          if (res >= 0)
 162  193                  return (res);
 163  194  
 164  195          return (EINVAL);
 165  196  }
 166  197  
 167  198  void
 168  199  sn1_copy_procdata(proc_t *child, proc_t *parent)
 169  200  {
 170  201          brand_solaris_copy_procdata(child, parent, &sn1_brand);
 171  202  }
 172  203  
 173  204  void
 174      -sn1_proc_exit(struct proc *p, klwp_t *l)
      205 +sn1_proc_exit(struct proc *p)
 175  206  {
 176      -        brand_solaris_proc_exit(p, l, &sn1_brand);
      207 +        brand_solaris_proc_exit(p, &sn1_brand);
 177  208  }
 178  209  
 179  210  void
 180  211  sn1_exec()
 181  212  {
 182  213          brand_solaris_exec(&sn1_brand);
 183  214  }
 184  215  
 185      -int
 186      -sn1_initlwp(klwp_t *l)
      216 +/* ARGSUSED */
      217 +void
      218 +sn1_initlwp(klwp_t *l, void *bd)
 187  219  {
 188      -        return (brand_solaris_initlwp(l, &sn1_brand));
      220 +        brand_solaris_initlwp(l, &sn1_brand);
 189  221  }
 190  222  
 191  223  void
 192  224  sn1_forklwp(klwp_t *p, klwp_t *c)
 193  225  {
 194  226          brand_solaris_forklwp(p, c, &sn1_brand);
 195  227  }
 196  228  
 197  229  void
 198  230  sn1_freelwp(klwp_t *l)
 199  231  {
 200  232          brand_solaris_freelwp(l, &sn1_brand);
 201  233  }
 202  234  
 203  235  void
 204  236  sn1_lwpexit(klwp_t *l)
 205  237  {
 206  238          brand_solaris_lwpexit(l, &sn1_brand);
  
    | 
      ↓ open down ↓ | 
    8 lines elided | 
    
      ↑ open up ↑ | 
  
 207  239  }
 208  240  
 209  241  /*ARGSUSED*/
 210  242  void
 211  243  sn1_free_brand_data(zone_t *zone)
 212  244  {
 213  245  }
 214  246  
 215  247  /*ARGSUSED*/
 216  248  void
 217      -sn1_init_brand_data(zone_t *zone)
      249 +sn1_init_brand_data(zone_t *zone, kmutex_t *zsl)
 218  250  {
 219  251  }
 220  252  
 221  253  int
 222  254  sn1_elfexec(vnode_t *vp, execa_t *uap, uarg_t *args, intpdata_t *idatap,
 223      -        int level, long *execsz, int setid, caddr_t exec_file, cred_t *cred,
 224      -        int brand_action)
      255 +    int level, long *execsz, int setid, caddr_t exec_file, cred_t *cred,
      256 +    int *brand_action)
 225  257  {
 226  258          return (brand_solaris_elfexec(vp, uap, args, idatap, level, execsz,
 227  259              setid, exec_file, cred, brand_action, &sn1_brand, SN1_BRANDNAME,
 228      -            SN1_LIB, SN1_LIB32, SN1_LINKER, SN1_LINKER32));
      260 +            SN1_LIB, SN1_LIB32));
 229  261  }
 230  262  
 231  263  int
 232  264  _init(void)
 233  265  {
 234  266          int err;
 235  267  
 236  268          /*
 237  269           * Set up the table indicating which system calls we want to
 238  270           * interpose on.  We should probably build this automatically from
 239  271           * a list of system calls that is shared with the user-space
 240  272           * library.
 241  273           */
 242  274          sn1_emulation_table = kmem_zalloc(NSYSCALL, KM_SLEEP);
 243  275          sn1_emulation_table[SYS_read] = 1;                      /*   3 */
 244  276          sn1_emulation_table[SYS_write] = 1;                     /*   4 */
 245  277          sn1_emulation_table[SYS_time] = 1;                      /*  13 */
 246  278          sn1_emulation_table[SYS_getpid] = 1;                    /*  20 */
 247  279          sn1_emulation_table[SYS_mount] = 1;                     /*  21 */
 248  280          sn1_emulation_table[SYS_getuid] = 1;                    /*  24 */
 249  281          sn1_emulation_table[SYS_times] = 1;                     /*  43 */
 250  282          sn1_emulation_table[SYS_getgid] = 1;                    /*  47 */
 251  283          sn1_emulation_table[SYS_utssys] = 1;                    /*  57 */
 252  284          sn1_emulation_table[SYS_waitid] = 1;                    /* 107 */
 253  285          sn1_emulation_table[SYS_uname] = 1;                     /* 135 */
 254  286  
 255  287          err = mod_install(&modlinkage);
 256  288          if (err) {
 257  289                  cmn_err(CE_WARN, "Couldn't install brand module");
 258  290                  kmem_free(sn1_emulation_table, NSYSCALL);
 259  291          }
 260  292  
 261  293          return (err);
 262  294  }
 263  295  
 264  296  int
 265  297  _info(struct modinfo *modinfop)
 266  298  {
 267  299          return (mod_info(&modlinkage, modinfop));
 268  300  }
 269  301  
 270  302  int
 271  303  _fini(void)
 272  304  {
 273  305          return (brand_solaris_fini(&sn1_emulation_table, &modlinkage,
 274  306              &sn1_brand));
 275  307  }
  
    | 
      ↓ open down ↓ | 
    37 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX