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 ↓ 2040 lines elided ↑ open up ↑
2041 2041          zone0.zone_max_lofi_ctl = UINT64_MAX;
2042 2042          zone0.zone_shmmax = 0;
2043 2043          zone0.zone_ipc.ipcq_shmmni = 0;
2044 2044          zone0.zone_ipc.ipcq_semmni = 0;
2045 2045          zone0.zone_ipc.ipcq_msgmni = 0;
2046 2046          zone0.zone_name = GLOBAL_ZONENAME;
2047 2047          zone0.zone_nodename = utsname.nodename;
2048 2048          zone0.zone_domain = srpc_domain;
2049 2049          zone0.zone_hostid = HW_INVALID_HOSTID;
2050 2050          zone0.zone_fs_allowed = NULL;
     2051 +        psecflags_default(&zone0.zone_secflags);
2051 2052          zone0.zone_ref = 1;
2052 2053          zone0.zone_id = GLOBAL_ZONEID;
2053 2054          zone0.zone_status = ZONE_IS_RUNNING;
2054 2055          zone0.zone_rootpath = "/";
2055 2056          zone0.zone_rootpathlen = 2;
2056 2057          zone0.zone_psetid = ZONE_PS_INVAL;
2057 2058          zone0.zone_ncpus = 0;
2058 2059          zone0.zone_ncpus_online = 0;
2059 2060          zone0.zone_proc_initpid = 1;
2060 2061          zone0.zone_initname = initname;
↓ open down ↓ 427 lines elided ↑ open up ↑
2488 2489  
2489 2490          /* set up the brand specific data */
2490 2491          zone->zone_brand = bp;
2491 2492          ZBROP(zone)->b_init_brand_data(zone);
2492 2493  
2493 2494          mutex_exit(&zone_status_lock);
2494 2495          return (0);
2495 2496  }
2496 2497  
2497 2498  static int
     2499 +zone_set_secflags(zone_t *zone, const psecflags_t *zone_secflags)
     2500 +{
     2501 +        int err = 0;
     2502 +        psecflags_t psf;
     2503 +
     2504 +        ASSERT(zone != global_zone);
     2505 +
     2506 +        if ((err = copyin(zone_secflags, &psf, sizeof (psf))) != 0)
     2507 +                return (err);
     2508 +
     2509 +        if (zone_status_get(zone) > ZONE_IS_READY)
     2510 +                return (EINVAL);
     2511 +
     2512 +        if (!psecflags_validate(&psf))
     2513 +                return (EINVAL);
     2514 +
     2515 +        (void) memcpy(&zone->zone_secflags, &psf, sizeof (psf));
     2516 +
     2517 +        /* Set security flags on the zone's zsched */
     2518 +        (void) memcpy(&zone->zone_zsched->p_secflags, &zone->zone_secflags,
     2519 +            sizeof (zone->zone_zsched->p_secflags));
     2520 +
     2521 +        return (0);
     2522 +}
     2523 +
     2524 +static int
2498 2525  zone_set_fs_allowed(zone_t *zone, const char *zone_fs_allowed)
2499 2526  {
2500 2527          char *buf = kmem_zalloc(ZONE_FS_ALLOWED_MAX, KM_SLEEP);
2501 2528          int err = 0;
2502 2529  
2503 2530          ASSERT(zone != global_zone);
2504 2531          if ((err = copyinstr(zone_fs_allowed, buf,
2505 2532              ZONE_FS_ALLOWED_MAX, NULL)) != 0)
2506 2533                  goto done;
2507 2534  
↓ open down ↓ 1441 lines elided ↑ open up ↑
3949 3976                          /*
3950 3977                           * rctl_local_insert can fail if the value being
3951 3978                           * inserted is a duplicate; this is OK.
3952 3979                           */
3953 3980                          mutex_enter(&pp->p_lock);
3954 3981                          if (rctl_local_insert(hndl, nvalp, pp) != 0)
3955 3982                                  kmem_cache_free(rctl_val_cache, nvalp);
3956 3983                          mutex_exit(&pp->p_lock);
3957 3984                  }
3958 3985          }
     3986 +
3959 3987          /*
3960 3988           * Tell the world that we're done setting up.
3961 3989           *
3962 3990           * At this point we want to set the zone status to ZONE_IS_INITIALIZED
3963 3991           * and atomically set the zone's processor set visibility.  Once
3964 3992           * we drop pool_lock() this zone will automatically get updated
3965 3993           * to reflect any future changes to the pools configuration.
3966 3994           *
3967 3995           * Note that after we drop the locks below (zonehash_lock in
3968 3996           * particular) other operations such as a zone_getattr call can
↓ open down ↓ 263 lines elided ↑ open up ↑
4232 4260          error = 0;
4233 4261          *nvlp = nvl;
4234 4262  out:
4235 4263          kmem_free(kbuf, buflen);
4236 4264          if (error && nvl != NULL)
4237 4265                  nvlist_free(nvl);
4238 4266          return (error);
4239 4267  }
4240 4268  
4241 4269  int
4242      -zone_create_error(int er_error, int er_ext, int *er_out) {
     4270 +zone_create_error(int er_error, int er_ext, int *er_out)
     4271 +{
4243 4272          if (er_out != NULL) {
4244 4273                  if (copyout(&er_ext, er_out, sizeof (int))) {
4245 4274                          return (set_errno(EFAULT));
4246 4275                  }
4247 4276          }
4248 4277          return (set_errno(er_error));
4249 4278  }
4250 4279  
4251 4280  static int
4252 4281  zone_set_label(zone_t *zone, const bslabel_t *lab, uint32_t doi)
↓ open down ↓ 149 lines elided ↑ open up ↑
4402 4431          zone->zone_domain = kmem_alloc(_SYS_NMLN, KM_SLEEP);
4403 4432          zone->zone_domain[0] = '\0';
4404 4433          zone->zone_hostid = HW_INVALID_HOSTID;
4405 4434          zone->zone_shares = 1;
4406 4435          zone->zone_shmmax = 0;
4407 4436          zone->zone_ipc.ipcq_shmmni = 0;
4408 4437          zone->zone_ipc.ipcq_semmni = 0;
4409 4438          zone->zone_ipc.ipcq_msgmni = 0;
4410 4439          zone->zone_bootargs = NULL;
4411 4440          zone->zone_fs_allowed = NULL;
     4441 +
     4442 +        secflags_zero(&zone0.zone_secflags.psf_lower);
     4443 +        secflags_zero(&zone0.zone_secflags.psf_effective);
     4444 +        secflags_zero(&zone0.zone_secflags.psf_inherit);
     4445 +        secflags_fullset(&zone0.zone_secflags.psf_upper);
     4446 +
4412 4447          zone->zone_initname =
4413 4448              kmem_alloc(strlen(zone_default_initname) + 1, KM_SLEEP);
4414 4449          (void) strcpy(zone->zone_initname, zone_default_initname);
4415 4450          zone->zone_nlwps = 0;
4416 4451          zone->zone_nlwps_ctl = INT_MAX;
4417 4452          zone->zone_nprocs = 0;
4418 4453          zone->zone_nprocs_ctl = INT_MAX;
4419 4454          zone->zone_locked_mem = 0;
4420 4455          zone->zone_locked_mem_ctl = UINT64_MAX;
4421 4456          zone->zone_max_swap = 0;
↓ open down ↓ 1101 lines elided ↑ open up ↑
5523 5558                          outstr = zone->zone_fs_allowed;
5524 5559                  size = strlen(outstr) + 1;
5525 5560                  if (bufsize > size)
5526 5561                          bufsize = size;
5527 5562                  if (buf != NULL) {
5528 5563                          err = copyoutstr(outstr, buf, bufsize, NULL);
5529 5564                          if (err != 0 && err != ENAMETOOLONG)
5530 5565                                  error = EFAULT;
5531 5566                  }
5532 5567                  break;
     5568 +        case ZONE_ATTR_SECFLAGS:
     5569 +                size = sizeof (zone->zone_secflags);
     5570 +                if (bufsize > size)
     5571 +                        bufsize = size;
     5572 +                if ((err = copyout(&zone->zone_secflags, buf, bufsize)) != 0)
     5573 +                        error = EFAULT;
     5574 +                break;
5533 5575          case ZONE_ATTR_NETWORK:
5534 5576                  zbuf = kmem_alloc(bufsize, KM_SLEEP);
5535 5577                  if (copyin(buf, zbuf, bufsize) != 0) {
5536 5578                          error = EFAULT;
5537 5579                  } else {
5538 5580                          error = zone_get_network(zoneid, zbuf);
5539 5581                          if (error == 0 && copyout(zbuf, buf, bufsize) != 0)
5540 5582                                  error = EFAULT;
5541 5583                  }
5542 5584                  kmem_free(zbuf, bufsize);
↓ open down ↓ 64 lines elided ↑ open up ↑
5607 5649                  break;
5608 5650          case ZONE_ATTR_BOOTARGS:
5609 5651                  err = zone_set_bootargs(zone, (const char *)buf);
5610 5652                  break;
5611 5653          case ZONE_ATTR_BRAND:
5612 5654                  err = zone_set_brand(zone, (const char *)buf);
5613 5655                  break;
5614 5656          case ZONE_ATTR_FS_ALLOWED:
5615 5657                  err = zone_set_fs_allowed(zone, (const char *)buf);
5616 5658                  break;
     5659 +        case ZONE_ATTR_SECFLAGS:
     5660 +                err = zone_set_secflags(zone, (psecflags_t *)buf);
     5661 +                break;
5617 5662          case ZONE_ATTR_PHYS_MCAP:
5618 5663                  err = zone_set_phys_mcap(zone, (const uint64_t *)buf);
5619 5664                  break;
5620 5665          case ZONE_ATTR_SCHED_CLASS:
5621 5666                  err = zone_set_sched_class(zone, (const char *)buf);
5622 5667                  break;
5623 5668          case ZONE_ATTR_HOSTID:
5624 5669                  if (bufsize == sizeof (zone->zone_hostid)) {
5625 5670                          if (copyin(buf, &zone->zone_hostid, bufsize) == 0)
5626 5671                                  err = 0;
↓ open down ↓ 1614 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX