From owner-svn-src-head@freebsd.org Sun May 28 07:40:11 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64BDFD85A03; Sun, 28 May 2017 07:40:11 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 404ED1C4; Sun, 28 May 2017 07:40:11 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4S7eAYt067742; Sun, 28 May 2017 07:40:10 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4S7e9B1067738; Sun, 28 May 2017 07:40:09 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201705280740.v4S7e9B1067738@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 28 May 2017 07:40:09 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 May 2017 07:40:11 -0000 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 #include @@ -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