From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C36DFC43381 for ; Tue, 26 Mar 2019 18:04:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8949C2075C for ; Tue, 26 Mar 2019 18:04:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=stressinduktion.org header.i=@stressinduktion.org header.b="F/u0P6zY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="0nfy7XlL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732407AbfCZSD7 (ORCPT ); Tue, 26 Mar 2019 14:03:59 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:48295 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731940AbfCZSD6 (ORCPT ); Tue, 26 Mar 2019 14:03:58 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id A796C373A; Tue, 26 Mar 2019 14:03:56 -0400 (EDT) Received: from imap2 ([10.202.2.52]) by compute7.internal (MEProxy); Tue, 26 Mar 2019 14:03:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= stressinduktion.org; h=mime-version:message-id:in-reply-to :references:date:from:to:cc:subject:content-type; s=fm3; bh=uEoz D5CUhqDILbTVTl4ehQdcdAaAiB+t8JJSowtRISY=; b=F/u0P6zYK8BPZINE5cXM L2B6hH8dhO9+LKUk0UCLI4tKSsqk9A0NynIKN2bCu6FpqfP7m1/PlKyMUmzLqrDp CWXd5a8EGJuy3DWiOImLeJqm9I5Vips7bTgU3t/q9OEFYTnPK5DKwts3x5UEU/9/ rfwbYqTl1o7314mA87RGKJgpJgFllGBjlvcPv5/WYYpSN+1obGnR7UPwE23p/hBZ 1Ho9317667Fn7ZMnJDQz2QoU3AKfuLIFpk2/MPdm92g/yoaMpEiQvL5F9lt4Xv6Q k9crdKfSF61/cJ+NqJF1pN7oc+XR928ktxpDg1zV4sEGVeYRpddtfbyd5CR63EGv Ng== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=uEozD5 CUhqDILbTVTl4ehQdcdAaAiB+t8JJSowtRISY=; b=0nfy7XlL4dsMiMfQ2Vaosj XpZEwUbYCgVqPHVA30VY4Ly058fgaOHawTHK0jjx08HtjnkEgTzbPPfvP7N24Hme Q5BaG2xQxPrhHDo8Jv1qzpckj+WNP7NNZotMT7l0kf0YKBkIyySphg9kY8ppdyXR HPRdOLY6BNIhfBWlYxUFdpuU8q54w+KqzfiTCFWxeWrFNoRwO/YKLW8fNknNCpTG 2h77qM+bPYqyZVt8awNLLGrlxukVHKL3EcroiEwHOJZy/3a5qFRymuzVOsU+BO1H 6R8YJwC2r3g3nu5XK3oEDqnVPR0d1+VOk+AmTRml//175YNTC7wcaGhQgm/ifpqg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrkedtgdelhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfjfgrnhhn vghsucfhrhgvuggvrhhitgcuufhofigrfdcuoehhrghnnhgvshesshhtrhgvshhsihhnug hukhhtihhonhdrohhrgheqnecurfgrrhgrmhepmhgrihhlfhhrohhmpehhrghnnhgvshes shhtrhgvshhsihhnughukhhtihhonhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id DA15F7C4D0; Tue, 26 Mar 2019 14:03:55 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.5-976-g376b1f3-fmstable-20190314v3 Mime-Version: 1.0 X-Me-Personality: 20898249 Message-Id: <109c67e3-7cda-40cf-80e1-a2d3500a2b5d@www.fastmail.com> In-Reply-To: <201903261117.x2QBHTnl002697@sdf.org> References: <201903261110.x2QBAFmp001613@sdf.org> <201903261117.x2QBHTnl002697@sdf.org> Date: Tue, 26 Mar 2019 14:03:55 -0400 From: "Hannes Frederic Sowa" To: "George Spelvin" , "Daniel Borkmann" Cc: netdev@vger.kernel.org Subject: Re: Revising prandom_32 generator Content-Type: text/plain Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi, On Tue, Mar 26, 2019, at 12:10, George Spelvin wrote: > I started on a project to correct all of the instances of > "prandom_u32() % FOO" in the kernel (there are lots) > to "prandom_u32_max(FOO)". The conversation definitely makes sense. Are you trying to fix the modulo biases? I think that prandom_u32_max also has bias, would that be worth fixing as well? > [...] > > Thw ones that seem interesting to me are: > - Chris Doty-Humphrey's sfc32. This is a 96-bit chaotic generator > (meaning period *probably* long but not well defined) fed with > a 32-bit counter to ensure a minimum period. It's extremely > fast, and the author is also the author of PractRand, so it's > well-tested. > - Vigna and Bacman's xoshiro128**. This is a 128-bit LFSR with some > output postprocessing. > - (on 64-bit machines) xoroshiro128**, by the same authors. > This is only efficient on 64-bit machines, so it would need > a have a 32-bit backup. > - Bob Jenkins' jsf (originally "flea"). 128 bits, good mixing, > fully chaotic. I prefer the safety of a guaranteed minimum > period, but this is well thought of. > - A lag-3 mutiply-with-carry generator. 2^32 - 1736 is the largest > "safe prime" mutiplier. I think tausworthe is not _trivially_ to predict, what about your proposed algorithms? I think it is a nice to have safety-net in case too much random numbers accidentally leaks (despite reseeding). Thanks, Hannes