LKML Archive on
help / color / mirror / Atom feed
From: Thierry Escande <>
To: Petr Mladek <>
Cc: Andrew Morton <>,
	David Miller <>,
	Rasmus Villemoes <>,
	"Tobin C . Harding" <>,,
	Andy Shevchenko <>
Subject: Re: [PATCH RESEND] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests
Date: Fri, 8 Jun 2018 11:07:11 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 08/06/2018 10:04, Petr Mladek wrote:
> On Thu 2018-06-07 20:47:25, Thierry Escande wrote:
>> Hi Petr,
>> On 07/06/2018 14:24, Petr Mladek wrote:
>>> On Mon 2018-06-04 13:37:08, 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.
>>> Hmm, my system did not boot with this patch and
>>> I guess that there was not enough entropy. It is basically a deadlock.
>>> The build-in module init calls are called when SMP is enabled but
>>> there is no real activity and the init calls are called sequentially.
>>> Therefore there is nothing that could produce some entropy, ...
>>> I suggest to skip the test when crng is not ready.
>> Thanks for pointing this out.
>> The issue is that the crng_ready() is not available outside of random.c.
>> I'll leave the call to wait_for_random_bytes() if test_printf is compiled as
>> a module and use add_random_ready_callback() to check if crng is initialized
>> otherwise. Does that sound ok to you?
> Great, I was not aware of add_random_ready_callback().
> I suggest to make the decision in test_printf_init()
> and run all tests either as the callback or immediately.

The script relies on the error code returned by 
modprobe to check if the test is passed or not. So the init function has 
to return the test results and we cannot defer the test execution in the 
random ready callback if the crng is not yet initialized at __init.

My idea was to use add_random_ready_callback() as a non blocking test 
when compiled built-in as it returns -EALREADY if crng is already 

But as I type I realize it's not necessary. I will simply enclose the 
call to wait_for_random_bytes() by #if IS_MODULE() #endif so it gets 
called only if built as a module, which is how wants 
it... If test_printf is compiled built-in and the crng is not yet 
initialized the test will fail anyway so there is no need to add an 
extra check.


  reply	other threads:[~2018-06-08  9:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04 11:37 Thierry Escande
2018-06-05 12:43 ` Andy Shevchenko
2018-06-07 12:24 ` Petr Mladek
2018-06-07 18:47   ` Thierry Escande
2018-06-08  8:04     ` Petr Mladek
2018-06-08  9:07       ` Thierry Escande [this message]
2018-06-08  9:46         ` Andy Shevchenko
2018-06-08 10:32           ` Thierry Escande
2018-06-08 11:22             ` Petr Mladek
2018-06-08 11:28               ` Thierry Escande
2018-06-22 20:53   ` Steven Rostedt
2018-06-22 21:50     ` Thierry Escande
2018-06-25  7:50       ` Petr Mladek
2018-06-25 12:04         ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH RESEND] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).