From owner-svn-src-all@FreeBSD.ORG Wed Apr 1 12:38:17 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AE5257C4; Wed, 1 Apr 2015 12:38:17 +0000 (UTC) Received: from mail-wi0-x22c.google.com (mail-wi0-x22c.google.com [IPv6:2a00:1450:400c:c05::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4EA097B6; Wed, 1 Apr 2015 12:38:17 +0000 (UTC) Received: by wibgn9 with SMTP id gn9so64655014wib.1; Wed, 01 Apr 2015 05:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=2nykuv3PaG4y5BOR+mMQSwL5SanJ1oXfR++roA18t1o=; b=dneehVbUTINxCDpe+UI/h8LFSRtVI+L66L2LSmBQiUuud3cdcA7kB8QzZoSMXZW8Rw Wh14yluivucCt74t9PF2Lk23vUvOMHnxu1PpPxgXPrSq/uv4WfclfdEJLJOA34Mj/N1x aSoilNqflKsKpHwubjCMBMB1150BWi8sP0GSypVYG9fPcROr8IifbgygpP62k58WtJbx wGathVyVZA6JaU6qXKZ9t0dBqWYGqjK6ueBi5AsjQSv+MI/1jDfc8ojod5rf7Ylc4Let e1esIQqzx4hRwZ96YqaICdoKpAaw+0IansRMdqshrszwjqy3zlvuVeb7djCRMkX3ZoSs fCpQ== X-Received: by 10.194.177.195 with SMTP id cs3mr81818833wjc.141.1427891895797; Wed, 01 Apr 2015 05:38:15 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id dx11sm2520886wjb.23.2015.04.01.05.38.14 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 01 Apr 2015 05:38:15 -0700 (PDT) Date: Wed, 1 Apr 2015 14:38:12 +0200 From: Mateusz Guzik To: Andrew Turner Subject: Re: svn commit: r280955 - in head/sys: modules/notrandom dev/notrandom Message-ID: <20150401123812.GB10926@dft-labs.eu> References: <20150401113628.GA16649@dft-labs.eu> <20150401133114.16e7d7ba@bender> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150401133114.16e7d7ba@bender> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2015 12:38:17 -0000 On Wed, Apr 01, 2015 at 01:31:14PM +0100, Andrew Turner wrote: > On Wed, 1 Apr 2015 13:36:28 +0200 > Mateusz Guzik wrote: > > > Author: mjg > > Date: Wed Apr 1 13:37:00 2015 > > New Revision: 280955 > > URL: https://svnweb.freebsd.org/changeset/base/280955 > > > > Log: > > Add /dev/notrandom > > > > notrandom provides fast and reliable not random numbers. > > > > This was added in an effort to increase feature-compatiblity with > > Solaris 10. > > > > See http://www.brendangregg.com/Specials/notrandom.c for Solaris > > implementation. > > > > Reviewed-by: Bruce Schneier (ok, not really) > > MFC after: 1 week > > I've been thinking about adding something similar for some time. I do > have one question, should it accept data for the notrandom number > generator? It would only need to accept up until the first notrandom > number. I was thinking something like the following patch (untested). > > Andrew > > diff --git a/sys/dev/notrandom/notrandom.c > b/sys/dev/notrandom/notrandom.c index c09eaf3..9e5f523 100644 > --- a/sys/dev/notrandom/notrandom.c > +++ b/sys/dev/notrandom/notrandom.c > @@ -41,10 +41,12 @@ static struct cdev *notrandom_dev; > > static d_ioctl_t notrandom_ioctl; > static d_read_t notrandom_read; > +static d_read_t notrandom_write; > > static struct cdevsw notrandom_cdevsw = { > .d_version = D_VERSION, > .d_read = notrandom_read, > + .d_write = notrandom_write, > .d_ioctl = notrandom_ioctl, > .d_name = "notrandom", > .d_flags = D_MMAP_ANON, > @@ -91,6 +93,30 @@ notrandom_read(struct cdev *dev __unused, struct uio > *uio, int flags __unused) > /* ARGSUSED */ > static int > +notrandom_write(struct cdev *dev __unused, struct uio *uio, int flags > __unused) > +{ > + size_t pos; > + ssize_t len; > + int error = 0; > + char buf; > + > + pos = 0; > + while (uio->uio_resid > 0) { > + len = uio->uio_resid; > + error = uiomove(&buf, 1, uio); > + if (error != 0) > + break; > + if (buf != 7) > + return (EIO); > + notrandom_buf[pos++] = buf; > + pos %= sizeof(notrandom_buf); I disagree with this part. It should only write buffers which fit the rest of the buffer, it should not wrap. Would you mind fixing the patch, testing it and allowing me later to commit it without attribution? Thanks, > + } > + > + return (error); > +} > + -- Mateusz Guzik