fix typo/thinko in get_random_bytes()
PATCH 1/1 fix typo/thinko 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.
---
drivers/char/random.c +1 -1
@@ -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; }
Quoted 6 lines · Tony
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 <[email protected]>
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.
Linus, do you want to take this one or should I put it in the urgent queue in tip?
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Thomas Gleixner
Acked-byQuoted 6 lines · H. Peter Anvin
Quoted 5 lines · Tony
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.
Quoted 6 lines
Quoted 1 line
Signed-off-by Tony Luck <[email protected]>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 <[email protected]>
H. Peter Anvin
AppliedQuoted 10 lines · Thomas Gleixner
Quoted 6 lines · H. Peter Anvin
Quoted 5 lines · Tony
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.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Tony Luck <[email protected]>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 <[email protected]>Acked-by Thomas Gleixner <[email protected]>
Applied to x86/urgent... I'll try to get the tip-bot back online today if I can find the time.
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
[tip:x86/urgent] random: Fix handing of arch_get_random_long in get_random_bytes()
In reply to Luck, TonyCommit-ID: 0d2f096b8785b67c38afcf6e1fbb9674af2e05ca Gitweb: http://git.kernel.org/tip/0d2f096b8785b67c38afcf6e1fbb9674af2e05ca Author: Luck, Tony <[email protected]> AuthorDate: Wed, 16 Nov 2011 10:50:56 -0800 Committer: H. Peter Anvin <[email protected]> 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.
--- drivers/char/random.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/random.c +1 -1
@@ -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; }