* [PATCH 0/2] rng-tools: add udev rule for virtio-rng
@ 2014-08-07 13:08 Amit Shah
  2014-08-07 13:08 ` [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present Amit Shah
  2014-08-07 13:09 ` [PATCH 2/2] Install udev rules in system-default directory Amit Shah
  0 siblings, 2 replies; 11+ messages in thread
From: Amit Shah @ 2014-08-07 13:08 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-kernel, Virtualization List, Amit Shah, hpa
Hello,
I didn't find a mailing list for rng-tools, so CC'ing the kernel lists
and the last few committers.
The first patch in this series adds a udev rule to start rngd for
guests that have a virtio-rng device available.
The second patch attempts to add autoconf magic to install the udev
rule in the system dirs.  However, installing as non-root will
obviously fail.  Prefixes are also not honoured.  I don't know of a
better way, and we probably should leave this to distributions.
However, if someone has a better idea on how to expand this, please
suggest.
Amit Shah (2):
  rngd: add udev rule to source from hwrng if virtio-rng present
  Install udev rules in system-default directory
 90-virtio-rng.rules | 1 +
 Makefile.am         | 1 +
 configure.ac        | 8 ++++++++
 3 files changed, 10 insertions(+)
 create mode 100644 90-virtio-rng.rules
-- 
1.9.3
^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
  2014-08-07 13:08 [PATCH 0/2] rng-tools: add udev rule for virtio-rng Amit Shah
@ 2014-08-07 13:08 ` Amit Shah
  2014-08-07 19:31   ` H. Peter Anvin
       [not found]   ` <53E3D3FF.70707@linux.intel.com>
  2014-08-07 13:09 ` [PATCH 2/2] Install udev rules in system-default directory Amit Shah
  1 sibling, 2 replies; 11+ messages in thread
From: Amit Shah @ 2014-08-07 13:08 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-kernel, Virtualization List, Amit Shah, hpa
On KVM guests where the virtio-rng device is available, and set as the
current rng, this udev rule will start rngd which will feed in the
host-provided entropy to /dev/random.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 90-virtio-rng.rules | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 90-virtio-rng.rules
diff --git a/90-virtio-rng.rules b/90-virtio-rng.rules
new file mode 100644
index 0000000..07f2f9c
--- /dev/null
+++ b/90-virtio-rng.rules
@@ -0,0 +1 @@
+KERNEL=="hw_random", ATTR{rng_current}=="virtio*", RUN+="/sbin/rngd -r /dev/hwrng"
-- 
1.9.3
^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH 2/2] Install udev rules in system-default directory
  2014-08-07 13:08 [PATCH 0/2] rng-tools: add udev rule for virtio-rng Amit Shah
  2014-08-07 13:08 ` [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present Amit Shah
@ 2014-08-07 13:09 ` Amit Shah
  2014-08-19 17:20   ` Paolo Bonzini
  1 sibling, 1 reply; 11+ messages in thread
From: Amit Shah @ 2014-08-07 13:09 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-kernel, Virtualization List, Amit Shah, hpa
not-quite-Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 Makefile.am  | 1 +
 configure.ac | 8 ++++++++
 2 files changed, 9 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index f8490a3..a2b8173 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,6 +8,7 @@ sbin_PROGRAMS	 = rngd
 bin_PROGRAMS	 = rngtest
 man_MANS	 = rngd.8 rngtest.1
 noinst_LIBRARIES = librngd.a
+udevrules_DATA	 = 90-virtio-rng.rules
 
 rngd_SOURCES	= rngd.h rngd.c	rngd_entsource.h rngd_entsource.c	\
 		  rngd_linux.h rngd_linux.c util.c 			\
diff --git a/configure.ac b/configure.ac
index 27a2dba..4187aca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,14 @@ AC_ARG_WITH([libgcrypt],
 	[with_libgcrypt=check]
 )
 
+PKG_PROG_PKG_CONFIG
+
+AC_ARG_WITH([udevrulesdir],
+	AS_HELP_STRING([--with-udevrulesdir=DIR], [Directory for udev rules]),
+	[],
+	[with_udevrulesdir=$($PKG_CONFIG --variable=udevdir udev)"/rules.d"])
+AC_SUBST([udevrulesdir], [$with_udevrulesdir])
+
 dnl Make sure anyone changing configure.ac/Makefile.am has a clue
 AM_MAINTAINER_MODE
 
-- 
1.9.3
^ permalink raw reply related	[flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
  2014-08-07 13:08 ` [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present Amit Shah
@ 2014-08-07 19:31   ` H. Peter Anvin
       [not found]   ` <53E3D3FF.70707@linux.intel.com>
  1 sibling, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2014-08-07 19:31 UTC (permalink / raw)
  To: Amit Shah, jgarzik; +Cc: Ricardo Neri, linux-kernel, Virtualization List
On 08/07/2014 06:08 AM, Amit Shah wrote:
> On KVM guests where the virtio-rng device is available, and set as the
> current rng, this udev rule will start rngd which will feed in the
> host-provided entropy to /dev/random.
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  90-virtio-rng.rules | 1 +
>  1 file changed, 1 insertion(+)
>  create mode 100644 90-virtio-rng.rules
> 
> diff --git a/90-virtio-rng.rules b/90-virtio-rng.rules
> new file mode 100644
> index 0000000..07f2f9c
> --- /dev/null
> +++ b/90-virtio-rng.rules
> @@ -0,0 +1 @@
> +KERNEL=="hw_random", ATTR{rng_current}=="virtio*", RUN+="/sbin/rngd -r /dev/hwrng"
> 
I'm not sure this is really right.  rngd can receive input from a number
of sources, and I suspect it would be better to rngd to be started much
earlier and perhaps get sent a SIGHUP to reconfigure when a hw_random
device appears ... not just the virtio one.
Currently rngd exits if there is no daemon.  There are a few ways to
deal with that: one is to run rngd on changes and leave a pid file
around; the rngd can try to signal the old rngd or launch itself;
another option would be to have a different rngd for each source.  To
some degree the above is obsolete when we get khwrngd widely deployed,
but that is a new-kernel-only kind of thing.
	-hpa
^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
       [not found]   ` <53E3D3FF.70707@linux.intel.com>
@ 2014-08-08  9:07     ` Amit Shah
  2014-08-08 21:46       ` H. Peter Anvin
       [not found]       ` <53E54533.8030109@linux.intel.com>
  0 siblings, 2 replies; 11+ messages in thread
From: Amit Shah @ 2014-08-08  9:07 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: jgarzik, Ricardo Neri, linux-kernel, Virtualization List
On (Thu) 07 Aug 2014 [12:31:11], H. Peter Anvin wrote:
> On 08/07/2014 06:08 AM, Amit Shah wrote:
> > On KVM guests where the virtio-rng device is available, and set as the
> > current rng, this udev rule will start rngd which will feed in the
> > host-provided entropy to /dev/random.
> > 
> > Signed-off-by: Amit Shah <amit.shah@redhat.com>
> > ---
> >  90-virtio-rng.rules | 1 +
> >  1 file changed, 1 insertion(+)
> >  create mode 100644 90-virtio-rng.rules
> > 
> > diff --git a/90-virtio-rng.rules b/90-virtio-rng.rules
> > new file mode 100644
> > index 0000000..07f2f9c
> > --- /dev/null
> > +++ b/90-virtio-rng.rules
> > @@ -0,0 +1 @@
> > +KERNEL=="hw_random", ATTR{rng_current}=="virtio*", RUN+="/sbin/rngd -r /dev/hwrng"
> > 
> 
> I'm not sure this is really right.  rngd can receive input from a number
> of sources, and I suspect it would be better to rngd to be started much
> earlier and perhaps get sent a SIGHUP to reconfigure when a hw_random
> device appears ... not just the virtio one.
Right - yea.  Modern distros do start rngd by default (at least Fedora
and RHEL do), so this does make sense.
But as you note below, not all distros may start rngd...
> Currently rngd exits if there is no daemon.  There are a few ways to
> deal with that: one is to run rngd on changes and leave a pid file
> around; the rngd can try to signal the old rngd or launch itself;
> another option would be to have a different rngd for each source.
Currently the kernel can only have one rng_current, which is a pity.
So in the current case, rngd only needs one instance -- and it'll
always accept stuff from /dev/hwrng and it doesn't matter if the
rng_current is changed as long as there's some rng there.
>  To
> some degree the above is obsolete when we get khwrngd widely deployed,
> but that is a new-kernel-only kind of thing.
Right - I'm wondering if any such changes as propsed here are now
obsolted already by khwrngd?
Thanks,
		Amit
^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
  2014-08-08  9:07     ` Amit Shah
@ 2014-08-08 21:46       ` H. Peter Anvin
       [not found]       ` <53E54533.8030109@linux.intel.com>
  1 sibling, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2014-08-08 21:46 UTC (permalink / raw)
  To: Amit Shah; +Cc: jgarzik, Ricardo Neri, linux-kernel, Virtualization List
On 08/08/2014 02:07 AM, Amit Shah wrote:
>
> 
>>  To
>> some degree the above is obsolete when we get khwrngd widely deployed,
>> but that is a new-kernel-only kind of thing.
> 
> Right - I'm wondering if any such changes as propsed here are now
> obsolted already by khwrngd?
> 
In this case, yes, khwrngd would be a better solution for current kernels.
	-hpa
^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
       [not found]       ` <53E54533.8030109@linux.intel.com>
@ 2014-08-11  7:15         ` Amit Shah
  2014-08-11 13:30           ` Torsten Duwe
       [not found]           ` <20140811133030.GA27247@lst.de>
  0 siblings, 2 replies; 11+ messages in thread
From: Amit Shah @ 2014-08-11  7:15 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: jgarzik, Ricardo Neri, linux-kernel, Virtualization List, duwe
On (Fri) 08 Aug 2014 [14:46:27], H. Peter Anvin wrote:
> On 08/08/2014 02:07 AM, Amit Shah wrote:
> >
> > 
> >>  To
> >> some degree the above is obsolete when we get khwrngd widely deployed,
> >> but that is a new-kernel-only kind of thing.
> > 
> > Right - I'm wondering if any such changes as propsed here are now
> > obsolted already by khwrngd?
> > 
> 
> In this case, yes, khwrngd would be a better solution for current kernels.
I think that's OK with me.
What's the suggested value for rng->quality, though, for virtio-rng
that I can use to ensure the kthread starts?
Should I use the 700 (70%) as proposed in the original patchset?  I'm
not exactly sure how that value will be used as well..
		Amit
^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
  2014-08-11  7:15         ` Amit Shah
@ 2014-08-11 13:30           ` Torsten Duwe
       [not found]           ` <20140811133030.GA27247@lst.de>
  1 sibling, 0 replies; 11+ messages in thread
From: Torsten Duwe @ 2014-08-11 13:30 UTC (permalink / raw)
  To: Amit Shah
  Cc: jgarzik, Ricardo Neri, linux-kernel, Virtualization List,
	H. Peter Anvin
On Mon, Aug 11, 2014 at 12:45:27PM +0530, Amit Shah wrote:
> 
> What's the suggested value for rng->quality, though, for virtio-rng
> that I can use to ensure the kthread starts?
> 
> Should I use the 700 (70%) as proposed in the original patchset?  I'm
> not exactly sure how that value will be used as well..
There is no such thing as a suggested value, every number is wrong
to some degree.  The quality is an estimation of how random your
source really is; it's a property of your hardware. If the device is
virtual you're in trouble ;-)
Either you have a way to query the underlying real hardware, or
you do your whitening and entropy estimation in the backend driver --
then you can claim 100%.
	Torsten
^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
       [not found]           ` <20140811133030.GA27247@lst.de>
@ 2014-08-11 16:50             ` H. Peter Anvin
  0 siblings, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2014-08-11 16:50 UTC (permalink / raw)
  To: Torsten Duwe, Amit Shah
  Cc: jgarzik, Ricardo Neri, linux-kernel, Virtualization List
On 08/11/2014 06:30 AM, Torsten Duwe wrote:
> On Mon, Aug 11, 2014 at 12:45:27PM +0530, Amit Shah wrote:
>>
>> What's the suggested value for rng->quality, though, for virtio-rng
>> that I can use to ensure the kthread starts?
>>
>> Should I use the 700 (70%) as proposed in the original patchset?  I'm
>> not exactly sure how that value will be used as well..
> 
> There is no such thing as a suggested value, every number is wrong
> to some degree.  The quality is an estimation of how random your
> source really is; it's a property of your hardware. If the device is
> virtual you're in trouble ;-)
> 
> Either you have a way to query the underlying real hardware, or
> you do your whitening and entropy estimation in the backend driver --
> then you can claim 100%.
> 
virtio-rng I feel we could rank at 100%; it is supposed to feed
/dev/random-quality randomness from the VMM.  If the VMM is hostile you
have already lost anyway.
	-hpa
^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] Install udev rules in system-default directory
  2014-08-07 13:09 ` [PATCH 2/2] Install udev rules in system-default directory Amit Shah
@ 2014-08-19 17:20   ` Paolo Bonzini
  2014-08-20  4:36     ` Amit Shah
  0 siblings, 1 reply; 11+ messages in thread
From: Paolo Bonzini @ 2014-08-19 17:20 UTC (permalink / raw)
  To: Amit Shah, jgarzik; +Cc: hpa, linux-kernel, Virtualization List
Il 07/08/2014 15:09, Amit Shah ha scritto:
> +udevrules_DATA	 = 90-virtio-rng.rules
If rng-tools is packaged with "make dist" you need this to be
dist_udevrules_DATA	 = 90-virtio-rng.rules
or alternatively
EXTRA_DIST = 90-virtio-rng.rules
udevrules_DATA	 = 90-virtio-rng.rules
> +AC_ARG_WITH([udevrulesdir],
> +	AS_HELP_STRING([--with-udevrulesdir=DIR], [Directory for udev rules]),
> +	[],
> +	[with_udevrulesdir=$($PKG_CONFIG --variable=udevdir udev)"/rules.d"])
> +AC_SUBST([udevrulesdir], [$with_udevrulesdir])
You can use AM_CONDITIONAL to skip the installation if
$with_udevrulesdir is "no" (aka --without-udevrulesdir).  Then you'd have
EXTRA_DIST = 90-virtio-rng.rules
if INSTALL_UDEV_RULES
udevrules_DATA	 = 90-virtio-rng.rules
endif
I don't know offhand if this works:
if INSTALL_UDEV_RULES
dist_udevrules_DATA	 = 90-virtio-rng.rules
endif
but I think so; you can check with "./configure --without-udevrulesdir
&& make && make dist".
Thanks,
Paolo
^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] Install udev rules in system-default directory
  2014-08-19 17:20   ` Paolo Bonzini
