Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8345690ybn; Tue, 1 Oct 2019 06:55:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoito76wbjlhGgqH5HS6vm0VKiX9edmsqWaZge3ny3Z2iJEv4jaNsWwfmjN8K8Hxm1YvOx X-Received: by 2002:a05:6402:6c6:: with SMTP id n6mr24988036edy.162.1569938136074; Tue, 01 Oct 2019 06:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569938136; cv=none; d=google.com; s=arc-20160816; b=bkxjjB6eC+bhVKostBHfFabvm/WzWLVkwwmme+Lk9ASzWvjNX60KZBrb7W+lmThzbE xGKly+beTMi4yvvva5RnmglnAA7gXo1++gBZ+PxCTRsJXnSEY8lITaTMQkLS2y6SGci0 fsjqeke+v/c5ylZHNywnbpHofpzTX9sL74/XIhvi+yxUy/mMuT1eyfUpMX/fRrcHRsfn 6yDFa/F9pWLljxOSWqmYiB31qji9+LImpnRBKaDTlEz4JLOvkq8xM0XYate8XXH1J7uC FukkRQhSilTeedkY7Y+xPW52+wj407kpUVyxltXnfOLy766GPYbzMuBen9LGF7EW2S5q n5qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=jWF7NUD3UG4zEl0CddlLEO+oeHhhgitXQGaScYypXro=; b=GPSsMlB3n1HXUIXCraONhrbjbnUipbHpi45hjDjUKmOabW/8Z5x2jbFmOPisnrfL19 5StXpkGqXFLhlHb8vveabUKqADkmhkfPkKPOxtEnBLTkvYMBLwsPU+MBXI6l+Ci6jR53 K9mKKEJtzvVXKC2TrH/XWUsaZHsMxZKHZHZ8XbfrORatG9rYVmXzhE8f/hWnwMcUis8H r1mmP+rKXSsgyNBIZDEjWgVDsxgpT06DkeC5uaDlVLkbq9CjY5kr/kB3M3j34JDFcn4E KcGUK58CfMU5zWBl3HS+cWww95or9mED33YoJPtHfb25LtWmjq2TyJq8dO4EGupNke/M Wh/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Pq9uNLT4; 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=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si10473593edx.257.2019.10.01.06.55.11; Tue, 01 Oct 2019 06:55:36 -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=@alien8.de header.s=dkim header.b=Pq9uNLT4; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388790AbfJANvM (ORCPT + 99 others); Tue, 1 Oct 2019 09:51:12 -0400 Received: from mail.skyhub.de ([5.9.137.197]:44560 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388706AbfJANvM (ORCPT ); Tue, 1 Oct 2019 09:51:12 -0400 Received: from zn.tnic (p200300EC2F0A2D0011A0C0FEFCED0EBA.dip0.t-ipconnect.de [IPv6:2003:ec:2f0a:2d00:11a0:c0fe:fced:eba]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id F3C1B1EC03AD; Tue, 1 Oct 2019 15:51:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1569937871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=jWF7NUD3UG4zEl0CddlLEO+oeHhhgitXQGaScYypXro=; b=Pq9uNLT41EO/NKOX2eDfLDuzdhcEz39M+YEQgdg1fmeI29l0IubgvVStdbhcu/mNNKlLBq dOpiCIO5r8s+33d+fdYvbSar5pQQEtGzrUlX6Ztf2A91PyB1tSmfbYgSAooSVnNmvuGQ3I CQhu6feHC9g9szUkRyi0bT4LmnJXKyU= Date: Tue, 1 Oct 2019 15:51:08 +0200 From: Borislav Petkov To: Linus Torvalds Cc: Thomas Gleixner , "Ahmed S. Darwish" , LKML , Theodore Ts'o , Nicholas Mc Guire , the arch/x86 maintainers , Andy Lutomirski , Kees Cook Subject: Re: x86/random: Speculation to the rescue Message-ID: <20191001135108.GD5390@zn.tnic> References: <20190930061014.GC29694@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 30, 2019 at 09:06:36AM -0700, Linus Torvalds wrote: > Obviously, that can be a problem if you then need sshd in order to get > into a headless box, so my patch fixes things for you too, but at > least your box doesn't show the problem that Ahmed had, and the boot > completing presumably means that you got more entropy from other disk > IO being done by the rest of the boot. Right, another observation I did was that when it would wait for entropy, if I press random keys, it would get done faster because apparently it would collect entropy from the key presses too. > If you want to test my hacky "do /dev/urandom too", it was this one-liner: > > --- a/drivers/char/random.c > +++ b/drivers/char/random.c > @@ -2027,6 +2027,7 @@ urandom_read(struct file *file, char __user > *buf, size_t nbytes, loff_t *ppos) > static int maxwarn = 10; > int ret; > > + if (!crng_ready()) try_to_generate_entropy(); > if (!crng_ready() && maxwarn > 0) { > maxwarn--; > if (__ratelimit(&urandom_warning)) > > and that should get rid of the warnings. So when I add this by hand and do git diff, it adds a second hunk: --- diff --git a/drivers/char/random.c b/drivers/char/random.c index c2f7de9dc543..93bad17bef98 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -2027,6 +2027,7 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) static int maxwarn = 10; int ret; + if (!crng_ready()) try_to_generate_entropy(); if (!crng_ready() && maxwarn > 0) { maxwarn--; if (__ratelimit(&urandom_warning)) @@ -2520,4 +2521,4 @@ void add_bootloader_randomness(const void *buf, unsigned int size) else add_device_randomness(buf, size); } -EXPORT_SYMBOL_GPL(add_bootloader_randomness); \ No newline at end of file +EXPORT_SYMBOL_GPL(add_bootloader_randomness); --- and I kinda get what it is trying to tell me but this is new. And when I do $ xxd drivers/char/random.c .. 000125e0: 646f 6d6e 6573 7329 3b0a domness);. there's a 0xa at the end so what's git really trying to tell me? Anyway, that does get rid of the warns too. > Doing something like the above to /dev/urandom is likely the right > thing to do eventually, but I didn't want to mix up "we can perhaps > improve the urandom situation too" with the basic "let's fix the boot > problem". The urandom behavior change would be a separate thing. So make it a separate patch and let's hammer on it during the next weeks and see what happens? > Also, talking about "future changes". Right now > "try_to_generate_entropy()" is actually uninterruptible once it gets > started. I think we should add a test for signal_pending() too, but it Wouldn't that even increase its entropy, which would be a good thing? > should generally complete really fairly quickly so I left it without > one just to see if anybody even notices. Right. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette