linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests
@ 2018-05-22 17:41 Thierry Escande
  2018-05-22 22:01 ` Tobin C . Harding
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Escande @ 2018-05-22 17:41 UTC (permalink / raw)
  To: Tobin C . Harding, Rasmus Villemoes; +Cc: linux-kernel

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.

Signed-off-by: Thierry Escande <thierry.escande@linaro.org>
---
 lib/test_printf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/test_printf.c b/lib/test_printf.c
index 71ebfa43ad05..839be9385a8a 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -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");
-- 
2.14.1

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

* Re: [PATCH] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests
  2018-05-22 17:41 [PATCH] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests Thierry Escande
@ 2018-05-22 22:01 ` Tobin C . Harding
  0 siblings, 0 replies; 2+ messages in thread
From: Tobin C . Harding @ 2018-05-22 22:01 UTC (permalink / raw)
  To: Thierry Escande; +Cc: Rasmus Villemoes, linux-kernel

On Tue, May 22, 2018 at 07:41:14PM +0200, Thierry Escande wrote:
> 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.
> 
> Signed-off-by: Thierry Escande <thierry.escande@linaro.org>
> ---
>  lib/test_printf.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/lib/test_printf.c b/lib/test_printf.c
> index 71ebfa43ad05..839be9385a8a 100644
> --- a/lib/test_printf.c
> +++ b/lib/test_printf.c
> @@ -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");
> -- 
> 2.14.1

Not sure if I'm qualified for this but here goes

Acked-by: Tobin C. Harding <me@tobin.cc>

thanks,
Tobin.

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

end of thread, other threads:[~2018-05-22 22:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-22 17:41 [PATCH] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests Thierry Escande
2018-05-22 22:01 ` Tobin C . Harding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).