Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2529046imm; Thu, 7 Jun 2018 12:10:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIbyhnOo1mJsdaLIcWK2eLKhB0IgafEmIsTbMGdyMbck8xpOr/zFIFrvoo0nvKPpkeSKCuB X-Received: by 2002:a63:8c4f:: with SMTP id q15-v6mr2659094pgn.236.1528398655294; Thu, 07 Jun 2018 12:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528398655; cv=none; d=google.com; s=arc-20160816; b=DAuclK2I/1PbtKabvivaaXOIiSUNHWuK1cI4Nt+RFDTmiiEEY3NFY2dYtEWhpQiB6z 5uebZ1mWGg/L4BYx/PUqQvDnhqacTObT9N/b78F/Lo+K0ZKwc7ROZqvE3tVhjYQAyDcE QeMqtdYMZE4yn7BxQ2RTfUThHyq46K1s4ilFECraSideuWmoTx+J8oL+N0YnF43r4slC e0EQHvR7i6sARikNjEqIrGjhfru//Bzv2XkMiD4KtOoTs9j/k8a9wfneAuvq18RO021K zeoePQ5VivvLTACmhxxcNiFP7kbkfYumW+2tant3qLoSmrdmP54YBLHNygGemKGUEbSI aQAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=jq3fo19f6padLIIBgXrSmLayZed11pR10Zz/YBUntHE=; b=sUkyodD+hS7aKqF1SFLVUgitjBxcX2uj7ToQAZlu1oad5V2Dou50oECK/LFHt/Bjjm C800HgkYGjTz8myvjO2Zk7jSXDUmGWpbULYxOBGfv/HDWKrnj1aPYx9izfZuplzTgn0N GpSxmi8HsSUb6+EwnAa1xm51bC78MygO1YU/HE+glukgRLjglvs556Ote1VO35bDUzPW s7fJUd6lWGGK+BFoDMBhWcYDGZxemb/CKNJxtY/doitEKo6kZSyCbYBz9Li5JG0HECcn OrQjMCS+dwmyl7SAZkZ/PSmofhcvq4tqRgFFC9kUXjOukI/6HQNF3BgNAS8lgMgOvMjX rCWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FRbWhDm+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64-v6si38870226plk.33.2018.06.07.12.10.41; Thu, 07 Jun 2018 12:10:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FRbWhDm+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932219AbeFGSra (ORCPT + 99 others); Thu, 7 Jun 2018 14:47:30 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:38094 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169AbeFGSr3 (ORCPT ); Thu, 7 Jun 2018 14:47:29 -0400 Received: by mail-wr0-f194.google.com with SMTP id e18-v6so2626015wrs.5 for ; Thu, 07 Jun 2018 11:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jq3fo19f6padLIIBgXrSmLayZed11pR10Zz/YBUntHE=; b=FRbWhDm+pQcfuJmLXtoO3ZCus4wRNQ1gYQF4DigY4rhnrGG8PcXsxwI2yWtnmXJqr0 Vhca/OGOk5az6fgfLB/4P/ELFpIDFMF0beL17XZqdFC0gBIj6sCCB5qjwiCoOqNt0NFd ppySwaC0OLzHZPOOhbNE7inaBH/KR3YIHZN7s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jq3fo19f6padLIIBgXrSmLayZed11pR10Zz/YBUntHE=; b=a97FMjLMdq9zHUgTBcE9kdoMSd22DQP6KPVsG6/hpEmihY5Tiy1t4Lb6Li5bjQP1U/ fJJBbImPLQSQSftnGG46Rb9Fd38XtbeEJjdUyBLdcA/DKgCPaYsRRTbxXyOT1mz/NYuD dDKzXbWbVD93NY4K3C4MCOOA1de0hRBXvpaK2AELRPx6fMPRkeCyPbGNEnsHsYeIpqUg c+ZKZAZZXVSGmPwDnhalBaJ/1ZhBArleWoos2acrD7LQ+rZS4p44isu0xTUfXFjjEZ6N HbVxND6HLWpGBKbezjg+ftJImXpaTukxjo9r6ruIKfpQkNlsQzyDiXszEBbsY/Uxa4ah IsNg== X-Gm-Message-State: APt69E37uvhpynAXUwH68zJDgWJM3S/W1nTPQVw09C2O8qEhVxyXQiPC TIoM8D9Fyfthr+gvj9W0zpKJWA== X-Received: by 2002:adf:9341:: with SMTP id 59-v6mr2497149wro.80.1528397247901; Thu, 07 Jun 2018 11:47:27 -0700 (PDT) Received: from [192.168.1.100] (aig34-1-88-167-228-121.fbx.proxad.net. [88.167.228.121]) by smtp.gmail.com with ESMTPSA id p6-v6sm24210331wrq.19.2018.06.07.11.47.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 11:47:27 -0700 (PDT) Subject: Re: [PATCH RESEND] lib/test_printf.c: call wait_for_random_bytes() before plain %p tests To: Petr Mladek Cc: Andrew Morton , David Miller , Rasmus Villemoes , "Tobin C . Harding" , linux-kernel@vger.kernel.org, Andy Shevchenko References: <20180604113708.11554-1-thierry.escande@linaro.org> <20180607122434.i4x7b5ij4p6dpx7w@pathway.suse.cz> From: Thierry Escande Message-ID: Date: Thu, 7 Jun 2018 20:47:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180607122434.i4x7b5ij4p6dpx7w@pathway.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> Acked-by: Tobin C. Harding >> --- >> 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 >>