LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thierry Escande <thierry.escande@linaro.org>
To: Petr Mladek <pmladek@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	"Tobin C . Harding" <me@tobin.cc>,
	linux-kernel@vger.kernel.org,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: Re: [PATCH RESEND] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests
Date: Thu, 7 Jun 2018 20:47:25 +0200	[thread overview]
Message-ID: <d9ecdf72-7500-66d4-0360-231218cccbb4@linaro.org> (raw)
In-Reply-To: <20180607122434.i4x7b5ij4p6dpx7w@pathway.suse.cz>

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
> CONFIG_TEST_PRINTF=y
> 
> 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?

Regards,
Thierry

> 
> Best Regards,
> Petr
> 
>> Signed-off-by: Thierry Escande <thierry.escande@linaro.org>
>> Acked-by: Tobin C. Harding <me@tobin.cc>
>> ---
>>   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
>>

  reply	other threads:[~2018-06-07 18:47 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 [this message]
2018-06-08  8:04     ` Petr Mladek
2018-06-08  9:07       ` Thierry Escande
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=d9ecdf72-7500-66d4-0360-231218cccbb4@linaro.org \
    --to=thierry.escande@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=me@tobin.cc \
    --cc=pmladek@suse.com \
    --subject='Re: [PATCH RESEND] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

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