Print this page
OS-5576 harden random pool for zones
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/random.c
          +++ new/usr/src/uts/common/io/random.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  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   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  22   22   * Use is subject to license terms.
       23 + *
       24 + * Copyright 2016 Joyent, Inc.
  23   25   */
  24   26  
  25   27  
  26   28  /*
  27   29   * Random number generator pseudo-driver
  28   30   *
  29   31   * This is a lightweight driver which calls in to the Kernel Cryptographic
  30   32   * Framework to do the real work. Kernel modules should NOT depend on this
  31   33   * driver for /dev/random kernel API.
  32   34   *
↓ open down ↓ 249 lines elided ↑ open up ↑
 282  284          devno = getminor(dev);
 283  285  
 284  286          while (uiop->uio_resid > 0) {
 285  287                  bytes = min(sizeof (buf), uiop->uio_resid);
 286  288  
 287  289                  /* See comments in rnd_read() */
 288  290                  uiop->uio_loffset = 0;
 289  291                  if ((error = uiomove(buf, bytes, UIO_WRITE, uiop)) != 0)
 290  292                          return (error);
 291  293  
      294 +                if (crgetzone(credp) != global_zone)
      295 +                        continue;
      296 +
 292  297                  switch (devno) {
 293  298                  case DEVRANDOM:
 294  299                          if ((error = random_add_entropy(buf, bytes, 0)) != 0)
 295  300                                  return (error);
 296  301                          break;
 297  302                  case DEVURANDOM:
 298  303                          if ((error = random_add_pseudo_entropy(buf, bytes,
 299  304                              0)) != 0)
 300  305                                  return (error);
 301  306                          break;
↓ open down ↓ 43 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX