Print this page
7029 want per-process exploit mitigation features (secflags)
7030 want basic address space layout randomization (aslr)
7031 noexec_user_stack should be a secflag
7032 want a means to forbid mappings around NULL.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/zone.c
          +++ new/usr/src/uts/common/os/zone.c
↓ open down ↓ 2072 lines elided ↑ open up ↑
2073 2073          zone0.zone_max_lofi_ctl = UINT64_MAX;
2074 2074          zone0.zone_shmmax = 0;
2075 2075          zone0.zone_ipc.ipcq_shmmni = 0;
2076 2076          zone0.zone_ipc.ipcq_semmni = 0;
2077 2077          zone0.zone_ipc.ipcq_msgmni = 0;
2078 2078          zone0.zone_name = GLOBAL_ZONENAME;
2079 2079          zone0.zone_nodename = utsname.nodename;
2080 2080          zone0.zone_domain = srpc_domain;
2081 2081          zone0.zone_hostid = HW_INVALID_HOSTID;
2082 2082          zone0.zone_fs_allowed = NULL;
     2083 +        psecflags_default(&zone0.zone_secflags);
2083 2084          zone0.zone_ref = 1;
2084 2085          zone0.zone_id = GLOBAL_ZONEID;
2085 2086          zone0.zone_status = ZONE_IS_RUNNING;
2086 2087          zone0.zone_rootpath = "/";
2087 2088          zone0.zone_rootpathlen = 2;
2088 2089          zone0.zone_psetid = ZONE_PS_INVAL;
2089 2090          zone0.zone_ncpus = 0;
2090 2091          zone0.zone_ncpus_online = 0;
2091 2092          zone0.zone_proc_initpid = 1;
2092 2093          zone0.zone_initname = initname;
↓ open down ↓ 427 lines elided ↑ open up ↑
2520 2521  
2521 2522          /* set up the brand specific data */
2522 2523          zone->zone_brand = bp;
2523 2524          ZBROP(zone)->b_init_brand_data(zone);
2524 2525  
2525 2526          mutex_exit(&zone_status_lock);
2526 2527          return (0);
2527 2528  }
2528 2529  
2529 2530  static int
     2531 +zone_set_secflags(zone_t *zone, const psecflags_t *zone_secflags)
     2532 +{
     2533 +        int err = 0;
     2534 +        psecflags_t psf;
     2535 +
     2536 +        ASSERT(zone != global_zone);
     2537 +
     2538 +        if ((err = copyin(zone_secflags, &psf, sizeof (psf))) != 0)
     2539 +                return (err);
     2540 +
     2541 +        if (zone_status_get(zone) > ZONE_IS_READY)
     2542 +                return (EINVAL);
     2543 +
     2544 +        if (!psecflags_validate(&psf))
     2545 +                return (EINVAL);
     2546 +
     2547 +        (void) memcpy(&zone->zone_secflags, &psf, sizeof (psf));
     2548 +
     2549 +        /* Set security flags on the zone's zsched */
     2550 +        (void) memcpy(&zone->zone_zsched->p_secflags, &zone->zone_secflags,
     2551 +            sizeof (zone->zone_zsched->p_secflags));
     2552 +
     2553 +        return (0);
     2554 +}
     2555 +
     2556 +static int
2530 2557  zone_set_fs_allowed(zone_t *zone, const char *zone_fs_allowed)
2531 2558  {
2532 2559          char *buf = kmem_zalloc(ZONE_FS_ALLOWED_MAX, KM_SLEEP);
2533 2560          int err = 0;
2534 2561  
2535 2562          ASSERT(zone != global_zone);
2536 2563          if ((err = copyinstr(zone_fs_allowed, buf,
2537 2564              ZONE_FS_ALLOWED_MAX, NULL)) != 0)
2538 2565                  goto done;
2539 2566  
↓ open down ↓ 1441 lines elided ↑ open up ↑
3981 4008                          /*
3982 4009                           * rctl_local_insert can fail if the value being
3983 4010                           * inserted is a duplicate; this is OK.
3984 4011                           */
3985 4012                          mutex_enter(&pp->p_lock);
3986 4013                          if (rctl_local_insert(hndl, nvalp, pp) != 0)
3987 4014                                  kmem_cache_free(rctl_val_cache, nvalp);
3988 4015                          mutex_exit(&pp->p_lock);
3989 4016                  }
3990 4017          }
     4018 +
3991 4019          /*
3992 4020           * Tell the world that we're done setting up.
3993 4021           *
3994 4022           * At this point we want to set the zone status to ZONE_IS_INITIALIZED
3995 4023           * and atomically set the zone's processor set visibility.  Once
3996 4024           * we drop pool_lock() this zone will automatically get updated
3997 4025           * to reflect any future changes to the pools configuration.
3998 4026           *
3999 4027           * Note that after we drop the locks below (zonehash_lock in
4000 4028           * particular) other operations such as a zone_getattr call can
↓ open down ↓ 263 lines elided ↑ open up ↑
4264 4292          error = 0;
4265 4293          *nvlp = nvl;
4266 4294  out:
4267 4295          kmem_free(kbuf, buflen);
4268 4296          if (error && nvl != NULL)
4269 4297                  nvlist_free(nvl);
4270 4298          return (error);
4271 4299  }
4272 4300  
4273 4301  int
4274      -zone_create_error(int er_error, int er_ext, int *er_out) {
     4302 +zone_create_error(int er_error, int er_ext, int *er_out)
     4303 +{
4275 4304          if (er_out != NULL) {
4276 4305                  if (copyout(&er_ext, er_out, sizeof (int))) {
4277 4306                          return (set_errno(EFAULT));
4278 4307                  }
4279 4308          }
4280 4309          return (set_errno(er_error));
4281 4310  }
4282 4311  
4283 4312  static int
4284 4313  zone_set_label(zone_t *zone, const bslabel_t *lab, uint32_t doi)
↓ open down ↓ 149 lines elided ↑ open up ↑
4434 4463          zone->zone_domain = kmem_alloc(_SYS_NMLN, KM_SLEEP);
4435 4464          zone->zone_domain[0] = '\0';
4436 4465          zone->zone_hostid = HW_INVALID_HOSTID;
4437 4466          zone->zone_shares = 1;
4438 4467          zone->zone_shmmax = 0;
4439 4468          zone->zone_ipc.ipcq_shmmni = 0;
4440 4469          zone->zone_ipc.ipcq_semmni = 0;
4441 4470          zone->zone_ipc.ipcq_msgmni = 0;
4442 4471          zone->zone_bootargs = NULL;
4443 4472          zone->zone_fs_allowed = NULL;
     4473 +
     4474 +        secflags_zero(&zone0.zone_secflags.psf_lower);
     4475 +        secflags_zero(&zone0.zone_secflags.psf_effective);
     4476 +        secflags_zero(&zone0.zone_secflags.psf_inherit);
     4477 +        secflags_fullset(&zone0.zone_secflags.psf_upper);
     4478 +
4444 4479          zone->zone_initname =
4445 4480              kmem_alloc(strlen(zone_default_initname) + 1, KM_SLEEP);
4446 4481          (void) strcpy(zone->zone_initname, zone_default_initname);
4447 4482          zone->zone_nlwps = 0;
4448 4483          zone->zone_nlwps_ctl = INT_MAX;
4449 4484          zone->zone_nprocs = 0;
4450 4485          zone->zone_nprocs_ctl = INT_MAX;
4451 4486          zone->zone_locked_mem = 0;
4452 4487          zone->zone_locked_mem_ctl = UINT64_MAX;
4453 4488          zone->zone_max_swap = 0;
↓ open down ↓ 1101 lines elided ↑ open up ↑
5555 5590                          outstr = zone->zone_fs_allowed;
5556 5591                  size = strlen(outstr) + 1;
5557 5592                  if (bufsize > size)
5558 5593                          bufsize = size;
5559 5594                  if (buf != NULL) {
5560 5595                          err = copyoutstr(outstr, buf, bufsize, NULL);
5561 5596                          if (err != 0 && err != ENAMETOOLONG)
5562 5597                                  error = EFAULT;
5563 5598                  }
5564 5599                  break;
     5600 +        case ZONE_ATTR_SECFLAGS:
     5601 +                size = sizeof (zone->zone_secflags);
     5602 +                if (bufsize > size)
     5603 +                        bufsize = size;
     5604 +                if ((err = copyout(&zone->zone_secflags, buf, bufsize)) != 0)
     5605 +                        error = EFAULT;
     5606 +                break;
5565 5607          case ZONE_ATTR_NETWORK:
5566 5608                  zbuf = kmem_alloc(bufsize, KM_SLEEP);
5567 5609                  if (copyin(buf, zbuf, bufsize) != 0) {
5568 5610                          error = EFAULT;
5569 5611                  } else {
5570 5612                          error = zone_get_network(zoneid, zbuf);
5571 5613                          if (error == 0 && copyout(zbuf, buf, bufsize) != 0)
5572 5614                                  error = EFAULT;
5573 5615                  }
5574 5616                  kmem_free(zbuf, bufsize);
↓ open down ↓ 64 lines elided ↑ open up ↑
5639 5681                  break;
5640 5682          case ZONE_ATTR_BOOTARGS:
5641 5683                  err = zone_set_bootargs(zone, (const char *)buf);
5642 5684                  break;
5643 5685          case ZONE_ATTR_BRAND:
5644 5686                  err = zone_set_brand(zone, (const char *)buf);
5645 5687                  break;
5646 5688          case ZONE_ATTR_FS_ALLOWED:
5647 5689                  err = zone_set_fs_allowed(zone, (const char *)buf);
5648 5690                  break;
     5691 +        case ZONE_ATTR_SECFLAGS:
     5692 +                err = zone_set_secflags(zone, (psecflags_t *)buf);
     5693 +                break;
5649 5694          case ZONE_ATTR_PHYS_MCAP:
5650 5695                  err = zone_set_phys_mcap(zone, (const uint64_t *)buf);
5651 5696                  break;
5652 5697          case ZONE_ATTR_SCHED_CLASS:
5653 5698                  err = zone_set_sched_class(zone, (const char *)buf);
5654 5699                  break;
5655 5700          case ZONE_ATTR_HOSTID:
5656 5701                  if (bufsize == sizeof (zone->zone_hostid)) {
5657 5702                          if (copyin(buf, &zone->zone_hostid, bufsize) == 0)
5658 5703                                  err = 0;
↓ open down ↓ 1614 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX