Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1560452pxk; Tue, 1 Sep 2020 01:36:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNhNz1/+0ZWN/YbZoJX+inNpe8dOZiYD1dKTbrLnb/rRU6mHInSTw0X8WE57lj5EZDn9rf X-Received: by 2002:aa7:c693:: with SMTP id n19mr820883edq.101.1598949365936; Tue, 01 Sep 2020 01:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598949365; cv=none; d=google.com; s=arc-20160816; b=dthVZSYYTOkbupZaa9InOwbsg1A/5c4fbxdwuyAdzuLs0vKMvqsuNXnIpDxF2FbVPl bzjzdjhnMppgD8JAs+sa3cnqQlflRtZIYQict+ULkUuA22EhMBUgiOKKvG9XaaerXKYD 6pPrDTSRBLFQ0AIcqlcK5NncJNMlKITaoZPx0dWQMjHFK+5Il56u4bu/iWHXAmmvwxSg LXgK2RiuJ1KRVPhrHPAhqV0/JHS9FtzspxvWy0RBzRTIxquHOX5pKR/pS8mIFGS2Ox3M 9C/m0zo7X6Pj/LfXWIE0UOol/EOWYFDj0QHm10TY6WUB3Jm+jmNIf/ujrAUt5U9lQX58 c3Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=G+VmgoO8vIbvtjcVYz620lwA/qI81jwMNO0XxxHQoX0=; b=FWHVeLxknpPkA8mzIHhFx8Iykke0RJSU1Y38lnXt0kOzp22PN7a65ooaeTcE1B2wyX U6Z1i4584S6YbJMfWrJfVN9xb7G9ffr1KSIeRKYLE49OATr58qQUKt3J2yRc/1VYatM0 wWKbc51p4RZCyizEg1SbAWANkLaGm9Ke/qXiA7bdASbBX2i2z4+R893engkSvlgeIDnP B1w+nUlt+GI4qq48S2iv+aWJIelXezaQRpwW5/KplDowwwjwVisIv8Vt/u8Bf1aD4DQA m1oq4bOcfiBlUKDrYlstfFgY3E5tlp9eAMDjibzGnS+ls9kj+X2mOj1cnY0HiKRrpoNu SEzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZTSIDzuA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k16si267090ejd.738.2020.09.01.01.35.42; Tue, 01 Sep 2020 01:36:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZTSIDzuA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727049AbgIAId6 (ORCPT + 99 others); Tue, 1 Sep 2020 04:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbgIAIdw (ORCPT ); Tue, 1 Sep 2020 04:33:52 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DA72C061244; Tue, 1 Sep 2020 01:33:52 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id u126so335020iod.12; Tue, 01 Sep 2020 01:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G+VmgoO8vIbvtjcVYz620lwA/qI81jwMNO0XxxHQoX0=; b=ZTSIDzuANrxX4hUFOaMXVu7wF4/c558yhxyDvVPjauI/aUI0aZ7PNHCbAtaiPdXbRS EVRU8kkXPTFlac7Y8blhAe9S/x8T+bxGMNP/CGrXLC31/XltqecIWpZxVJd7LULbT6HB u0zNpKC591mnmMRMa7OanZFVidpYmnc8Lo/QhwmVeKANEKLJ8lbDkSC5LBUK0/nsdmRZ lWQlv3wu0Y4Ji19zZlctiAP0YdMD+AvKrYsTY/iInQQ9bHcy9T8l4Na0rR1+KIr5n6de mAJGjhsPTS6FN9n2Jpvz4YbOUlMTybwKUD6H+qGGRyTuA3CE+0mse/UYzfEd0xNYXnCF MHYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G+VmgoO8vIbvtjcVYz620lwA/qI81jwMNO0XxxHQoX0=; b=dAPHgQWjhl+XgozpnzjjdhyKqBO1JoozRXbPuhyOHz/XywUwXfLlAzbdxGvqy29pJe /MUQmQTdzz1Fe5rig9n/r60h6KJrbJGFP3UtVFD2zHFp/HCUF8/0GJlb1mI24+Bs3YzR lpgWWQ7CGedmuKrm7YGZOe9GhpDULpprbnO+56KgMsPKKEVzQ631KPZ1ka1LqU95aBok J1maA/6as/EbMs3CPhonS/cIq48ktXZtMe+YaKaoPBPsYKYgNgCHluWOsZCKl+o1db+9 tuecDdJjOUJLUcm9NjI+ZDUUCs7S+0ESWWU1hKstMYDaetqpFMUF7h+M9+1wct+J07Nt U9tA== X-Gm-Message-State: AOAM533QWBQnKNpFClEhjvPwfwaH3znKUz85/iizsVl8HxOdvJPyqcKg PYpk9UOdgnBbLPVqzaQMABGM+WUYIVW+aw/xDUU= X-Received: by 2002:a05:6638:2653:: with SMTP id n19mr384136jat.34.1598949231460; Tue, 01 Sep 2020 01:33:51 -0700 (PDT) MIME-Version: 1.0 References: <20200901064302.849-1-w@1wt.eu> <20200901064302.849-2-w@1wt.eu> In-Reply-To: <20200901064302.849-2-w@1wt.eu> From: Yann Ylavic Date: Tue, 1 Sep 2020 10:33:40 +0200 Message-ID: Subject: Re: [PATCH 1/2] random32: make prandom_u32() output unpredictable To: Willy Tarreau Cc: linux-kernel@vger.kernel.org, Linux Kernel Network Developers , Sedat Dilek , George Spelvin , Amit Klein , Eric Dumazet , "Jason A. Donenfeld" , Andy Lutomirski , Kees Cook , Thomas Gleixner , Peter Zijlstra , Linus Torvalds , tytso@mit.edu, Florian Westphal , Marc Plumb Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 1, 2020 at 8:45 AM Willy Tarreau wrote: > > +/* > + * Generate some initially weak seeding values to allow > + * the prandom_u32() engine to be started. > + */ > +static int __init prandom_init_early(void) > +{ > + int i; > + unsigned long v0, v1, v2, v3; > + > + if (!arch_get_random_long(&v0)) > + v0 = jiffies; > + if (!arch_get_random_long(&v1)) > + v0 = random_get_entropy(); Shouldn't the above be: v1 = random_get_entropy(); ? > + v2 = v0 ^ PRND_K0; > + v3 = v1 ^ PRND_K1; > + > + for_each_possible_cpu(i) { > + struct siprand_state *state; > + > + v3 ^= i; > + PRND_SIPROUND(v0, v1, v2, v3); > + PRND_SIPROUND(v0, v1, v2, v3); > + v0 ^= i; > + > + state = per_cpu_ptr(&net_rand_state, i); > + state->v0 = v0; state->v1 = v1; > + state->v2 = v2; state->v3 = v3; > + } > + > + return 0; > +} > +core_initcall(prandom_init_early); Regards; Yann.