Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8563458ybn; Tue, 1 Oct 2019 09:52:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyI1PyBVJIG0954f2KIp+vPgKpSomgg2YyHbb6F1ZlKTk3RWm0etAQ6SoLpOCt4ZCjehm/c X-Received: by 2002:a17:906:5295:: with SMTP id c21mr15980675ejm.80.1569948735187; Tue, 01 Oct 2019 09:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569948735; cv=none; d=google.com; s=arc-20160816; b=Mn7kjA19tAUJ9YViT5tZj9hUN7LkoPNklwc/zXtqilwPAdg4Ivn2TZRg1tEjrzwlWT 5rXr4iDCGLd9qBtTFFYPH3J6Pn1ci/9CPo7jn4Q/AiA19P9rRIL/neZo87OybvGNmSPS 3/TqCj0DEWHsQK9l2IwtC9VZFB2AdPbzvWotTnp7ZoUlooFsKDsXgB4ShycsQw7QSwyy p0Gg4VJT3yd4k6tUZjpd3tFLzbdzI+rjf2tCSElEV/jvjjK962u3hel68WWSKaZXMas1 7/HR813Kxj6JQ16LFOEzMvF1DF/Xy0yOdg9qvsLKIX/Ad4xLqyAD6r9kcWVoiNh5e+Rg jQrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nRBqIlLhM8ZUJgatnzPvhuMc606HDrYYNudVlJiQtTo=; b=Y2r9Tg8Ipq0LJiMXy7Jo1bi4yC4fzEM3Kt5xjzlvTvRy55S4QMOQCwm/XVPfOM95dC yLzEyuX1ua8BL4GlFWTGKlmwaPyt70mUBfv80sxFxL5Dhd5cWSHLWvA8+qQkdFYLuPYA /E59W5nnEskLBlWIyPR3vPyK0TAtbx1rUKphRF9UBSgOHUSL7CDaOFYfcCOmq4E4slTd VljA/H2snZw5jqMGWZ0/w4usRH7mw77kdSXnIp2JgPfSCjttxsJd4iAdKqJTH+jfFlKg DfcznIXHhbu2rgCaUg/KXwB+dQtvh/19J0hT7TvbsR4jtHg24fKDPZ7UvflMw4dVrBX5 PP5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QOdvq3F7; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si9064466ejf.28.2019.10.01.09.51.50; Tue, 01 Oct 2019 09:52:15 -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=@chromium.org header.s=google header.b=QOdvq3F7; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727523AbfJAQhm (ORCPT + 99 others); Tue, 1 Oct 2019 12:37:42 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42533 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbfJAQhm (ORCPT ); Tue, 1 Oct 2019 12:37:42 -0400 Received: by mail-pg1-f193.google.com with SMTP id z12so10006079pgp.9 for ; Tue, 01 Oct 2019 09:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=nRBqIlLhM8ZUJgatnzPvhuMc606HDrYYNudVlJiQtTo=; b=QOdvq3F7RPeoeqsDbhWOOUVxzHnf6D2wVftkdGGj7lbk6tdr5FAZLxzC65bB/Ovnni UeOttAleJyJ/kz4TXsHzrARBIN7Cuapykt9NtyGO6IEU7eUPKwURc6F3iEM98ehRUZS9 GXYsHtFIAT7VlERhrlt3NiNiGb1M0OiN+tV/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=nRBqIlLhM8ZUJgatnzPvhuMc606HDrYYNudVlJiQtTo=; b=d9217rZGXyNKNZl+EBlWxKMGSkZgHsBpQjQGm1zOpek5fAp2B7vOIyU2YejDaQCMq6 mfEpYRMJxMAPgZ/gnLV44tzB259I/cMoW/0M5T02K2lgg7gvfyWNr8WX4+l/K8em7p2v 3MQeYymPYU7BsMORu39E4BHojxjzec4+2ftxMayy6RKtY5xVu4wkEmPXO55qasoYvABQ 2O5pZm87bPastqo3z58DUKzdmbZ5+uql/d6d4e3HWRj4S/w/Ji4aFMV5O3Vef5hymv+h rrCgAzDOO7z+mhmOcLb/sst46e+hTK5gB/fNHTwMXJXPD8hQQSOOUL5y/S8H91bRwin+ CK9w== X-Gm-Message-State: APjAAAUBjSdh5qqDMIcscQavB8zwouNY63M+g9EYcHXiAmaLFpYCSDbm dPRwaMMbSe/MBknntKFpdVfZ0Q== X-Received: by 2002:a17:90a:bb8e:: with SMTP id v14mr6323823pjr.84.1569947861914; Tue, 01 Oct 2019 09:37:41 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q20sm19504378pfl.79.2019.10.01.09.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 09:37:41 -0700 (PDT) Date: Tue, 1 Oct 2019 09:37:39 -0700 From: Kees Cook To: "Ahmed S. Darwish" Cc: Linus Torvalds , Thomas Gleixner , a.darwish@linutronix.de, LKML , Theodore Ts'o , Nicholas Mc Guire , the arch/x86 maintainers , Andy Lutomirski Subject: Re: x86/random: Speculation to the rescue Message-ID: <201910010932.C6DF862@keescook> References: <20191001161448.GA1918@darwi-home-pc> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191001161448.GA1918@darwi-home-pc> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 01, 2019 at 06:15:02PM +0200, Ahmed S. Darwish wrote: > On Sat, Sep 28, 2019 at 04:53:52PM -0700, Linus Torvalds wrote: > > Ahmed - would you be willing to test this on your problem case (with > > the ext4 optimization re-enabled, of course)? > > > > So I pulled the patch and the revert of the ext4 revert as they're all > now merged in master. It of course made the problem go away... > > To test the quality of the new jitter code, I added a small patch on > top to disable all other sources of randomness except the new jitter > entropy code, [1] and made quick tests on the quality of getrandom(0). > > Using the "ent" tool, [2] also used to test randomness in the Stephen > M?ller LRNG paper, on a 500000-byte file, produced the following > results: > > $ ent rand-file > > Entropy = 7.999625 bits per byte. > > Optimum compression would reduce the size of this 500000 byte file > by 0 percent. > > Chi square distribution for 500000 samples is 259.43, and randomly > would exceed this value 41.11 percent of the times. > > Arithmetic mean value of data bytes is 127.4085 (127.5 = random). > > Monte Carlo value for Pi is 3.148476594 (error 0.22 percent). > > Serial correlation coefficient is 0.001740 (totally uncorrelated = 0.0). > > As can be seen above, everything looks random, and almost all of the > statistical randomness tests matched the same kernel without the > "jitter + schedule()" patch added (after getting it un-stuck). Can you post the patch for [1]? Another test we should do is the multi-boot test. Testing the stream (with ent, or with my dieharder run) is mainly testing the RNG algo. I'd like to see if the first 8 bytes out of the kernel RNG change between multiple boots of the same system. e.g. read the first 8 bytes, for each of 100000 boots, and feed THAT byte "stream" into ent... -- Kees Cook