Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1689263ybb; Sun, 29 Mar 2020 10:56:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs85QTfKDZaiHqQTukMqjsPAr7Dl9RWkEGtAjsEyepebDmQEwq/lhhrMsI5J+ecYl1IvzD/ X-Received: by 2002:a05:6830:22d1:: with SMTP id q17mr6709068otc.194.1585504618471; Sun, 29 Mar 2020 10:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585504618; cv=none; d=google.com; s=arc-20160816; b=R81JlPC5eTsF2ATYHO8eHkbJQk6HjFyOaNK1UCG4eEhy7xviakyoEAzX6Cg/9bdnod 1BUuBFWwSO59pKBPLG2WaD7YT+2d9JG7Z/CT11Z5TYttiyTKqsYM+o9UEy3SCbrlwgtL x2ULQjbxRMle2Z1HpVWUTsgDYwLDuuM1w5yLjejugrHV3ENZ/U8VsRcojZPLchipXPSc IF38+wDktyalH+1JiY3lEsy9SaldJndbu9vDKfFfe2d88Zsc8Y3WbZRKIWKE9Z0XiBIy y+mjUaLeLiUQZupbrfy+pnOMhNlw7pTCDoD58urZ9pk3eo3gxY8eblcH1g834xMCTmNE 3EmA== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gMowoXZkXa+cTP3+C2hbc9oV3fdVIun2OWShC4Ek0Dg=; b=IlSd6CYj6b0bmfmMWv6b1gI9qNU+MfMkpg2DIkMEU0lSyRi8kLZfgEf94h8o+nsLtX l75PTRYf46DuBukiIuSooD96so5vMZcDZnwYnfoAdWuNcRhTHqg08QjB5pho8xQ5vnwL sX8H44jYGs9B21x3CjQuTtWi6/8TyUf+48LshnLlRdloAAIH3sJYPYEkXpbHhMSWOnXf pDnAetKyQ1nUWGZUjcObwkARhl7rg6oenImNlw2RcVPIl2MorX4pg5roCQT2DTEZDRZ5 kftAx456e+YdyD3Q1v5/PNMgGWZGomQoCVaMP9i3fS5pl7IgLxO1ikQXADCvIywsPY1S BA/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x23si2002650ote.264.2020.03.29.10.56.32; Sun, 29 Mar 2020 10:56:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728310AbgC2RqM (ORCPT + 99 others); Sun, 29 Mar 2020 13:46:12 -0400 Received: from mx.sdf.org ([205.166.94.20]:56177 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728065AbgC2RqM (ORCPT ); Sun, 29 Mar 2020 13:46:12 -0400 Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 02THfOue005744 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Sun, 29 Mar 2020 17:41:25 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02THfMtT011769; Sun, 29 Mar 2020 17:41:22 GMT Date: Sun, 29 Mar 2020 17:41:22 +0000 From: George Spelvin To: David Laight Cc: Dan Williams , Linux Kernel Mailing List , Qian Cai , Kees Cook , Michal Hocko , Andrew Morton , Linux MM , lkml@sdf.org Subject: Re: [RFC PATCH v1 00/52] Audit kernel random number use Message-ID: <20200329174122.GD4675@SDF.ORG> References: <202003281643.02SGhPmY017434@sdf.org> <20200328182817.GE5859@SDF.ORG> <98bd30f23b374ccbb61dd46125dc9669@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98bd30f23b374ccbb61dd46125dc9669@AcuMS.aculab.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 29, 2020 at 12:21:46PM +0000, David Laight wrote: >From: George Spelvin >> Sent: 28 March 2020 18:28 >... >> 20..23: Changes to the prandom_u32() generator itself. Including >> switching to a stronger & faster PRNG. > > Does this remove the code that used 'xor' to combine the output > of (about) 5 LFSR? > Or is that somewhere else? > I didn't spot it in the patches - so it might already have gone. Yes, Patch #21 ("lib/random32.c: Change to SFC32 PRNG") changes out the generator. I kept the same 128-bit (per CPU) state size. The previous degree-113 LFSR was okay, but not great. (It was factored into degree-31, -29, -28 and -25 components, so there were four subgenerators.) (If people are willing to spend the additional state size on 64-bit machines, there are lots of good 64-bit generators with 256 bits of state. Just remember that we have one state per possible CPU, so that's a jump from 2KB to 4KB with the default NR_CPUS = 64.) > Using xor was particularly stupid. > The whole generator was then linear and trivially reversable. > Just using addition would have made it much stronger. I considered changing it to addition (actually, add pairs and XOR the sums), but that would break its self-test. And once I'd done that, there are much better possibilities. Actually, addition doesn't make it *much* stronger. To start with, addition and xor are the same thing at the lsbit, so observing 113 lsbits gives you a linear decoding problem.