Print this page
9971 Make getrandom(2) a public interface

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/sysent.c
          +++ new/usr/src/uts/common/os/sysent.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2012 Milan Jurik. All rights reserved.
  25   25   * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
  26      - * Copyright (c) 2015, Joyent, Inc.
       26 + * Copyright (c) 2018, Joyent, Inc.
  27   27   */
  28   28  
  29   29  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  30   30  /*        All Rights Reserved   */
  31   31  
  32   32  #include <sys/param.h>
  33   33  #include <sys/types.h>
  34   34  #include <sys/systm.h>
  35   35  #include <sys/systrace.h>
  36   36  #include <sys/procfs.h>
↓ open down ↓ 285 lines elided ↑ open up ↑
 322  322  ssize_t recvmsg(int, struct nmsghdr *, int);
 323  323  ssize_t send(int, void *, size_t, int);
 324  324  ssize_t sendmsg(int, struct nmsghdr *, int);
 325  325  ssize_t sendto(int, void *, size_t, int, struct sockaddr *, socklen_t);
 326  326  int     getpeername(int, struct sockaddr *, socklen_t *, int);
 327  327  int     getsockname(int, struct sockaddr *, socklen_t *, int);
 328  328  int     getsockopt(int, int, int, void *, socklen_t *, int);
 329  329  int     setsockopt(int, int, int, void *, socklen_t *, int);
 330  330  int     sockconfig(int, void *, void *, void *, void *);
 331  331  ssize_t sendfilev(int, int, const struct sendfilevec *, int, size_t *);
 332      -int     getrandom(void *, size_t, int);
      332 +ssize_t getrandom(void *, size_t, unsigned int);
 333  333  
 334  334  typedef int64_t (*llfcn_t)();   /* for casting one-word returns */
 335  335  
 336  336  /*
 337  337   * Sysent initialization macros.
 338      - *      These take the name string of the system call even though that isn't
      338 + *      These take the name string of the system call even though that isn't
 339  339   *      currently used in the sysent entry.  This might be useful someday.
 340  340   *
 341  341   * Initialization macro for system calls which take their args in the C style.
 342  342   * These system calls return the longlong_t return value and must call
 343  343   * set_errno() to return an error.  For SPARC, narg must be at most six.
 344  344   * For more args, use the SYSENT_AP() routine.
 345  345   *
 346  346   * We are able to return two distinct values to userland via the rval_t.
 347  347   * At this time, that corresponds to one 64-bit quantity, or two 32-bit
 348  348   * quantities.  The kernel does not currently need to return two 64-bit
↓ open down ↓ 161 lines elided ↑ open up ↑
 510  510          /* 59 */ SYSENT_CI("exece",             exece,          3),
 511  511          /* 60 */ SYSENT_CI("umask",             umask,          1),
 512  512          /* 61 */ SYSENT_CI("chroot",            chroot,         1),
 513  513          /* 62 */ SYSENT_CI("fcntl",             fcntl,          3),
 514  514          /* 63 */ SYSENT_CI("ulimit",            ulimit,         2),
 515  515          /* 64 */ SYSENT_CI("renameat",          renameat,       4),
 516  516          /* 65 */ SYSENT_CI("unlinkat",          unlinkat,       3),
 517  517          /* 66 */ SYSENT_CI("fstatat",           fstatat,        4),
 518  518          /* 67 */ IF_LP64(
 519  519                          SYSENT_NOSYS(),
 520      -                        SYSENT_CI("fstatat64",  fstatat64,      4)),
      520 +                        SYSENT_CI("fstatat64",  fstatat64,      4)),
 521  521          /* 68 */ SYSENT_CI("openat",            openat,         4),
 522  522          /* 69 */ IF_LP64(
 523  523                          SYSENT_NOSYS(),
 524  524                          SYSENT_CI("openat64",   openat64,       4)),
 525  525          /* 70 */ SYSENT_CI("tasksys",           tasksys,        5),
 526  526          /* 71 */ SYSENT_LOADABLE(),             /* acctctl */
 527  527          /* 72 */ SYSENT_LOADABLE(),             /* exacct */
 528  528          /* 73 */ SYSENT_CI("getpagesizes",      getpagesizes,   3),
 529  529          /* 74 */ SYSENT_CI("rctlsys",           rctlsys,        6),
 530  530          /* 75 */ SYSENT_2CI("sidsys",           sidsys,         4),
↓ open down ↓ 46 lines elided ↑ open up ↑
 577  577          /* 116 */ SYSENT_CI("mprotect",         mprotect,       3),
 578  578          /* 117 */ SYSENT_CI("munmap",           munmap,         2),
 579  579          /* 118 */ SYSENT_CL("fpathconf",        fpathconf,      2),
 580  580          /* 119 */ SYSENT_2CI("vfork",           vfork,          0),
 581  581          /* 120 */ SYSENT_CI("fchdir",           fchdir,         1),
 582  582          /* 121 */ SYSENT_CL("readv",            readv,          3),
 583  583          /* 122 */ SYSENT_CL("writev",           writev,         3),
 584  584          /* 123 */ SYSENT_CL("preadv",           preadv,         5),
 585  585          /* 124 */ SYSENT_CL("pwritev",          pwritev,        5),
 586  586          /* 125 */ SYSENT_LOADABLE(),                    /* (was fxstat) */
 587      -        /* 126 */ SYSENT_CI("getrandom",        getrandom,      3),
      587 +        /* 126 */ SYSENT_CL("getrandom",        getrandom,      3),
 588  588          /* 127 */ SYSENT_CI("mmapobj",          mmapobjsys,     5),
 589  589          /* 128 */ IF_LP64(
 590  590                          SYSENT_CI("setrlimit",  setrlimit64,    2),
 591  591                          SYSENT_CI("setrlimit",  setrlimit32,    2)),
 592  592          /* 129 */ IF_LP64(
 593  593                          SYSENT_CI("getrlimit",  getrlimit64,    2),
 594  594                          SYSENT_CI("getrlimit",  getrlimit32,    2)),
 595  595          /* 130 */ SYSENT_CI("lchown",           lchown,         3),
 596  596          /* 131 */ SYSENT_CI("memcntl",          memcntl,        6),
 597  597          /* 132 */ SYSENT_CI("getpmsg",          getpmsg,        5),
↓ open down ↓ 46 lines elided ↑ open up ↑
 644  644           * is needed as a native syscall only on the 32-bit kernel.
 645  645           */
 646  646          /* 175 */ IF_LP64(
 647  647                          SYSENT_NOSYS(),
 648  648                          SYSENT_C("llseek",      llseek32,       4)),
 649  649          /* 176 */ SYSENT_LOADABLE(),            /* inst_sync */
 650  650          /* 177 */ SYSENT_CI("brandsys",         brandsys,       6),
 651  651          /* 178 */ SYSENT_LOADABLE(),            /* kaio */
 652  652          /* 179 */ SYSENT_LOADABLE(),            /* cpc */
 653  653          /* 180 */ SYSENT_CI("lgrpsys",          lgrpsys,        3),
 654      -        /* 181 */ SYSENT_CI("rusagesys",        rusagesys,      5),
      654 +        /* 181 */ SYSENT_CI("rusagesys",        rusagesys,      5),
 655  655          /* 182 */ SYSENT_LOADABLE(),            /* portfs */
 656  656          /* 183 */ SYSENT_CI("pollsys",          pollsys,        4),
 657  657          /* 184 */ SYSENT_CI("labelsys",         labelsys,       5),
 658  658          /* 185 */ SYSENT_CI("acl",              acl,            4),
 659  659          /* 186 */ SYSENT_AP("auditsys",         auditsys,       6),
 660  660          /* 187 */ SYSENT_CI("processor_bind",   processor_bind, 4),
 661  661          /* 188 */ SYSENT_CI("processor_info",   processor_info, 2),
 662  662          /* 189 */ SYSENT_CI("p_online",         p_online,       2),
 663  663          /* 190 */ SYSENT_CI("sigqueue",         sigqueue,       5),
 664  664          /* 191 */ SYSENT_CI("clock_gettime",    clock_gettime,  2),
