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/solaris10/s10_brand.c
          +++ new/usr/src/uts/common/brand/solaris10/s10_brand.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
  24   24   * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
       25 + * Copyright 2016, Joyent, Inc.
  25   26   */
  26   27  
  27   28  #include <sys/errno.h>
  28   29  #include <sys/exec.h>
  29   30  #include <sys/file.h>
  30   31  #include <sys/kmem.h>
  31   32  #include <sys/modctl.h>
  32   33  #include <sys/model.h>
  33   34  #include <sys/proc.h>
  34   35  #include <sys/syscall.h>
↓ open down ↓ 3 lines elided ↑ open up ↑
  38   39  #include <sys/archsystm.h>
  39   40  #include <sys/pathname.h>
  40   41  #include <sys/sunddi.h>
  41   42  
  42   43  #include <sys/machbrand.h>
  43   44  #include <sys/brand.h>
  44   45  #include "s10_brand.h"
  45   46  
  46   47  char *s10_emulation_table = NULL;
  47   48  
  48      -void    s10_init_brand_data(zone_t *);
       49 +void    s10_init_brand_data(zone_t *, kmutex_t *);
  49   50  void    s10_free_brand_data(zone_t *);
  50   51  void    s10_setbrand(proc_t *);
  51   52  int     s10_getattr(zone_t *, int, void *, size_t *);
  52   53  int     s10_setattr(zone_t *, int, void *, size_t);
  53   54  int     s10_brandsys(int, int64_t *, uintptr_t, uintptr_t, uintptr_t,
  54      -                uintptr_t, uintptr_t, uintptr_t);
       55 +                uintptr_t);
  55   56  void    s10_copy_procdata(proc_t *, proc_t *);
  56      -void    s10_proc_exit(struct proc *, klwp_t *);
       57 +void    s10_proc_exit(struct proc *);
  57   58  void    s10_exec();
  58      -int     s10_initlwp(klwp_t *);
       59 +void    s10_initlwp(klwp_t *, void *);
  59   60  void    s10_forklwp(klwp_t *, klwp_t *);
  60   61  void    s10_freelwp(klwp_t *);
  61   62  void    s10_lwpexit(klwp_t *);
  62   63  int     s10_elfexec(vnode_t *, execa_t *, uarg_t *, intpdata_t *, int,
  63      -        long *, int, caddr_t, cred_t *, int);
       64 +        long *, int, caddr_t, cred_t *, int *);
  64   65  void    s10_sigset_native_to_s10(sigset_t *);
  65   66  void    s10_sigset_s10_to_native(sigset_t *);
  66   67  
  67   68  /* s10 brand */
  68   69  struct brand_ops s10_brops = {
  69      -        s10_init_brand_data,
  70      -        s10_free_brand_data,
  71      -        s10_brandsys,
  72      -        s10_setbrand,
  73      -        s10_getattr,
  74      -        s10_setattr,
  75      -        s10_copy_procdata,
  76      -        s10_proc_exit,
  77      -        s10_exec,
  78      -        lwp_setrval,
  79      -        s10_initlwp,
  80      -        s10_forklwp,
  81      -        s10_freelwp,
  82      -        s10_lwpexit,
  83      -        s10_elfexec,
  84      -        s10_sigset_native_to_s10,
  85      -        s10_sigset_s10_to_native,
  86      -        S10_NSIG,
       70 +        s10_init_brand_data,            /* b_init_brand_data */
       71 +        s10_free_brand_data,            /* b_free_brand_data */
       72 +        s10_brandsys,                   /* b_brandsys */
       73 +        s10_setbrand,                   /* b_setbrand */
       74 +        s10_getattr,                    /* b_getattr */
       75 +        s10_setattr,                    /* b_setattr */
       76 +        s10_copy_procdata,              /* b_copy_procdata */
       77 +        s10_proc_exit,                  /* b_proc_exit */
       78 +        s10_exec,                       /* b_exec */
       79 +        lwp_setrval,                    /* b_lwp_setrval */
       80 +        NULL,                           /* b_lwpdata_alloc */
       81 +        NULL,                           /* b_lwpdata_free */
       82 +        s10_initlwp,                    /* b_initlwp */
       83 +        NULL,                           /* b_initlwp_post */
       84 +        s10_forklwp,                    /* b_forklwp */
       85 +        s10_freelwp,                    /* b_freelwp */
       86 +        s10_lwpexit,                    /* b_lwpexit */
       87 +        s10_elfexec,                    /* b_elfexec */
       88 +        s10_sigset_native_to_s10,       /* b_sigset_native_to_brand */
       89 +        s10_sigset_s10_to_native,       /* b_sigset_brand_to_native */
       90 +        NULL,                           /* b_sigfd_translate */
       91 +        S10_NSIG,                       /* b_nsig */
       92 +        NULL,                           /* b_exit_with_sig */
       93 +        NULL,                           /* b_wait_filter */
       94 +        NULL,                           /* b_native_exec */
       95 +        NULL,                           /* b_map32limit */
       96 +        NULL,                           /* b_stop_notify */
       97 +        NULL,                           /* b_waitid_helper */
       98 +        NULL,                           /* b_sigcld_repost */
       99 +        NULL,                           /* b_issig_stop */
      100 +        NULL,                           /* b_sig_ignorable */
      101 +        NULL,                           /* b_savecontext */
      102 +#if defined(_SYSCALL32_IMPL)
      103 +        NULL,                           /* b_savecontext32 */
      104 +#endif
      105 +        NULL,                           /* b_restorecontext */
      106 +        NULL,                           /* b_sendsig_stack */
      107 +        NULL,                           /* b_sendsig */
      108 +        NULL,                           /* b_setid_clear */
      109 +        NULL,                           /* b_pagefault */
      110 +        B_TRUE                          /* b_intp_parse_arg */
  87  111  };
  88  112  
  89  113  #ifdef  sparc
  90  114  
  91  115  struct brand_mach_ops s10_mops = {
  92  116          s10_brand_syscall_callback,
  93  117          s10_brand_syscall32_callback
  94  118  };
  95  119  
  96  120  #else   /* sparc */
  97  121  
  98  122  #ifdef  __amd64
  99  123  
 100  124  struct brand_mach_ops s10_mops = {
 101  125          s10_brand_sysenter_callback,
      126 +        NULL,
 102  127          s10_brand_int91_callback,
 103  128          s10_brand_syscall_callback,
 104      -        s10_brand_syscall32_callback
      129 +        s10_brand_syscall32_callback,
      130 +        NULL,
      131 +        NULL
 105  132  };
 106  133  
 107  134  #else   /* ! __amd64 */
 108  135  
 109  136  struct brand_mach_ops s10_mops = {
 110  137          s10_brand_sysenter_callback,
 111  138          NULL,
      139 +        NULL,
 112  140          s10_brand_syscall_callback,
      141 +        NULL,
      142 +        NULL,
 113  143          NULL
 114  144  };
 115  145  #endif  /* __amd64 */
 116  146  
 117  147  #endif  /* _sparc */
 118  148  
 119  149  struct brand    s10_brand = {
 120  150          BRAND_VER_1,
 121  151          "solaris10",
 122  152          &s10_brops,
 123      -        &s10_mops
      153 +        &s10_mops,
      154 +        sizeof (brand_proc_data_t),
 124  155  };
 125  156  
 126  157  static struct modlbrand modlbrand = {
 127  158          &mod_brandops,          /* type of module */
 128  159          "Solaris 10 Brand",     /* description of module */
 129  160          &s10_brand              /* driver ops */
 130  161  };
 131  162  
 132  163  static struct modlinkage modlinkage = {
 133  164          MODREV_1, (void *)&modlbrand, NULL
↓ open down ↓ 108 lines elided ↑ open up ↑
 242  273                  return (0);
 243  274  
 244  275          mutex_enter(&curproc->p_lock);
 245  276          (void) strlcpy(up->u_comm, cmd_buf, sizeof (up->u_comm));
 246  277          (void) strlcpy(up->u_psargs, arg_buf, sizeof (up->u_psargs));
 247  278          mutex_exit(&curproc->p_lock);
 248  279  
 249  280          return (0);
 250  281  }
 251  282  
 252      -/*ARGSUSED*/
      283 +/* ARGSUSED5 */
 253  284  int
 254  285  s10_brandsys(int cmd, int64_t *rval, uintptr_t arg1, uintptr_t arg2,
 255      -    uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, uintptr_t arg6)
      286 +    uintptr_t arg3, uintptr_t arg4)
 256  287  {
 257  288          proc_t  *p = curproc;
 258  289          int     res;
 259  290  
 260  291          *rval = 0;
 261  292  
 262  293          if (cmd == B_S10_NATIVE)
 263  294                  return (s10_native((void *)arg1, (void *)arg2));
 264  295  
 265  296          res = brand_solaris_cmd(cmd, arg1, arg2, arg3, &s10_brand, S10_VERSION);
↓ open down ↓ 53 lines elided ↑ open up ↑
 319  350          return (EINVAL);
 320  351  }
 321  352  
 322  353  void
 323  354  s10_copy_procdata(proc_t *child, proc_t *parent)
 324  355  {
 325  356          brand_solaris_copy_procdata(child, parent, &s10_brand);
 326  357  }
 327  358  
 328  359  void
 329      -s10_proc_exit(struct proc *p, klwp_t *l)
      360 +s10_proc_exit(struct proc *p)
 330  361  {
 331      -        brand_solaris_proc_exit(p, l, &s10_brand);
      362 +        brand_solaris_proc_exit(p, &s10_brand);
 332  363  }
 333  364  
 334  365  void
 335  366  s10_exec()
 336  367  {
 337  368          brand_solaris_exec(&s10_brand);
 338  369  }
 339  370  
 340      -int
 341      -s10_initlwp(klwp_t *l)
      371 +/* ARGSUSED */
      372 +void
      373 +s10_initlwp(klwp_t *l, void *bd)
 342  374  {
 343      -        return (brand_solaris_initlwp(l, &s10_brand));
      375 +        brand_solaris_initlwp(l, &s10_brand);
 344  376  }
 345  377  
 346  378  void
 347  379  s10_forklwp(klwp_t *p, klwp_t *c)
 348  380  {
 349  381          brand_solaris_forklwp(p, c, &s10_brand);
 350  382  
 351  383  #ifdef  __amd64
 352  384          /*
 353  385           * Only correct the child's %fs register if the parent's %fs register
↓ open down ↓ 18 lines elided ↑ open up ↑
 372  404  {
 373  405          brand_solaris_lwpexit(l, &s10_brand);
 374  406  }
 375  407  
 376  408  void
 377  409  s10_free_brand_data(zone_t *zone)
 378  410  {
 379  411          kmem_free(zone->zone_brand_data, sizeof (s10_zone_data_t));
 380  412  }
 381  413  
      414 +/* ARGSUSED */
 382  415  void
 383      -s10_init_brand_data(zone_t *zone)
      416 +s10_init_brand_data(zone_t *zone, kmutex_t *zsl)
 384  417  {
 385  418          ASSERT(zone->zone_brand == &s10_brand);
 386  419          ASSERT(zone->zone_brand_data == NULL);
 387  420          zone->zone_brand_data = kmem_zalloc(sizeof (s10_zone_data_t), KM_SLEEP);
 388  421  }
 389  422  
 390  423  int
 391  424  s10_elfexec(vnode_t *vp, execa_t *uap, uarg_t *args, intpdata_t *idatap,
 392      -        int level, long *execsz, int setid, caddr_t exec_file, cred_t *cred,
 393      -        int brand_action)
      425 +    int level, long *execsz, int setid, caddr_t exec_file, cred_t *cred,
      426 +    int *brand_action)
 394  427  {
 395  428          return (brand_solaris_elfexec(vp, uap, args, idatap, level, execsz,
 396  429              setid, exec_file, cred, brand_action, &s10_brand, S10_BRANDNAME,
 397      -            S10_LIB, S10_LIB32, S10_LINKER, S10_LINKER32));
      430 +            S10_LIB, S10_LIB32));
 398  431  }
 399  432  
 400  433  void
 401  434  s10_sigset_native_to_s10(sigset_t *set)
 402  435  {
 403  436          int nativesig;
 404  437          int s10sig;
 405  438          sigset_t s10set;
 406  439  
 407  440          /*
↓ open down ↓ 176 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX