Re: Replace /dev/random input mix polynomial with Brent's xorgen?

2013-12-15 Thread Greg Price
On Sun, Dec 15, 2013 at 05:09:10PM -0500, George Spelvin wrote: > Well, /dev/urandom is documented as being *deliberately* slow. It's meant > only to produce 128 to 256 bits of seed material for CPRNG. I don't > know if Ted considers speeding it up to be goal or an antigoal. :-) Hmm, I don't

Re: Replace /dev/random input mix polynomial with Brent's xorgen?

2013-12-15 Thread Greg Price
On Sat, Dec 14, 2013 at 02:23:07PM -0500, Theodore Ts'o wrote: > I'm much more inclined to think about changing how we generate random > numbers from the output pool by switching from using SHA to AES in > some one-way random function mode (i.e., such as the Davies-Meyer > construction), since

Re: Replace /dev/random input mix polynomial with Brent's xorgen?

2013-12-15 Thread Greg Price
On Sun, Dec 15, 2013 at 05:09:10PM -0500, George Spelvin wrote: Well, /dev/urandom is documented as being *deliberately* slow. It's meant only to produce 128 to 256 bits of seed material for CPRNG. I don't know if Ted considers speeding it up to be goal or an antigoal. :-) Hmm, I don't think

Re: Replace /dev/random input mix polynomial with Brent's xorgen?

2013-12-15 Thread Greg Price
On Sat, Dec 14, 2013 at 02:23:07PM -0500, Theodore Ts'o wrote: I'm much more inclined to think about changing how we generate random numbers from the output pool by switching from using SHA to AES in some one-way random function mode (i.e., such as the Davies-Meyer construction), since that is

[PATCH 05/14] random: move transfer accounting into account() helper

2013-12-14 Thread Greg Price
particularly helpful in the next commit, where we add another parameter to account() and extract_entropy(). Signed-off-by: Greg Price --- drivers/char/random.c | 61 --- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/drivers/cha

[PATCH 12/14] random: separate minimum reseed size from minimum /dev/random read

2013-12-14 Thread Greg Price
and the kernel's general use, on the other hand, should be at least 128 for good commercial security and users may want it higher. Make a new parameter for the minimum size of a reseed, and make it 128 by default. Signed-off-by: Greg Price --- drivers/char/random.c | 46

[PATCH 13/14] random: count only catastrophic reseeds for initialization

2013-12-14 Thread Greg Price
rrent code, as we don't make repeated small reseeds anyway, but it's best to be clear. Rename entropy_total to seed_entropy_bits to reflect its new function. While touching the not-yet-initialized warnings, checkpatch complains about printk(KERN_NOTICE, ...), so switch to pr_notice etc. Signed-of

[PATCH 14/14] random: target giant reseeds, to be conservative

2013-12-14 Thread Greg Price
e glimpses the internal state -- which is largely an academic question, given what an attacker who can read kernel memory is usually able to do. We still take a regular-sized seed up front so as not to delay getting initialized. Signed-off-by: Greg Price --- drivers/char/ran

[PATCH 08/14] random: rate-limit reseeding only after properly seeded

2013-12-14 Thread Greg Price
Until then, we need all the entropy we can get. The "min_bytes" logic takes care of making these reseeds catastrophic, and reserving entropy for /dev/random isn't a priority in early boot. Signed-off-by: Greg Price --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+),

[PATCH 03/14] random: reserve for /dev/random only once /dev/urandom seeded

2013-12-14 Thread Greg Price
is seeded is no big deal. This logic still ensures that /dev/random readers won't starve indefinitely. At present most input goes directly to the nonblocking pool early on anyway, but this helps put us in a position to change that. Signed-off-by: Greg Price --- drivers/char/random.c | 12

[PATCH 06/14] random: separate quantity of bytes extracted and entropy to credit

2013-12-14 Thread Greg Price
are interchangeable, but the next commit will make them differ. Signed-off-by: Greg Price --- drivers/char/random.c | 24 ++-- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index a624262e8..c11281551 100644

[PATCH 04/14] random: accept small seeds early on

2013-12-14 Thread Greg Price
reseed while producing output from virtually no entropy. At present most input goes directly to the nonblocking pool early on anyway, but this helps put us in a position to change that. Signed-off-by: Greg Price --- drivers/char/random.c | 17 + 1 file changed, 13 insertions(+), 4

[PATCH 09/14] random: reserve entropy for nonblocking pool early on

2013-12-14 Thread Greg Price
that. This adds a wrinkle to determining when we're ready for someone to read from /dev/random, so factor that out. At present most input goes directly to the nonblocking pool early on anyway, but this puts us in a position to change that. Signed-off-by: Greg Price --- drivers/char/random.c | 25

[PATCH 11/14] random: separate entropy since auto-push from entropy_total

2013-12-14 Thread Greg Price
the computation on nonblocking_pool. Also compute 'initialized' only for nonblocking_pool, which is the only place where the concept really makes sense. Signed-off-by: Greg Price --- drivers/char/random.c | 17 + include/trace/events/random.h | 24 ++-- 2

[PATCH 10/14] random: direct all routine input via input pool

2013-12-14 Thread Greg Price
complished by sending the input straight to the nonblocking pool early on. Signed-off-by: Greg Price --- drivers/char/random.c | 19 ++- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 58e3e81d4..ea389723f 100644 --- a/dr

[PATCH 07/14] random: exploit any extra entropy too when reseeding

2013-12-14 Thread Greg Price
. The credit_bits output parameter takes care of that. Signed-off-by: Greg Price --- drivers/char/random.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/char/random.c b/drivers/char/random.c index c11281551..c2428ecb2 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c

[PATCH 01/14] random: fix signedness bug

2013-12-14 Thread Greg Price
andom: simplify accounting code" a few commits ago. Before that, for a long time we would compare have_bytes - reserved (or equivalent) to ibytes or store it into ibytes, but only inside a condition that guaranteed it wasn't negative. Signed-off-by: Greg Price --- drivers/char/random.c | 3 +

[PATCH 02/14] random: fix a (harmless) overflow

2013-12-14 Thread Greg Price
it clear that overflow isn't an issue. Also we might be less likely to make mistakes like the one fixed in the previous commit. As a bonus, give a name to the minimum number of bytes to pull, which we use twice. Signed-off-by: Greg Price --- drivers/char/random.c | 11 +-- 1 file changed, 5

[PATCH 00/14] random: rework reseeding

2013-12-14 Thread Greg Price
the target (by default 512b estimated.) Until we first reach the minimum reseed size (128b by default), all input collected is exclusively for the nonblocking pool and /dev/random readers must wait. Cheers, Greg Greg Price (14): random: fix signedness bug random: fix a (harmless) overflow rando

[PATCH 02/14] random: fix a (harmless) overflow

2013-12-14 Thread Greg Price
it clear that overflow isn't an issue. Also we might be less likely to make mistakes like the one fixed in the previous commit. As a bonus, give a name to the minimum number of bytes to pull, which we use twice. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 11 +-- 1

[PATCH 00/14] random: rework reseeding

2013-12-14 Thread Greg Price
(by default 512b estimated.) Until we first reach the minimum reseed size (128b by default), all input collected is exclusively for the nonblocking pool and /dev/random readers must wait. Cheers, Greg Greg Price (14): random: fix signedness bug random: fix a (harmless) overflow random: reserve

[PATCH 01/14] random: fix signedness bug

2013-12-14 Thread Greg Price
: simplify accounting code a few commits ago. Before that, for a long time we would compare have_bytes - reserved (or equivalent) to ibytes or store it into ibytes, but only inside a condition that guaranteed it wasn't negative. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 3 ++- 1

[PATCH 04/14] random: accept small seeds early on

2013-12-14 Thread Greg Price
reseed while producing output from virtually no entropy. At present most input goes directly to the nonblocking pool early on anyway, but this helps put us in a position to change that. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 17 + 1 file changed, 13

[PATCH 09/14] random: reserve entropy for nonblocking pool early on

2013-12-14 Thread Greg Price
that. This adds a wrinkle to determining when we're ready for someone to read from /dev/random, so factor that out. At present most input goes directly to the nonblocking pool early on anyway, but this puts us in a position to change that. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c

[PATCH 11/14] random: separate entropy since auto-push from entropy_total

2013-12-14 Thread Greg Price
the computation on nonblocking_pool. Also compute 'initialized' only for nonblocking_pool, which is the only place where the concept really makes sense. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 17 + include/trace/events/random.h | 24

[PATCH 10/14] random: direct all routine input via input pool

2013-12-14 Thread Greg Price
by sending the input straight to the nonblocking pool early on. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 19 ++- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 58e3e81d4..ea389723f 100644

[PATCH 07/14] random: exploit any extra entropy too when reseeding

2013-12-14 Thread Greg Price
. The credit_bits output parameter takes care of that. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/char/random.c b/drivers/char/random.c index c11281551..c2428ecb2 100644 --- a/drivers/char/random.c +++ b/drivers/char

[PATCH 08/14] random: rate-limit reseeding only after properly seeded

2013-12-14 Thread Greg Price
Until then, we need all the entropy we can get. The min_bytes logic takes care of making these reseeds catastrophic, and reserving entropy for /dev/random isn't a priority in early boot. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH 03/14] random: reserve for /dev/random only once /dev/urandom seeded

2013-12-14 Thread Greg Price
is seeded is no big deal. This logic still ensures that /dev/random readers won't starve indefinitely. At present most input goes directly to the nonblocking pool early on anyway, but this helps put us in a position to change that. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 12

[PATCH 06/14] random: separate quantity of bytes extracted and entropy to credit

2013-12-14 Thread Greg Price
are interchangeable, but the next commit will make them differ. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 24 ++-- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index a624262e8..c11281551 100644

[PATCH 12/14] random: separate minimum reseed size from minimum /dev/random read

2013-12-14 Thread Greg Price
and the kernel's general use, on the other hand, should be at least 128 for good commercial security and users may want it higher. Make a new parameter for the minimum size of a reseed, and make it 128 by default. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 46

[PATCH 13/14] random: count only catastrophic reseeds for initialization

2013-12-14 Thread Greg Price
, as we don't make repeated small reseeds anyway, but it's best to be clear. Rename entropy_total to seed_entropy_bits to reflect its new function. While touching the not-yet-initialized warnings, checkpatch complains about printk(KERN_NOTICE, ...), so switch to pr_notice etc. Signed-off-by: Greg

[PATCH 14/14] random: target giant reseeds, to be conservative

2013-12-14 Thread Greg Price
the internal state -- which is largely an academic question, given what an attacker who can read kernel memory is usually able to do. We still take a regular-sized seed up front so as not to delay getting initialized. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 38

[PATCH 05/14] random: move transfer accounting into account() helper

2013-12-14 Thread Greg Price
add another parameter to account() and extract_entropy(). Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 61 --- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index

[PATCH 2/2] random: clarify bits/bytes in wakeup thresholds

2013-12-06 Thread Greg Price
These are a recurring cause of confusion, so rename them to hopefully be clearer. Signed-off-by: Greg Price --- drivers/char/random.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index

[3.13 PATCH 1/2] random: entropy_bytes is actually bits

2013-12-06 Thread Greg Price
The variable 'entropy_bytes' is set from an expression that actually counts bits. Fortunately it's also only compared to values that also count bits. Rename it accordingly. Signed-off-by: Greg Price --- drivers/char/random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff

[3.13 PATCH 0/2] random: bytes vs. bits

2013-12-06 Thread Greg Price
es should be clarified too.) This may as well be post-3.13. Cheers, Greg Greg Price (2): random: entropy_bytes is actually bits random: clarify bits/bytes in wakeup thresholds drivers/char/random.c | 36 ++-- 1 file changed, 18 insertions(+), 18

Re: [PATCH 9/9] random: simplify accounting code

2013-12-06 Thread Greg Price
On Thu, Dec 05, 2013 at 08:13:47PM -0500, Theodore Ts'o wrote: > On Wed, Nov 13, 2013 at 03:08:41AM -0500, Greg Price wrote: > > + if (ibytes && cmpxchg(>entropy_count, orig, entropy_count) != orig) > > + goto retry; > > I wonder if we would be better d

Re: [PATCH 9/9] random: simplify accounting code

2013-12-06 Thread Greg Price
On Thu, Dec 05, 2013 at 08:13:47PM -0500, Theodore Ts'o wrote: On Wed, Nov 13, 2013 at 03:08:41AM -0500, Greg Price wrote: + if (ibytes cmpxchg(r-entropy_count, orig, entropy_count) != orig) + goto retry; I wonder if we would be better dropping the test for ibytes here, so

[PATCH 2/2] random: clarify bits/bytes in wakeup thresholds

2013-12-06 Thread Greg Price
These are a recurring cause of confusion, so rename them to hopefully be clearer. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/char/random.c b/drivers/char

[3.13 PATCH 1/2] random: entropy_bytes is actually bits

2013-12-06 Thread Greg Price
The variable 'entropy_bytes' is set from an expression that actually counts bits. Fortunately it's also only compared to values that also count bits. Rename it accordingly. Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 6 +++--- 1 file changed, 3 insertions(+), 3

[3.13 PATCH 0/2] random: bytes vs. bits

2013-12-06 Thread Greg Price
.) This may as well be post-3.13. Cheers, Greg Greg Price (2): random: entropy_bytes is actually bits random: clarify bits/bytes in wakeup thresholds drivers/char/random.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) -- 1.8.3.2 -- To unsubscribe from

Re: [PATCH 4/9] random: simplify loop in random_read

2013-11-29 Thread Greg Price
On Fri, Nov 29, 2013 at 03:09:05PM -0500, Theodore Ts'o wrote: > Applied, although I slightly edited the commit description the the > debug message mentioned in the description was removed since the first > version of your patch series, and it wasn't updated as part of the > rebase. Ah, good

Re: [PATCH 4/9] random: simplify loop in random_read

2013-11-29 Thread Greg Price
On Fri, Nov 29, 2013 at 03:09:05PM -0500, Theodore Ts'o wrote: Applied, although I slightly edited the commit description the the debug message mentioned in the description was removed since the first version of your patch series, and it wasn't updated as part of the rebase. Ah, good catch.

Re: [PATCH] Clarify error on directive in macro arguments (Re: [PATCH] jffs2: fix sparse errors: directive in argument list)

2013-11-17 Thread Greg Price
On Sun, Nov 17, 2013 at 06:15:32PM -0800, Joe Perches wrote: > On Sun, 2013-11-17 at 21:07 -0500, Greg Price wrote: > > Perhaps the following tweak to the error message would make this > > subtlety clearer? > > Maybe, but this case isn't a macro. It's a function. > Dunno

[PATCH] Clarify error on directive in macro arguments (Re: [PATCH] jffs2: fix sparse errors: directive in argument list)

2013-11-17 Thread Greg Price
emantics for that gets real ugly real fast. > sparse matches gcc behaviour (I hope), but it warns about such abuses. > It's a defect, all right - one being reported by sparse. Perhaps the following tweak to the error message would make this subtlety clearer? Cheers, Greg From: Greg Price Date:

[PATCH] Clarify error on directive in macro arguments (Re: [PATCH] jffs2: fix sparse errors: directive in argument list)

2013-11-17 Thread Greg Price
behaviour (I hope), but it warns about such abuses. It's a defect, all right - one being reported by sparse. Perhaps the following tweak to the error message would make this subtlety clearer? Cheers, Greg From: Greg Price pr...@mit.edu Date: Sun, 17 Nov 2013 17:57:41 -0800 Subject: [PATCH

Re: [PATCH] Clarify error on directive in macro arguments (Re: [PATCH] jffs2: fix sparse errors: directive in argument list)

2013-11-17 Thread Greg Price
On Sun, Nov 17, 2013 at 06:15:32PM -0800, Joe Perches wrote: On Sun, 2013-11-17 at 21:07 -0500, Greg Price wrote: Perhaps the following tweak to the error message would make this subtlety clearer? Maybe, but this case isn't a macro. It's a function. Dunno if differentiating when it's

[PATCH 9/9] random: simplify accounting code

2013-11-13 Thread Greg Price
e had enough bits, even though we don't apply it to actually limit how many we take. The callers of account() never exercise either of these cases. Before the previous commit, it was possible for "nbytes" to be less than "min" if userspace chose a pathological configuration, but no longe

[PATCH 8/9] random: tighten bound on random_read_wakeup_thresh

2013-11-13 Thread Greg Price
o for now just limit them both. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 1f43f9e..865c8db 100644 --- a/drivers/char/random.c +++ b/dr

[PATCH 7/9] random: forget lock in lockless accounting

2013-11-13 Thread Greg Price
sses to ->entropy_count here. Drop the use of the lock. Cc: Jiri Kosina Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 5dffca8..1f43f9e 100644 --- a

[PATCH 5/9] random: fix comment on "account"

2013-11-13 Thread Greg Price
This comment didn't quite keep up as extract_entropy() was split into four functions. Put each bit by the function it describes. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 31 +-- 1 file changed, 21 insertions(+), 10

[PATCH 6/9] random: simplify accounting logic

2013-11-13 Thread Greg Price
ore Ts'o" Cc: Jiri Kosina Cc: "H. Peter Anvin" Signed-off-by: Greg Price --- drivers/char/random.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index fe7ecdd..5dffca8 100644 --- a/drivers/char/rand

[PATCH 3/9] random: fix description of get_random_bytes

2013-11-13 Thread Greg Price
After this remark was written, commit d2e7c96af added a use of arch_get_random_long() inside the get_random_bytes codepath. The main point stands, but it needs to be reworded. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 5 +++-- 1 file changed, 3 insert

[PATCH 4/9] random: simplify loop in random_read

2013-11-13 Thread Greg Price
Some other simplifications. The behavior should be identical except that I've changed a debug message. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 57 --- 1 file changed, 18 insertions(+), 39 deletions(-) diff

[PATCH 2/9] random: fix comment on proc_do_uuid

2013-11-13 Thread Greg Price
There's only one function here now, as uuid_strategy is long gone. Also make the bit about "If accesses via ..." clearer. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dri

[PATCH 1/9] random: fix typos / spelling errors in comments

2013-11-13 Thread Greg Price
Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index cdf4cfb..ed72be5 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -30

[PATCH v2 0/9] random: code cleanups

2013-11-13 Thread Greg Price
tightens slightly a bound on a sysctl value to avoid a pathological case. The bugfix that was in v1 was taken care of by Peter in a283b5c45 ("random: allow fractional bits to be tracked"). Cheers, Greg Greg Price (9): random: fix typos / spelling errors in comments random: f

[PATCH v2 0/9] random: code cleanups

2013-11-13 Thread Greg Price
tightens slightly a bound on a sysctl value to avoid a pathological case. The bugfix that was in v1 was taken care of by Peter in a283b5c45 (random: allow fractional bits to be tracked). Cheers, Greg Greg Price (9): random: fix typos / spelling errors in comments random: fix comment

[PATCH 2/9] random: fix comment on proc_do_uuid

2013-11-13 Thread Greg Price
There's only one function here now, as uuid_strategy is long gone. Also make the bit about If accesses via ... clearer. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git

[PATCH 1/9] random: fix typos / spelling errors in comments

2013-11-13 Thread Greg Price
Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index cdf4cfb..ed72be5 100644 --- a/drivers/char/random.c +++ b/drivers/char

[PATCH 3/9] random: fix description of get_random_bytes

2013-11-13 Thread Greg Price
After this remark was written, commit d2e7c96af added a use of arch_get_random_long() inside the get_random_bytes codepath. The main point stands, but it needs to be reworded. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 5 +++-- 1 file

[PATCH 4/9] random: simplify loop in random_read

2013-11-13 Thread Greg Price
simplifications. The behavior should be identical except that I've changed a debug message. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 57 --- 1 file changed, 18 insertions(+), 39 deletions(-) diff

[PATCH 6/9] random: simplify accounting logic

2013-11-13 Thread Greg Price
...@mit.edu Cc: Jiri Kosina jkos...@suse.cz Cc: H. Peter Anvin h...@zytor.com Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index fe7ecdd..5dffca8

[PATCH 7/9] random: forget lock in lockless accounting

2013-11-13 Thread Greg Price
. Drop the use of the lock. Cc: Jiri Kosina jkos...@suse.cz Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 5dffca8..1f43f9e 100644

[PATCH 8/9] random: tighten bound on random_read_wakeup_thresh

2013-11-13 Thread Greg Price
both. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 1f43f9e..865c8db 100644 --- a/drivers/char/random.c +++ b/drivers/char

[PATCH 5/9] random: fix comment on account

2013-11-13 Thread Greg Price
This comment didn't quite keep up as extract_entropy() was split into four functions. Put each bit by the function it describes. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 31 +-- 1 file changed, 21 insertions

[PATCH 9/9] random: simplify accounting code

2013-11-13 Thread Greg Price
() never exercise either of these cases. Before the previous commit, it was possible for nbytes to be less than min if userspace chose a pathological configuration, but no longer. Cc: Theodore Ts'o ty...@mit.edu Cc: Jiri Kosina jkos...@suse.cz Cc: H. Peter Anvin h...@zytor.com Signed-off-by: Greg

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Wed, Nov 13, 2013 at 01:08:07AM -0500, Theodore Ts'o wrote: > On Tue, Nov 12, 2013 at 11:23:03PM -0500, Greg Price wrote: > > That's a good idea. I've worried about the same thing, but hadn't > > thought of that solution. > > I think the key is that we set a default

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Tue, Nov 12, 2013 at 08:51:18PM -0800, H. Peter Anvin wrote: > On 11/12/2013 08:37 PM, Greg Price wrote: > > I'm thinking only of boot-time blocking. The idea is that once > > /dev/urandom is seeded with, say, 128 bits of min-entropy in the > > absolute, information-th

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Tue, Nov 12, 2013 at 08:02:09PM -0800, H. Peter Anvin wrote: > One thing, too, if we are talking about anything other than > boot-time-only blocking: going from a nonblocking to a blocking > condition means being able to accept a short read, and right now *many* > users of /dev/urandom are not

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Tue, Nov 12, 2013 at 10:32:05PM -0500, Theodore Ts'o wrote: > One of the things I've been thinking about with respect to making > /dev/urandom block is being able to configure (via a module parameter > which could be specified on the boot command line) which allows us to > set a limit for how

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Mon, Nov 11, 2013 at 11:24:44PM -0500, Theodore Ts'o wrote: > My apologies for not being able to get to this patch series before the > patch window opened --- this week has been crazy. None of the changes > seem to be especially critical, and a number of the patches don't > apply cleanly to

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Mon, Nov 11, 2013 at 11:24:44PM -0500, Theodore Ts'o wrote: My apologies for not being able to get to this patch series before the patch window opened --- this week has been crazy. None of the changes seem to be especially critical, and a number of the patches don't apply cleanly to the

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Tue, Nov 12, 2013 at 10:32:05PM -0500, Theodore Ts'o wrote: One of the things I've been thinking about with respect to making /dev/urandom block is being able to configure (via a module parameter which could be specified on the boot command line) which allows us to set a limit for how long

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Tue, Nov 12, 2013 at 08:02:09PM -0800, H. Peter Anvin wrote: One thing, too, if we are talking about anything other than boot-time-only blocking: going from a nonblocking to a blocking condition means being able to accept a short read, and right now *many* users of /dev/urandom are not

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Tue, Nov 12, 2013 at 08:51:18PM -0800, H. Peter Anvin wrote: On 11/12/2013 08:37 PM, Greg Price wrote: I'm thinking only of boot-time blocking. The idea is that once /dev/urandom is seeded with, say, 128 bits of min-entropy in the absolute, information-theoretic sense, it can produce