@ 2014-08-20  4:36     ` Amit Shah
  0 siblings, 0 replies; 11+ messages in thread
From: Amit Shah @ 2014-08-20  4:36 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: jgarzik, hpa, linux-kernel, Virtualization List
On (Tue) 19 Aug 2014 [19:20:20], Paolo Bonzini wrote:
> Il 07/08/2014 15:09, Amit Shah ha scritto:
> > +udevrules_DATA	 = 90-virtio-rng.rules
> 
> If rng-tools is packaged with "make dist" you need this to be
> 
> dist_udevrules_DATA	 = 90-virtio-rng.rules
> 
> or alternatively
> 
> EXTRA_DIST = 90-virtio-rng.rules
> udevrules_DATA	 = 90-virtio-rng.rules
> 
> > +AC_ARG_WITH([udevrulesdir],
> > +	AS_HELP_STRING([--with-udevrulesdir=DIR], [Directory for udev rules]),
> > +	[],
> > +	[with_udevrulesdir=$($PKG_CONFIG --variable=udevdir udev)"/rules.d"])
> > +AC_SUBST([udevrulesdir], [$with_udevrulesdir])
> 
> You can use AM_CONDITIONAL to skip the installation if
> $with_udevrulesdir is "no" (aka --without-udevrulesdir).  Then you'd have
> 
> EXTRA_DIST = 90-virtio-rng.rules
> if INSTALL_UDEV_RULES
> udevrules_DATA	 = 90-virtio-rng.rules
> endif
> 
> I don't know offhand if this works:
> 
> if INSTALL_UDEV_RULES
> dist_udevrules_DATA	 = 90-virtio-rng.rules
> endif
> 
> but I think so; you can check with "./configure --without-udevrulesdir
> && make && make dist".
Thanks!  Will give this a shot for curiosity's sake.  The
khwrngd-based patch has already been merged upstream, so this is now
obsolete.
		Amit
^ permalink raw reply	[flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-08-20  4:36 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-07 13:08 [PATCH 0/2] rng-tools: add udev rule for virtio-rng Amit Shah
2014-08-07 13:08 ` [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present Amit Shah
2014-08-07 19:31   ` H. Peter Anvin
     [not found]   ` <53E3D3FF.70707@linux.intel.com>
2014-08-08  9:07     ` Amit Shah
2014-08-08 21:46       ` H. Peter Anvin
     [not found]       ` <53E54533.8030109@linux.intel.com>
2014-08-11  7:15         ` Amit Shah
2014-08-11 13:30           ` Torsten Duwe
     [not found]           ` <20140811133030.GA27247@lst.de>
2014-08-11 16:50             ` H. Peter Anvin
2014-08-07 13:09 ` [PATCH 2/2] Install udev rules in system-default directory Amit Shah
2014-08-19 17:20   ` Paolo Bonzini
2014-08-20  4:36     ` Amit Shah
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).