svn commit: r317317 - in stable/11/sys: amd64/linux amd64/linux32 compat/linux i386/linux
Dmitry Chagin
dchagin at FreeBSD.org
Sun Apr 23 06:43:53 UTC 2017
Author: dchagin
Date: Sun Apr 23 06:43:52 2017
New Revision: 317317
URL: https://svnweb.freebsd.org/changeset/base/317317
Log:
MFC r315505:
Implement getrandom() syscall.
Note. GRND_RANDOM option is not supported for now.
Modified:
stable/11/sys/amd64/linux/linux_dummy.c
stable/11/sys/amd64/linux32/linux32_dummy.c
stable/11/sys/compat/linux/linux_misc.c
stable/11/sys/compat/linux/linux_misc.h
stable/11/sys/i386/linux/linux_dummy.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/amd64/linux/linux_dummy.c
==============================================================================
--- stable/11/sys/amd64/linux/linux_dummy.c Sun Apr 23 03:36:03 2017 (r317316)
+++ stable/11/sys/amd64/linux/linux_dummy.c Sun Apr 23 06:43:52 2017 (r317317)
@@ -135,7 +135,6 @@ DUMMY(sched_getattr);
DUMMY(renameat2);
/* linux 3.15: */
DUMMY(seccomp);
-DUMMY(getrandom);
DUMMY(memfd_create);
DUMMY(kexec_file_load);
/* linux 3.18: */
Modified: stable/11/sys/amd64/linux32/linux32_dummy.c
==============================================================================
--- stable/11/sys/amd64/linux32/linux32_dummy.c Sun Apr 23 03:36:03 2017 (r317316)
+++ stable/11/sys/amd64/linux32/linux32_dummy.c Sun Apr 23 06:43:52 2017 (r317317)
@@ -144,7 +144,6 @@ DUMMY(sched_getattr);
DUMMY(renameat2);
/* linux 3.15: */
DUMMY(seccomp);
-DUMMY(getrandom);
DUMMY(memfd_create);
/* linux 3.18: */
DUMMY(bpf);
Modified: stable/11/sys/compat/linux/linux_misc.c
==============================================================================
--- stable/11/sys/compat/linux/linux_misc.c Sun Apr 23 03:36:03 2017 (r317316)
+++ stable/11/sys/compat/linux/linux_misc.c Sun Apr 23 06:43:52 2017 (r317317)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/racct.h>
+#include <sys/random.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/sdt.h>
@@ -65,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include <sys/vnode.h>
#include <sys/wait.h>
#include <sys/cpuset.h>
+#include <sys/uio.h>
#include <security/mac/mac_framework.h>
@@ -2508,3 +2510,27 @@ linux_to_bsd_waitopts(int options, int *
if (options & __WCLONE)
*bsdopts |= WLINUXCLONE;
}
+
+int
+linux_getrandom(struct thread *td, struct linux_getrandom_args *args)
+{
+ struct uio uio;
+ struct iovec iov;
+
+ if (args->flags & ~(LINUX_GRND_NONBLOCK|LINUX_GRND_RANDOM))
+ return (EINVAL);
+ if (args->count > INT_MAX)
+ args->count = INT_MAX;
+
+ iov.iov_base = args->buf;
+ iov.iov_len = args->count;
+
+ uio.uio_iov = &iov;
+ uio.uio_iovcnt = 1;
+ uio.uio_resid = iov.iov_len;
+ uio.uio_segflg = UIO_USERSPACE;
+ uio.uio_rw = UIO_READ;
+ uio.uio_td = td;
+
+ return (read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK));
+}
Modified: stable/11/sys/compat/linux/linux_misc.h
==============================================================================
--- stable/11/sys/compat/linux/linux_misc.h Sun Apr 23 03:36:03 2017 (r317316)
+++ stable/11/sys/compat/linux/linux_misc.h Sun Apr 23 06:43:52 2017 (r317317)
@@ -145,6 +145,10 @@ extern int stclohz;
#define LINUX_RLIM_INFINITY (~0UL)
+/* Linux getrandom flags */
+#define LINUX_GRND_NONBLOCK 0x0001
+#define LINUX_GRND_RANDOM 0x0002
+
int linux_common_wait(struct thread *td, int pid, int *status,
int options, struct rusage *ru);
void linux_to_bsd_waitopts(int options, int *bsdopts);
Modified: stable/11/sys/i386/linux/linux_dummy.c
==============================================================================
--- stable/11/sys/i386/linux/linux_dummy.c Sun Apr 23 03:36:03 2017 (r317316)
+++ stable/11/sys/i386/linux/linux_dummy.c Sun Apr 23 06:43:52 2017 (r317317)
@@ -140,7 +140,6 @@ DUMMY(sched_getattr);
DUMMY(renameat2);
/* linux 3.15: */
DUMMY(seccomp);
-DUMMY(getrandom);
DUMMY(memfd_create);
/* linux 3.18: */
DUMMY(bpf);
More information about the svn-src-stable-11
mailing list