Re: [PATCH 00/11] random: code cleanups

2013-11-12 Thread Greg Price
On Wed, Nov 13, 2013 at 01:08:07AM -0500, Theodore Ts'o wrote: On Tue, Nov 12, 2013 at 11:23:03PM -0500, Greg Price wrote: That's a good idea. I've worried about the same thing, but hadn't thought of that solution. I think the key is that we set a default of requiring 128 bits, or 5

random: locking vs. lockless accesses

2013-11-11 Thread Greg Price
Hi Ted, After reading through the RNG code, I'm curious about one aspect and I wonder if you can shed light on it. Since v3.6-rc1~26^2~30 ("random: use lockless techniques in the interrupt path"), we mix bytes into the pool without taking the lock, when inside add_interrupt_randomness(). This

random: locking vs. lockless accesses

2013-11-11 Thread Greg Price
Hi Ted, After reading through the RNG code, I'm curious about one aspect and I wonder if you can shed light on it. Since v3.6-rc1~26^2~30 (random: use lockless techniques in the interrupt path), we mix bytes into the pool without taking the lock, when inside add_interrupt_randomness(). This

[PATCH 08/11] random: simplify accounting logic

2013-11-07 Thread Greg Price
c: Jiri Kosina Signed-off-by: Greg Price --- drivers/char/random.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 8824e8d..9e4645e 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -860,12 +860,7 @@ retry:

[PATCH 07/11] random: simplify accounting code slightly

2013-11-07 Thread Greg Price
This commit makes the very boring simplifications so that the next commit, which is a little trickier, is isolated and easy to review. No change in behavior here at all. Cc: "Theodore Ts'o" Cc: Jiri Kosina Signed-off-by: Greg Price --- drivers/char/random.c | 10 -- 1 file

[PATCH 11/11] random: simplify accounting code

2013-11-07 Thread Greg Price
e had enough bits, even though we don't apply it to actually limit how many we take. The callers of account() never exercise either of these cases. Cc: "Theodore Ts'o" Cc: Jiri Kosina Signed-off-by: Greg Price --- drivers/char/random.c | 23 --- 1 file changed, 8 insertions(

[PATCH 04/11] random: simplify loop in random_read

2013-11-07 Thread Greg Price
Some other simplifications. The behavior should be identical except that I've changed a debug message. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 68 +-- 1 file changed, 22 insertions(+), 46 deletions(-) diff

[PATCH 03/11] random: fix description of get_random_bytes

2013-11-07 Thread Greg Price
After this remark was written, commit d2e7c96af added a use of arch_get_random_long() inside the get_random_bytes codepath. The main point stands, but it needs to be reworded. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 5 +++-- 1 file changed, 3 insert

[PATCH 06/11] random: fix comment on "account"

2013-11-07 Thread Greg Price
This comment didn't quite keep up as extract_entropy() was split into four functions. Put each bit by the function it describes. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 31 +-- 1 file changed, 21 insertions(+), 10

[PATCH 05/11] random: declare trickle_count unsigned

2013-11-07 Thread Greg Price
We cheerfully overflow these variables (at least where "int" is 32 bits wide), so pedantically they should be unsigned. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cha

[PATCH 10/11] random: pull 'min' check in accounting to inside lockless update

2013-11-07 Thread Greg Price
erved bytes from the pool, even though this is less than min. Move the "min" check inside the ACCESS_ONCE/cmpxchg loop to prevent the race. Cc: Jiri Kosina Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 9 - 1 file changed, 4 insertion

[PATCH 09/11] random: forget lock in lockless accounting

2013-11-07 Thread Greg Price
sses to ->entropy_count here. Drop the use of the lock. Cc: Jiri Kosina Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 5 - 1 file changed, 5 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 9e4645e..1bf6bf8 100644 --- a

[PATCH 02/11] random: fix comment on proc_do_uuid

2013-11-07 Thread Greg Price
There's only one function here now, as uuid_strategy is long gone. Also make the bit about "If accesses via ..." clearer. Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dri

[PATCH 00/11] random: code cleanups

2013-11-07 Thread Greg Price
signedness fix. Two patches change the locking and lockless concurrency control in account(), including one bugfix. The bug is related to the one Jiri found and fixed in May. Cheers, Greg Greg Price (11): random: fix typos / spelling errors in comments random: fix comment on proc_do_uuid random

[PATCH 01/11] random: fix typos / spelling errors in comments

2013-11-07 Thread Greg Price
Cc: "Theodore Ts'o" Signed-off-by: Greg Price --- drivers/char/random.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 7a744d3..ef3e15b 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c

[PATCH 01/11] random: fix typos / spelling errors in comments

2013-11-07 Thread Greg Price
Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 7a744d3..ef3e15b 100644 --- a/drivers/char/random.c +++ b/drivers/char

[PATCH 00/11] random: code cleanups

2013-11-07 Thread Greg Price
signedness fix. Two patches change the locking and lockless concurrency control in account(), including one bugfix. The bug is related to the one Jiri found and fixed in May. Cheers, Greg Greg Price (11): random: fix typos / spelling errors in comments random: fix comment on proc_do_uuid random

[PATCH 02/11] random: fix comment on proc_do_uuid

2013-11-07 Thread Greg Price
There's only one function here now, as uuid_strategy is long gone. Also make the bit about If accesses via ... clearer. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git

[PATCH 03/11] random: fix description of get_random_bytes

2013-11-07 Thread Greg Price
After this remark was written, commit d2e7c96af added a use of arch_get_random_long() inside the get_random_bytes codepath. The main point stands, but it needs to be reworded. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 5 +++-- 1 file

[PATCH 06/11] random: fix comment on account

2013-11-07 Thread Greg Price
This comment didn't quite keep up as extract_entropy() was split into four functions. Put each bit by the function it describes. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 31 +-- 1 file changed, 21 insertions

[PATCH 05/11] random: declare trickle_count unsigned

2013-11-07 Thread Greg Price
We cheerfully overflow these variables (at least where int is 32 bits wide), so pedantically they should be unsigned. Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char

[PATCH 10/11] random: pull 'min' check in accounting to inside lockless update

2013-11-07 Thread Greg Price
the min check inside the ACCESS_ONCE/cmpxchg loop to prevent the race. Cc: Jiri Kosina jkos...@suse.cz Cc: Theodore Ts'o ty...@mit.edu Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/char

[PATCH 11/11] random: simplify accounting code

2013-11-07 Thread Greg Price
() never exercise either of these cases. Cc: Theodore Ts'o ty...@mit.edu Cc: Jiri Kosina jkos...@suse.cz Signed-off-by: Greg Price pr...@mit.edu --- drivers/char/random.c | 23 --- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/char/random.c b/drivers/char

  1   2   >