All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix typo/thinko in get_random_bytes()
@ 2011-11-16 18:50 Luck, Tony
  2011-11-16 19:34 ` H. Peter Anvin
  2011-11-18 23:45 ` [tip:x86/urgent] random: Fix handing of arch_get_random_long " tip-bot for Luck, Tony
  0 siblings, 2 replies; 5+ messages in thread
From: Luck, Tony @ 2011-11-16 18:50 UTC (permalink / raw)
  To: Linus Torvalds, H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	Fenghua Yu, Matt Mackall, Herbert Xu, Theodore Ts'o,
	Jeff Garzik, Arjan van de Ven, linux-kernel

If there is an architecture-specific random number generator we use
it to acquire randomness one "long" at a time. We should put these
random words into consecutive words in the result buffer - not just
overwrite the first word again and again.

Signed-off-by: Tony Luck <tony.luck@intel.com>

---

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 63e19ba..6035ab8 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -941,7 +941,7 @@ void get_random_bytes(void *buf, int nbytes)
 		if (!arch_get_random_long(&v))
 			break;
 		
-		memcpy(buf, &v, chunk);
+		memcpy(p, &v, chunk);
 		p += chunk;
 		nbytes -= chunk;
 	}

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix typo/thinko in get_random_bytes()
  2011-11-16 18:50 [PATCH] fix typo/thinko in get_random_bytes() Luck, Tony
@ 2011-11-16 19:34 ` H. Peter Anvin
  2011-11-16 19:41   ` Thomas Gleixner
  2011-11-18 23:45 ` [tip:x86/urgent] random: Fix handing of arch_get_random_long " tip-bot for Luck, Tony
  1 sibling, 1 reply; 5+ messages in thread
From: H. Peter Anvin @ 2011-11-16 19:34 UTC (permalink / raw)
  To: Luck, Tony
  Cc: Linus Torvalds, Ingo Molnar, Thomas Gleixner, Fenghua Yu,
	Matt Mackall, Herbert Xu, Theodore Ts'o, Jeff Garzik,
	Arjan van de Ven, linux-kernel

On 11/16/2011 10:50 AM, Luck, Tony wrote:
> If there is an architecture-specific random number generator we use
> it to acquire randomness one "long" at a time. We should put these
> random words into consecutive words in the result buffer - not just
> overwrite the first word again and again.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>

Ouch.  Good catch.  This, I guess, is the downside of doing this only on
the kernel paths... made this kind of errors harder to catch.

Acked-by: H. Peter Anvin <hpa@zytor.com>

Linus, do you want to take this one or should I put it in the urgent
queue in tip?

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix typo/thinko in get_random_bytes()
  2011-11-16 19:34 ` H. Peter Anvin
@ 2011-11-16 19:41   ` Thomas Gleixner
  2011-11-17 16:34     ` H. Peter Anvin
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2011-11-16 19:41 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Luck, Tony, Linus Torvalds, Ingo Molnar, Fenghua Yu, Matt Mackall,
	Herbert Xu, Theodore Ts'o, Jeff Garzik, Arjan van de Ven,
	linux-kernel



On Wed, 16 Nov 2011, H. Peter Anvin wrote:

> On 11/16/2011 10:50 AM, Luck, Tony wrote:
> > If there is an architecture-specific random number generator we use
> > it to acquire randomness one "long" at a time. We should put these
> > random words into consecutive words in the result buffer - not just
> > overwrite the first word again and again.
> > 
> > Signed-off-by: Tony Luck <tony.luck@intel.com>
> 
> Ouch.  Good catch.  This, I guess, is the downside of doing this only on
> the kernel paths... made this kind of errors harder to catch.
> 
> Acked-by: H. Peter Anvin <hpa@zytor.com>

Acked-by: Thomas Gleixner <tglx@linutronix.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix typo/thinko in get_random_bytes()
  2011-11-16 19:41   ` Thomas Gleixner
@ 2011-11-17 16:34     ` H. Peter Anvin
  0 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2011-11-17 16:34 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Luck, Tony, Linus Torvalds, Ingo Molnar, Fenghua Yu, Matt Mackall,
	Herbert Xu, Theodore Ts'o, Jeff Garzik, Arjan van de Ven,
	linux-kernel

On 11/16/2011 11:41 AM, Thomas Gleixner wrote:
> 
> 
> On Wed, 16 Nov 2011, H. Peter Anvin wrote:
> 
>> On 11/16/2011 10:50 AM, Luck, Tony wrote:
>>> If there is an architecture-specific random number generator we use
>>> it to acquire randomness one "long" at a time. We should put these
>>> random words into consecutive words in the result buffer - not just
>>> overwrite the first word again and again.
>>>
>>> Signed-off-by: Tony Luck <tony.luck@intel.com>
>>
>> Ouch.  Good catch.  This, I guess, is the downside of doing this only on
>> the kernel paths... made this kind of errors harder to catch.
>>
>> Acked-by: H. Peter Anvin <hpa@zytor.com>
> 
> Acked-by: Thomas Gleixner <tglx@linutronix.de>

Applied to x86/urgent... I'll try to get the tip-bot back online today
if I can find the time.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:x86/urgent] random: Fix handing of arch_get_random_long in get_random_bytes()
  2011-11-16 18:50 [PATCH] fix typo/thinko in get_random_bytes() Luck, Tony
  2011-11-16 19:34 ` H. Peter Anvin
@ 2011-11-18 23:45 ` tip-bot for Luck, Tony
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Luck, Tony @ 2011-11-18 23:45 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tony.luck, tglx, hpa

Commit-ID:  0d2f096b8785b67c38afcf6e1fbb9674af2e05ca
Gitweb:     http://git.kernel.org/tip/0d2f096b8785b67c38afcf6e1fbb9674af2e05ca
Author:     Luck, Tony <tony.luck@intel.com>
AuthorDate: Wed, 16 Nov 2011 10:50:56 -0800
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Wed, 16 Nov 2011 16:41:02 -0800

random: Fix handing of arch_get_random_long in get_random_bytes()

If there is an architecture-specific random number generator we use
it to acquire randomness one "long" at a time. We should put these
random words into consecutive words in the result buffer - not just
overwrite the first word again and again.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/4ec4061010261a4cb0@agluck-desktop.sc.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 drivers/char/random.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 63e19ba..6035ab8 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -941,7 +941,7 @@ void get_random_bytes(void *buf, int nbytes)
 		if (!arch_get_random_long(&v))
 			break;
 		
-		memcpy(buf, &v, chunk);
+		memcpy(p, &v, chunk);
 		p += chunk;
 		nbytes -= chunk;
 	}

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-18 23:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-16 18:50 [PATCH] fix typo/thinko in get_random_bytes() Luck, Tony
2011-11-16 19:34 ` H. Peter Anvin
2011-11-16 19:41   ` Thomas Gleixner
2011-11-17 16:34     ` H. Peter Anvin
2011-11-18 23:45 ` [tip:x86/urgent] random: Fix handing of arch_get_random_long " tip-bot for Luck, Tony

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.