↓ open down ↓ 28 lines elided ↑ open up ↑
 693  693           * needed as native syscalls on the 32-bit kernel).
 694  694           */
 695  695          /* 213 */ IF_LP64(
 696  696                          SYSENT_NOSYS(),
 697  697                          SYSENT_CI("getdents64", getdents64,     3)),
 698  698          /* 214 */ IF_LP64(
 699  699                          SYSENT_NOSYS(),
 700  700                          SYSENT_AP("smmaplf32",  smmaplf32,      7)),
 701  701          /* 215 */ IF_LP64(
 702  702                          SYSENT_NOSYS(),
 703      -                        SYSENT_CI("stat64",     stat64,         2)),
      703 +                        SYSENT_CI("stat64",     stat64,         2)),
 704  704          /* 216 */ IF_LP64(
 705  705                          SYSENT_NOSYS(),
 706  706                          SYSENT_CI("lstat64",    lstat64,        2)),
 707  707          /* 217 */ IF_LP64(
 708  708                          SYSENT_NOSYS(),
 709      -                        SYSENT_CI("fstat64",    fstat64,        2)),
      709 +                        SYSENT_CI("fstat64",    fstat64,        2)),
 710  710          /* 218 */ IF_LP64(
 711  711                          SYSENT_NOSYS(),
 712      -                        SYSENT_CI("statvfs64",  statvfs64,      2)),
      712 +                        SYSENT_CI("statvfs64",  statvfs64,      2)),
 713  713          /* 219 */ IF_LP64(
 714  714                          SYSENT_NOSYS(),
 715      -                        SYSENT_CI("fstatvfs64", fstatvfs64,     2)),
      715 +                        SYSENT_CI("fstatvfs64", fstatvfs64,     2)),
 716  716          /* 220 */ IF_LP64(
 717  717                          SYSENT_NOSYS(),
 718      -                        SYSENT_CI("setrlimit64", setrlimit64,   2)),
      718 +                        SYSENT_CI("setrlimit64", setrlimit64,   2)),
 719  719          /* 221 */ IF_LP64(
 720  720                          SYSENT_NOSYS(),
 721      -                        SYSENT_CI("getrlimit64", getrlimit64,   2)),
      721 +                        SYSENT_CI("getrlimit64", getrlimit64,   2)),
 722  722          /* 222 */ IF_LP64(
 723  723                          SYSENT_NOSYS(),
 724      -                        SYSENT_CI("pread64",    pread64,        5)),
      724 +                        SYSENT_CI("pread64",    pread64,        5)),
 725  725          /* 223 */ IF_LP64(
 726  726                          SYSENT_NOSYS(),
 727      -                        SYSENT_CI("pwrite64",   pwrite64,       5)),
      727 +                        SYSENT_CI("pwrite64",   pwrite64,       5)),
 728  728          /* 224 */ SYSENT_LOADABLE(),                    /* (was creat64) */
 729  729          /* 225 */ IF_LP64(
 730  730                          SYSENT_NOSYS(),
 731  731                          SYSENT_CI("open64",     open64,         3)),
 732  732          /* 226 */ SYSENT_LOADABLE(),            /* rpcsys */
 733  733          /* 227 */ SYSENT_CL("zone",             zone,           5),
 734  734          /* 228 */ SYSENT_LOADABLE(),            /* autofssys */
 735  735          /* 229 */ SYSENT_CI("getcwd",           getcwd,         2),
 736  736          /* 230 */ SYSENT_CI("so_socket",        so_socket,      5),
 737  737          /* 231 */ SYSENT_CI("so_socketpair",    so_socketpair,  1),
↓ open down ↓ 143 lines elided ↑ open up ↑
 881  881          /* 57 */ SYSENT_2CI("utssys",           utssys32,       4),
 882  882          /* 58 */ SYSENT_CI("fdsync",            fdsync,         2),
 883  883          /* 59 */ SYSENT_CI("exece",             exece,          3),
 884  884          /* 60 */ SYSENT_CI("umask",             umask,          1),
 885  885          /* 61 */ SYSENT_CI("chroot",            chroot,         1),
 886  886          /* 62 */ SYSENT_CI("fcntl",             fcntl,          3),
 887  887          /* 63 */ SYSENT_CI("ulimit",            ulimit32,       2),
 888  888          /* 64 */ SYSENT_CI("renameat",          renameat,       4),
 889  889          /* 65 */ SYSENT_CI("unlinkat",          unlinkat,       3),
 890  890          /* 66 */ SYSENT_CI("fstatat",           fstatat32,      4),
 891      -        /* 67 */ SYSENT_CI("fstatat64",         fstatat64_32,   4),
      891 +        /* 67 */ SYSENT_CI("fstatat64",         fstatat64_32,   4),
 892  892          /* 68 */ SYSENT_CI("openat",            openat32,       4),
 893  893          /* 69 */ SYSENT_CI("openat64",          openat64,       4),
 894  894          /* 70 */ SYSENT_CI("tasksys",           tasksys,        5),
 895  895          /* 71 */ SYSENT_LOADABLE32(),           /* acctctl */
 896  896          /* 72 */ SYSENT_LOADABLE32(),           /* exacct */
 897  897          /* 73 */ SYSENT_CI("getpagesizes",      getpagesizes32, 3),
 898  898          /* 74 */ SYSENT_CI("rctlsys",           rctlsys,        6),
 899  899          /* 75 */ SYSENT_2CI("sidsys",           sidsys,         4),
 900  900          /* 76 */ SYSENT_LOADABLE32(),                   /* (was fsat) */
 901  901          /* 77 */ SYSENT_CI("lwp_park",          syslwp_park,    3),
