From f31c6fa33bcc9a608ce6f9ffd671ffc2b65a30ef Mon Sep 17 00:00:00 2001 From: Robert Mustacchi Date: Fri, 26 Dec 2014 02:46:52 +0000 Subject: OS-3845 want arc4random(3C) suite OS-3846 want getentropy(3C) OS-3847 want getrandom(2) OS-3848 want explicit_bzero(3C) OS-3843 want MC_INHERIT_ZERO OS-3844 uuid_generate can leak its cache in edge conditions Reviewed by: Jerry Jelinek Reviewed by: Joshua M. Clulow --- usr/src/uts/common/sys/mman.h | 11 +++++++++-- usr/src/uts/common/sys/random.h | 10 ++++++++++ usr/src/uts/common/sys/syscall.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'usr/src/uts/common/sys') diff --git a/usr/src/uts/common/sys/mman.h b/usr/src/uts/common/sys/mman.h index 8f4cd1639f..e9ac3a37cc 100644 --- a/usr/src/uts/common/sys/mman.h +++ b/usr/src/uts/common/sys/mman.h @@ -25,7 +25,7 @@ * * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * Copyright 2012 Joyent, Inc. All rights reserved. + * Copyright 2015 Joyent, Inc. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -303,7 +303,12 @@ struct memcntl_mha32 { #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ #if (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__) -/* advice to madvise */ +/* + * advice to madvise + * + * Note, if more than 4 bits worth of advice (eg. 16) are specified then + * changes will be necessary to the struct vpage. + */ #define MADV_NORMAL 0 /* no further special treatment */ #define MADV_RANDOM 1 /* expect random page references */ #define MADV_SEQUENTIAL 2 /* expect sequential page references */ @@ -313,6 +318,7 @@ struct memcntl_mha32 { #define MADV_ACCESS_DEFAULT 6 /* default access */ #define MADV_ACCESS_LWP 7 /* next LWP to access heavily */ #define MADV_ACCESS_MANY 8 /* many processes to access heavily */ + #endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */ #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) @@ -342,6 +348,7 @@ struct memcntl_mha32 { #define MC_LOCKAS 5 /* lock address space in memory */ #define MC_UNLOCKAS 6 /* unlock address space from memory */ #define MC_HAT_ADVISE 7 /* advise hat map size */ +#define MC_INHERIT_ZERO 8 /* zero out regions on fork() */ /* sub-commands for MC_HAT_ADVISE */ #define MHA_MAPSIZE_VA 0x1 /* set preferred page size */ diff --git a/usr/src/uts/common/sys/random.h b/usr/src/uts/common/sys/random.h index a38201456f..b835d2f5ac 100644 --- a/usr/src/uts/common/sys/random.h +++ b/usr/src/uts/common/sys/random.h @@ -24,6 +24,7 @@ */ /* * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2015, Joyent, Inc. */ #ifndef _SYS_RANDOM_H @@ -61,10 +62,19 @@ typedef struct swrand_stats { extern int random_add_entropy(uint8_t *, size_t, uint_t); extern int random_get_bytes(uint8_t *, size_t); +extern int random_get_blocking_bytes(uint8_t *, size_t); extern int random_get_pseudo_bytes(uint8_t *, size_t); #endif /* _KERNEL */ +/* + * Flags for the getrandom system call. Note, we may want to move these + * definitions if we expose getrandom(2) into a public system call. + */ +#define GRND_NONBLOCK 0x0001 /* O_NONBLOCK equiv */ +#define GRND_RANDOM 0x0002 /* Use /dev/random, not /dev/urandom */ +extern int getrandom(void *, size_t, int); + #ifdef __cplusplus } #endif diff --git a/usr/src/uts/common/sys/syscall.h b/usr/src/uts/common/sys/syscall.h index 5523f08552..7d86565564 100644 --- a/usr/src/uts/common/sys/syscall.h +++ b/usr/src/uts/common/sys/syscall.h @@ -296,6 +296,7 @@ extern "C" { #define SYS_writev 122 #define SYS_preadv 123 #define SYS_pwritev 124 +#define SYS_getrandom 126 #define SYS_mmapobj 127 #define SYS_setrlimit 128 #define SYS_getrlimit 129 -- cgit v1.2.3