Skip to content

Commit

Permalink
lib/test_printf.c: call wait_for_random_bytes() before plain %p tests
Browse files Browse the repository at this point in the history
If the test_printf module is loaded before the crng is initialized, the
plain 'p' tests will fail because the printed address will not be hashed
and the buffer will contain '(ptrval)' instead.

This patch adds a call to wait_for_random_bytes() before plain 'p' tests
to make sure the crng is initialized.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thierry Escande <[email protected]>
Acked-by: Tobin C. Harding <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: David Miller <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Thierry Escande authored and torvalds committed Jun 14, 2018
1 parent 608dbdf commit ee410f1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/test_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ plain(void)
{
int err;

/*
* Make sure crng is ready. Otherwise we get "(ptrval)" instead
* of a hashed address when printing '%p' in plain_hash() and
* plain_format().
*/
wait_for_random_bytes();

err = plain_hash();
if (err) {
pr_warn("plain 'p' does not appear to be hashed\n");
Expand Down

0 comments on commit ee410f1

Please sign in to comment.