↓ open down ↓ 133 lines elided ↑ open up ↑
1035 1035          /* 207 */ SYSENT_LOADABLE32(),          /* pset */
1036 1036          /* 208 */ SYSENT_LOADABLE32(),
1037 1037          /* 209 */ SYSENT_CI("resolvepath",      resolvepath,    3),
1038 1038          /* 210 */ SYSENT_CI("lwp_mutex_timedlock", lwp_mutex_timedlock, 3),
1039 1039          /* 211 */ SYSENT_CI("lwp_sema_timedwait", lwp_sema_timedwait,   3),
1040 1040          /* 212 */ SYSENT_CI("lwp_rwlock_sys",   lwp_rwlock_sys, 3),
1041 1041          /*
1042 1042           * Syscalls 213-225: 32-bit system call support for large files.
1043 1043           */
1044 1044          /* 213 */ SYSENT_CI("getdents64",       getdents64,     3),
1045      -        /* 214 */ SYSENT_AP("smmaplf32",        smmaplf32,      7),
1046      -        /* 215 */ SYSENT_CI("stat64",           stat64_32,      2),
1047      -        /* 216 */ SYSENT_CI("lstat64",          lstat64_32,     2),
1048      -        /* 217 */ SYSENT_CI("fstat64",          fstat64_32,     2),
1049      -        /* 218 */ SYSENT_CI("statvfs64",        statvfs64_32,   2),
1050      -        /* 219 */ SYSENT_CI("fstatvfs64",       fstatvfs64_32,  2),
1051      -        /* 220 */ SYSENT_CI("setrlimit64",      setrlimit64,    2),
1052      -        /* 221 */ SYSENT_CI("getrlimit64",      getrlimit64,    2),
1053      -        /* 222 */ SYSENT_CI("pread64",          pread64,        5),
1054      -        /* 223 */ SYSENT_CI("pwrite64",         pwrite64,       5),
     1045 +        /* 214 */ SYSENT_AP("smmaplf32",        smmaplf32,      7),
     1046 +        /* 215 */ SYSENT_CI("stat64",           stat64_32,      2),
     1047 +        /* 216 */ SYSENT_CI("lstat64",          lstat64_32,     2),
     1048 +        /* 217 */ SYSENT_CI("fstat64",          fstat64_32,     2),
     1049 +        /* 218 */ SYSENT_CI("statvfs64",        statvfs64_32,   2),
     1050 +        /* 219 */ SYSENT_CI("fstatvfs64",       fstatvfs64_32,  2),
     1051 +        /* 220 */ SYSENT_CI("setrlimit64",      setrlimit64,    2),
     1052 +        /* 221 */ SYSENT_CI("getrlimit64",      getrlimit64,    2),
     1053 +        /* 222 */ SYSENT_CI("pread64",          pread64,        5),
     1054 +        /* 223 */ SYSENT_CI("pwrite64",         pwrite64,       5),
1055 1055          /* 224 */ SYSENT_LOADABLE32(),                  /* (was creat64) */
1056 1056          /* 225 */ SYSENT_CI("open64",           open64,         3),
1057 1057          /* 226 */ SYSENT_LOADABLE32(),          /* rpcsys */
1058 1058          /* 227 */ SYSENT_CI("zone",             zone,           6),
1059 1059          /* 228 */ SYSENT_LOADABLE32(),          /* autofssys */
1060 1060          /* 229 */ SYSENT_CI("getcwd",           getcwd,         2),
1061 1061          /* 230 */ SYSENT_CI("so_socket",        so_socket,      5),
1062 1062          /* 231 */ SYSENT_CI("so_socketpair",    so_socketpair,  1),
1063 1063          /* 232 */ SYSENT_CI("bind",             bind,           4),
1064 1064          /* 233 */ SYSENT_CI("listen",           listen,         3),
↓ open down ↓ 143 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX