* [PATCH 1/4] random: use device attach events for entropy
[not found] <1383485595-2020-1-git-send-email-tytso@mit.edu>
@ 2013-11-03 13:33 ` Theodore Ts'o
2013-11-03 14:51 ` Greg KH
2013-11-03 23:10 ` Theodore Ts'o
0 siblings, 2 replies; 4+ messages in thread
From: Theodore Ts'o @ 2013-11-03 13:33 UTC (permalink / raw)
To: linux-crypto; +Cc: linux-kernel, Theodore Ts'o, stable
Some investigation from FreeBSD shows that there is entropy available
from measuring the device attach times:
http://lists.randombit.net/pipermail/cryptography/2013-October/005689.html
This will hopefully help us more quickly initialize the entropy pools
while the system is booting (which is one of the times when we really
badly need more entropy, especially in the case of the first boot
after an consumer electronics device is taken out of the box).
Measurements indicate this makes a huge improvement in the security of
/dev/urandom during the boot sequence, so I'm cc'ing this to the
stable kernel series. Especially for embedded systems, which use
flash and which don't necessarily have the network enabled when they
first generate ssh or x.509 keys (sigh), this can be a big deal.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
---
drivers/base/core.c | 3 +++
drivers/char/random.c | 7 +++++++
include/linux/random.h | 2 ++
3 files changed, 12 insertions(+)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 8856d74..5e98fc3 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -26,6 +26,7 @@
#include <linux/async.h>
#include <linux/pm_runtime.h>
#include <linux/netdevice.h>
+#include <linux/random.h>
#include "base.h"
#include "power/power.h"
@@ -1156,6 +1157,8 @@ int device_add(struct device *dev)
class_intf->add_dev(dev, class_intf);
mutex_unlock(&dev->class->p->mutex);
}
+ add_device_attach_randomness(dev);
+
done:
put_device(dev);
return error;
diff --git a/drivers/char/random.c b/drivers/char/random.c
index f126bd2..51153fe 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -829,6 +829,13 @@ void add_input_randomness(unsigned int type, unsigned int code,
}
EXPORT_SYMBOL_GPL(add_input_randomness);
+void add_device_attach_randomness(struct device *dev)
+{
+ static struct timer_rand_state attach_state = { 0, };
+
+ add_timer_randomness(&attach_state, dev->devt);
+}
+
static DEFINE_PER_CPU(struct fast_pool, irq_randomness);
void add_interrupt_randomness(int irq, int irq_flags)
diff --git a/include/linux/random.h b/include/linux/random.h
index 6312dd9..5ef9470 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -12,6 +12,8 @@
extern void add_device_randomness(const void *, unsigned int);
extern void add_input_randomness(unsigned int type, unsigned int code,
unsigned int value);
+struct device;
+extern void add_device_attach_randomness(struct device *dev);
extern void add_interrupt_randomness(int irq, int irq_flags);
extern void get_random_bytes(void *buf, int nbytes);
--
1.7.12.rc0.22.gcdd159b
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/4] random: use device attach events for entropy
2013-11-03 13:33 ` [PATCH 1/4] random: use device attach events for entropy Theodore Ts'o
@ 2013-11-03 14:51 ` Greg KH
2013-11-03 18:44 ` Theodore Ts'o
2013-11-03 23:10 ` Theodore Ts'o
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2013-11-03 14:51 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: linux-crypto, linux-kernel, stable
On Sun, Nov 03, 2013 at 08:33:12AM -0500, Theodore Ts'o wrote:
> Some investigation from FreeBSD shows that there is entropy available
> from measuring the device attach times:
>
> http://lists.randombit.net/pipermail/cryptography/2013-October/005689.html
>
> This will hopefully help us more quickly initialize the entropy pools
> while the system is booting (which is one of the times when we really
> badly need more entropy, especially in the case of the first boot
> after an consumer electronics device is taken out of the box).
>
> Measurements indicate this makes a huge improvement in the security of
> /dev/urandom during the boot sequence, so I'm cc'ing this to the
> stable kernel series. Especially for embedded systems, which use
> flash and which don't necessarily have the network enabled when they
> first generate ssh or x.509 keys (sigh), this can be a big deal.
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> Cc: stable@vger.kernel.org
> ---
> drivers/base/core.c | 3 +++
> drivers/char/random.c | 7 +++++++
> include/linux/random.h | 2 ++
> 3 files changed, 12 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 8856d74..5e98fc3 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -26,6 +26,7 @@
> #include <linux/async.h>
> #include <linux/pm_runtime.h>
> #include <linux/netdevice.h>
> +#include <linux/random.h>
>
> #include "base.h"
> #include "power/power.h"
> @@ -1156,6 +1157,8 @@ int device_add(struct device *dev)
> class_intf->add_dev(dev, class_intf);
> mutex_unlock(&dev->class->p->mutex);
> }
> + add_device_attach_randomness(dev);
> +
> done:
> put_device(dev);
> return error;
> diff --git a/drivers/char/random.c b/drivers/char/random.c
> index f126bd2..51153fe 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -829,6 +829,13 @@ void add_input_randomness(unsigned int type, unsigned int code,
> }
> EXPORT_SYMBOL_GPL(add_input_randomness);
>
> +void add_device_attach_randomness(struct device *dev)
> +{
> + static struct timer_rand_state attach_state = { 0, };
> +
> + add_timer_randomness(&attach_state, dev->devt);
Is it an issue that dev->devt will almost always be 0,0 for this
function call? Why not use the name instead here, that's more "unique"
and every device has one, not just a tiny %.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/4] random: use device attach events for entropy
2013-11-03 14:51 ` Greg KH
@ 2013-11-03 18:44 ` Theodore Ts'o
0 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2013-11-03 18:44 UTC (permalink / raw)
To: Greg KH; +Cc: linux-crypto, linux-kernel, stable
On Sun, Nov 03, 2013 at 06:51:18AM -0800, Greg KH wrote:
> Is it an issue that dev->devt will almost always be 0,0 for this
> function call? Why not use the name instead here, that's more "unique"
> and every device has one, not just a tiny %.
Hmm, good point. Thanks for raising it. I'll make this change and
respin the patches.
- Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/4] random: use device attach events for entropy
2013-11-03 13:33 ` [PATCH 1/4] random: use device attach events for entropy Theodore Ts'o
2013-11-03 14:51 ` Greg KH
@ 2013-11-03 23:10 ` Theodore Ts'o
1 sibling, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2013-11-03 23:10 UTC (permalink / raw)
To: linux-crypto; +Cc: linux-kernel, stable
On Sun, Nov 03, 2013 at 08:33:12AM -0500, Theodore Ts'o wrote:
> Some investigation from FreeBSD shows that there is entropy available
> from measuring the device attach times:
>
> http://lists.randombit.net/pipermail/cryptography/2013-October/005689.html
>
> This will hopefully help us more quickly initialize the entropy pools
> while the system is booting (which is one of the times when we really
> badly need more entropy, especially in the case of the first boot
> after an consumer electronics device is taken out of the box).
>
> Measurements indicate this makes a huge improvement in the security of
> /dev/urandom during the boot sequence, so I'm cc'ing this to the
> stable kernel series. Especially for embedded systems, which use
> flash and which don't necessarily have the network enabled when they
> first generate ssh or x.509 keys (sigh), this can be a big deal.
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> Cc: stable@vger.kernel.org
Self-NAK. After doing some more measurements, I'm not convinced the
entropy estimator is working well given how we are collecting the
device attach times. Instead, we need to measure the delta between
the start and the end of the device probe, which in turn will only
work if we have a valid cycle counter. (random_get_entropy() is not
going to cut it.)
So with some changes, this approach will improve things on x86, but on
architectures like ARM, which generally don't have a cycle counter,
the jiffies counter is not going to have enough resolution to do
something useful --- and it was on platforms such as ARM and MIPS
where I was hoping this would be most useful. Grumble.
Why can't ARM and MIPS have decent cycle counters? <Shakes fist>
- Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-11-03 23:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1383485595-2020-1-git-send-email-tytso@mit.edu>
2013-11-03 13:33 ` [PATCH 1/4] random: use device attach events for entropy Theodore Ts'o
2013-11-03 14:51 ` Greg KH
2013-11-03 18:44 ` Theodore Ts'o
2013-11-03 23:10 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox