Date: Sun, 28 May 2017 07:40:09 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319053 - in head/sys: compat/linux conf modules/linux modules/linux64 Message-ID: <201705280740.v4S7e9B1067738@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dchagin Date: Sun May 28 07:40:09 2017 New Revision: 319053 URL: https://svnweb.freebsd.org/changeset/base/319053 Log: On success, getrandom() Linux system call returns the number of bytes that were copied to the buffer supplied by the user. Also fix getrandom() if Linuxulator modules are built without the kernel. PR: 219464 Submitted by: Maciej Pasternacki Reported by: Maciej Pasternacki MFC after: 1 week Modified: head/sys/compat/linux/linux_misc.c head/sys/conf/config.mk head/sys/modules/linux/Makefile head/sys/modules/linux64/Makefile Modified: head/sys/compat/linux/linux_misc.c ============================================================================== --- head/sys/compat/linux/linux_misc.c Sun May 28 07:37:40 2017 (r319052) +++ head/sys/compat/linux/linux_misc.c Sun May 28 07:40:09 2017 (r319053) @@ -31,6 +31,9 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" +#if defined(KLD_MODULE) +#include "opt_global.h" +#endif #include <sys/param.h> #include <sys/blist.h> @@ -2516,6 +2519,7 @@ linux_getrandom(struct thread *td, struc { struct uio uio; struct iovec iov; + int error; if (args->flags & ~(LINUX_GRND_NONBLOCK|LINUX_GRND_RANDOM)) return (EINVAL); @@ -2532,7 +2536,10 @@ linux_getrandom(struct thread *td, struc uio.uio_rw = UIO_READ; uio.uio_td = td; - return (read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK)); + error = read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK); + if (error == 0) + td->td_retval[0] = args->count - uio.uio_resid; + return (error); } int Modified: head/sys/conf/config.mk ============================================================================== --- head/sys/conf/config.mk Sun May 28 07:37:40 2017 (r319052) +++ head/sys/conf/config.mk Sun May 28 07:40:09 2017 (r319053) @@ -8,6 +8,8 @@ # the code here when they all produce identical results # (or should) .if !defined(KERNBUILDDIR) +opt_global.h: + echo "#define DEV_RANDOM 1" >> ${.TARGET} opt_bpf.h: echo "#define DEV_BPF 1" > ${.TARGET} .if ${MK_INET_SUPPORT} != "no" Modified: head/sys/modules/linux/Makefile ============================================================================== --- head/sys/modules/linux/Makefile Sun May 28 07:37:40 2017 (r319052) +++ head/sys/modules/linux/Makefile Sun May 28 07:40:09 2017 (r319053) @@ -15,7 +15,7 @@ SRCS= linux_fork.c linux${SFX}_dummy.c l linux${SFX}_machdep.c linux_misc.c linux_signal.c \ linux_socket.c linux_stats.c linux_sysctl.c linux${SFX}_sysent.c \ linux${SFX}_sysvec.c linux_uid16.c linux_time.c \ - linux_timer.c linux_vdso.c \ + linux_timer.c linux_vdso.c opt_global.h \ opt_inet6.h opt_compat.h opt_posix.h opt_usb.h vnode_if.h \ device_if.h bus_if.h assym.s \ linux${SFX}_support.s Modified: head/sys/modules/linux64/Makefile ============================================================================== --- head/sys/modules/linux64/Makefile Sun May 28 07:37:40 2017 (r319052) +++ head/sys/modules/linux64/Makefile Sun May 28 07:40:09 2017 (r319053) @@ -10,7 +10,7 @@ SRCS= linux_fork.c linux_dummy.c linux_f linux_machdep.c linux_misc.c linux_ptrace.c linux_signal.c \ linux_socket.c linux_stats.c linux_sysctl.c linux_sysent.c \ linux_sysvec.c linux_time.c linux_vdso.c linux_timer.c \ - opt_inet6.h opt_compat.h opt_posix.h opt_usb.h \ + opt_inet6.h opt_compat.h opt_global.h opt_posix.h opt_usb.h \ vnode_if.h device_if.h bus_if.h assym.s \ linux_support.s DPSRCS= linux_genassym.c
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705280740.v4S7e9B1067738>