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


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2012 Milan Jurik. All rights reserved.
  25  * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
  26  * Copyright (c) 2015, Joyent, Inc.
  27  */
  28 
  29 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  30 /*        All Rights Reserved   */
  31 
  32 #include <sys/param.h>
  33 #include <sys/types.h>
  34 #include <sys/systm.h>
  35 #include <sys/systrace.h>
  36 #include <sys/procfs.h>
  37 #include <sys/mman.h>
  38 #include <sys/int_types.h>
  39 #include <c2/audit.h>
  40 #include <sys/stat.h>
  41 #include <sys/times.h>
  42 #include <sys/statfs.h>
  43 #include <sys/stropts.h>
  44 #include <sys/statvfs.h>
  45 #include <sys/utsname.h>
  46 #include <sys/timex.h>


 312 
 313 int     so_socket(int, int, int, char *, int);
 314 int     so_socketpair(int[2]);
 315 int     bind(int, struct sockaddr *, socklen_t, int);
 316 int     listen(int, int, int);
 317 int     accept(int, struct sockaddr *, socklen_t *, int, int);
 318 int     connect(int, struct sockaddr *, socklen_t, int);
 319 int     shutdown(int, int, int);
 320 ssize_t recv(int, void *, size_t, int);
 321 ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
 322 ssize_t recvmsg(int, struct nmsghdr *, int);
 323 ssize_t send(int, void *, size_t, int);
 324 ssize_t sendmsg(int, struct nmsghdr *, int);
 325 ssize_t sendto(int, void *, size_t, int, struct sockaddr *, socklen_t);
 326 int     getpeername(int, struct sockaddr *, socklen_t *, int);
 327 int     getsockname(int, struct sockaddr *, socklen_t *, int);
 328 int     getsockopt(int, int, int, void *, socklen_t *, int);
 329 int     setsockopt(int, int, int, void *, socklen_t *, int);
 330 int     sockconfig(int, void *, void *, void *, void *);
 331 ssize_t sendfilev(int, int, const struct sendfilevec *, int, size_t *);
 332 int     getrandom(void *, size_t, int);
 333 
 334 typedef int64_t (*llfcn_t)();   /* for casting one-word returns */
 335 
 336 /*
 337  * Sysent initialization macros.
 338  *      These take the name string of the system call even though that isn't
 339  *      currently used in the sysent entry.  This might be useful someday.
 340  *
 341  * Initialization macro for system calls which take their args in the C style.
 342  * These system calls return the longlong_t return value and must call
 343  * set_errno() to return an error.  For SPARC, narg must be at most six.
 344  * For more args, use the SYSENT_AP() routine.
 345  *
 346  * We are able to return two distinct values to userland via the rval_t.
 347  * At this time, that corresponds to one 64-bit quantity, or two 32-bit
 348  * quantities.  The kernel does not currently need to return two 64-bit
 349  * values, or one 128 bit value(!), but we may do one day, so the calling
 350  * sequence between userland and the kernel should permit it.
 351  *
 352  * The interpretation of rval_t is provided by the sy_flags field


 567                         SYSENT_AP("hrtsys",     hrtsys,         5),
 568                         SYSENT_LOADABLE()),
 569         /* 110 */ SYSENT_CI("utimesys",         utimesys,       5),
 570         /* 111 */ SYSENT_CI("sigresend",        sigresend,      3),
 571         /* 112 */ SYSENT_CL("priocntlsys",      priocntlsys,    5),
 572         /* 113 */ SYSENT_CL("pathconf",         pathconf,       2),
 573         /* 114 */ SYSENT_CI("mincore",          mincore,        3),
 574         /* 115 */ IF_LP64(
 575                         SYSENT_CL("mmap",       smmap64,        6),
 576                         SYSENT_CL("mmap",       smmap32,        6)),
 577         /* 116 */ SYSENT_CI("mprotect",         mprotect,       3),
 578         /* 117 */ SYSENT_CI("munmap",           munmap,         2),
 579         /* 118 */ SYSENT_CL("fpathconf",        fpathconf,      2),
 580         /* 119 */ SYSENT_2CI("vfork",           vfork,          0),
 581         /* 120 */ SYSENT_CI("fchdir",           fchdir,         1),
 582         /* 121 */ SYSENT_CL("readv",            readv,          3),
 583         /* 122 */ SYSENT_CL("writev",           writev,         3),
 584         /* 123 */ SYSENT_CL("preadv",           preadv,         5),
 585         /* 124 */ SYSENT_CL("pwritev",          pwritev,        5),
 586         /* 125 */ SYSENT_LOADABLE(),                    /* (was fxstat) */
 587         /* 126 */ SYSENT_CI("getrandom",        getrandom,      3),
 588         /* 127 */ SYSENT_CI("mmapobj",          mmapobjsys,     5),
 589         /* 128 */ IF_LP64(
 590                         SYSENT_CI("setrlimit",  setrlimit64,    2),
 591                         SYSENT_CI("setrlimit",  setrlimit32,    2)),
 592         /* 129 */ IF_LP64(
 593                         SYSENT_CI("getrlimit",  getrlimit64,    2),
 594                         SYSENT_CI("getrlimit",  getrlimit32,    2)),
 595         /* 130 */ SYSENT_CI("lchown",           lchown,         3),
 596         /* 131 */ SYSENT_CI("memcntl",          memcntl,        6),
 597         /* 132 */ SYSENT_CI("getpmsg",          getpmsg,        5),
 598         /* 133 */ SYSENT_CI("putpmsg",          putpmsg,        5),
 599         /* 134 */ SYSENT_CI("rename",           rename,         2),
 600         /* 135 */ SYSENT_CI("uname",            uname,          1),
 601         /* 136 */ SYSENT_CI("setegid",          setegid,        1),
 602         /* 137 */ SYSENT_CL("sysconfig",        sysconfig,      1),
 603         /* 138 */ SYSENT_CI("adjtime",          adjtime,        2),
 604         /* 139 */ SYSENT_CL("systeminfo",       systeminfo,     3),
 605         /* 140 */ SYSENT_LOADABLE(),            /* sharefs */
 606         /* 141 */ SYSENT_CI("seteuid",          seteuid,        1),
 607         /* 142 */ SYSENT_2CI("forksys",         forksys,        2),




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2012 Milan Jurik. All rights reserved.
  25  * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
  26  * Copyright (c) 2018, Joyent, Inc.
  27  */
  28 
  29 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  30 /*        All Rights Reserved   */
  31 
  32 #include <sys/param.h>
  33 #include <sys/types.h>
  34 #include <sys/systm.h>
  35 #include <sys/systrace.h>
  36 #include <sys/procfs.h>
  37 #include <sys/mman.h>
  38 #include <sys/int_types.h>
  39 #include <c2/audit.h>
  40 #include <sys/stat.h>
  41 #include <sys/times.h>
  42 #include <sys/statfs.h>
  43 #include <sys/stropts.h>
  44 #include <sys/statvfs.h>
  45 #include <sys/utsname.h>
  46 #include <sys/timex.h>


 312 
 313 int     so_socket(int, int, int, char *, int);
 314 int     so_socketpair(int[2]);
 315 int     bind(int, struct sockaddr *, socklen_t, int);
 316 int     listen(int, int, int);
 317 int     accept(int, struct sockaddr *, socklen_t *, int, int);
 318 int     connect(int, struct sockaddr *, socklen_t, int);
 319 int     shutdown(int, int, int);
 320 ssize_t recv(int, void *, size_t, int);
 321 ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
 322 ssize_t recvmsg(int, struct nmsghdr *, int);
 323 ssize_t send(int, void *, size_t, int);
 324 ssize_t sendmsg(int, struct nmsghdr *, int);
 325 ssize_t sendto(int, void *, size_t, int, struct sockaddr *, socklen_t);
 326 int     getpeername(int, struct sockaddr *, socklen_t *, int);
 327 int     getsockname(int, struct sockaddr *, socklen_t *, int);
 328 int     getsockopt(int, int, int, void *, socklen_t *, int);
 329 int     setsockopt(int, int, int, void *, socklen_t *, int);
 330 int     sockconfig(int, void *, void *, void *, void *);
 331 ssize_t sendfilev(int, int, const struct sendfilevec *, int, size_t *);
 332 ssize_t getrandom(void *, size_t, unsigned int);
 333 
 334 typedef int64_t (*llfcn_t)();   /* for casting one-word returns */
 335 
 336 /*
 337  * Sysent initialization macros.
 338  *      These take the name string of the system call even though that isn't
 339  *      currently used in the sysent entry.  This might be useful someday.
 340  *
 341  * Initialization macro for system calls which take their args in the C style.
 342  * These system calls return the longlong_t return value and must call
 343  * set_errno() to return an error.  For SPARC, narg must be at most six.
 344  * For more args, use the SYSENT_AP() routine.
 345  *
 346  * We are able to return two distinct values to userland via the rval_t.
 347  * At this time, that corresponds to one 64-bit quantity, or two 32-bit
 348  * quantities.  The kernel does not currently need to return two 64-bit
 349  * values, or one 128 bit value(!), but we may do one day, so the calling
 350  * sequence between userland and the kernel should permit it.
 351  *
 352  * The interpretation of rval_t is provided by the sy_flags field


 567                         SYSENT_AP("hrtsys",     hrtsys,         5),
 568                         SYSENT_LOADABLE()),
 569         /* 110 */ SYSENT_CI("utimesys",         utimesys,       5),
 570         /* 111 */ SYSENT_CI("sigresend",        sigresend,      3),
 571         /* 112 */ SYSENT_CL("priocntlsys",      priocntlsys,    5),
 572         /* 113 */ SYSENT_CL("pathconf",         pathconf,       2),
 573         /* 114 */ SYSENT_CI("mincore",          mincore,        3),
 574         /* 115 */ IF_LP64(
 575                         SYSENT_CL("mmap",       smmap64,        6),
 576                         SYSENT_CL("mmap",       smmap32,        6)),
 577         /* 116 */ SYSENT_CI("mprotect",         mprotect,       3),
 578         /* 117 */ SYSENT_CI("munmap",           munmap,         2),
 579         /* 118 */ SYSENT_CL("fpathconf",        fpathconf,      2),
 580         /* 119 */ SYSENT_2CI("vfork",           vfork,          0),
 581         /* 120 */ SYSENT_CI("fchdir",           fchdir,         1),
 582         /* 121 */ SYSENT_CL("readv",            readv,          3),
 583         /* 122 */ SYSENT_CL("writev",           writev,         3),
 584         /* 123 */ SYSENT_CL("preadv",           preadv,         5),
 585         /* 124 */ SYSENT_CL("pwritev",          pwritev,        5),
 586         /* 125 */ SYSENT_LOADABLE(),                    /* (was fxstat) */
 587         /* 126 */ SYSENT_CL("getrandom",        getrandom,      3),
 588         /* 127 */ SYSENT_CI("mmapobj",          mmapobjsys,     5),
 589         /* 128 */ IF_LP64(
 590                         SYSENT_CI("setrlimit",  setrlimit64,    2),
 591                         SYSENT_CI("setrlimit",  setrlimit32,    2)),
 592         /* 129 */ IF_LP64(
 593                         SYSENT_CI("getrlimit",  getrlimit64,    2),
 594                         SYSENT_CI("getrlimit",  getrlimit32,    2)),
 595         /* 130 */ SYSENT_CI("lchown",           lchown,         3),
 596         /* 131 */ SYSENT_CI("memcntl",          memcntl,        6),
 597         /* 132 */ SYSENT_CI("getpmsg",          getpmsg,        5),
 598         /* 133 */ SYSENT_CI("putpmsg",          putpmsg,        5),
 599         /* 134 */ SYSENT_CI("rename",           rename,         2),
 600         /* 135 */ SYSENT_CI("uname",            uname,          1),
 601         /* 136 */ SYSENT_CI("setegid",          setegid,        1),
 602         /* 137 */ SYSENT_CL("sysconfig",        sysconfig,      1),
 603         /* 138 */ SYSENT_CI("adjtime",          adjtime,        2),
 604         /* 139 */ SYSENT_CL("systeminfo",       systeminfo,     3),
 605         /* 140 */ SYSENT_LOADABLE(),            /* sharefs */
 606         /* 141 */ SYSENT_CI("seteuid",          seteuid,        1),
 607         /* 142 */ SYSENT_2CI("forksys",         forksys,        2),