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=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 6BE3CC49ED7 for ; Fri, 20 Sep 2019 20:03:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 450C120B7C for ; Fri, 20 Sep 2019 20:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569009796; bh=cMTjA/yz9KqqtUL/Mg2YNEN3nC9rBQU0G3Obqo8Nyo0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=VIVWDz95+hOBoRxnBOurLbxQrH4IM7+9ZCnWrXLwt0Hnc0SzwEDWDEWXz4PYNnzrI xY3Hlbpuoqwxda16OYm+31uTfYU+siGbGZuK/eC1ST9nNsHIizM0mZxaI2WWmyTHsX NGs6d5a3HAdopAAgLAfEAjXqfrTxcyJ/P3io3liY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728115AbfITUDM (ORCPT ); Fri, 20 Sep 2019 16:03:12 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36006 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728030AbfITUDM (ORCPT ); Fri, 20 Sep 2019 16:03:12 -0400 Received: by mail-lf1-f65.google.com with SMTP id x80so5885494lff.3 for ; Fri, 20 Sep 2019 13:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xvN2KQ56pBfopzR5NTpYWY+sY/vGc2/ameqmoybjDrQ=; b=dbuf/UXMHUar0osYBkFIQLOqXGRKAzunASOSjlxczJdJuAuv4EIQO4TdZW9FHxFdWP zRF0YsUx7Sl6hzcNZi0n4fx86g1PGjtpEfrdSTJgBzcGXrJX21Rn+bMPXKMJW/vYWOUs +yabpjBBNhCzra1YefBk5LzoO/V8kzRBZ0CEw= 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=xvN2KQ56pBfopzR5NTpYWY+sY/vGc2/ameqmoybjDrQ=; b=BRrokNXIxX5WlxKf5CqPnDjRMvyNWuxzzv1Su2KdfbY3IgH6nhN0VOBg15SsdQ+Yyw UFSlPhKRT4lZub97L7cNRzlLqJ4AYrBwrfmX8p92Rgzfqu+VrCT4827V7VzN4HmUh5YN G4CzFXhPHxPxBkzFXsYx7qjiPfpsCUn4jfAnakN6F1A+upEb5gejc7BwhZqlwwx/DuYW xNN7j7fOiU9Rwa+l/YbX0zqwldr412Er2FMDE1Wuy9CZY6RjaRfy+rHchCNyq0txi3Cz HfhljjcvMQJpJfTQ9NbrEjukHGzpael6AgC8/0SFmGDhhLRQW8d7oANTxQ9bfvv5qYyQ b/AA== X-Gm-Message-State: APjAAAW6ALpFIiHhXNn5zVmeHW1UHUcI4DSsCeucrGVyIQtHwIKnn4xw YVSrdIcyusWR5z/0vjfrVgYOWyOxNl0= X-Google-Smtp-Source: APXvYqyvGB+P199VVvhVyeRgrYtwzGRb8rhcCYXgN1XrNDxU33mzOFF29Q0YwGMr60km9utqlRSAow== X-Received: by 2002:a19:e204:: with SMTP id z4mr9609714lfg.157.1569009789674; Fri, 20 Sep 2019 13:03:09 -0700 (PDT) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com. [209.85.167.45]) by smtp.gmail.com with ESMTPSA id j84sm694416ljb.91.2019.09.20.13.03.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Sep 2019 13:03:07 -0700 (PDT) Received: by mail-lf1-f45.google.com with SMTP id u3so5854085lfl.10 for ; Fri, 20 Sep 2019 13:03:06 -0700 (PDT) X-Received: by 2002:a19:f204:: with SMTP id q4mr9514305lfh.29.1569009786273; Fri, 20 Sep 2019 13:03:06 -0700 (PDT) MIME-Version: 1.0 References: <008f17bc-102b-e762-a17c-e2766d48f515@gmail.com> <20190915052242.GG19710@mit.edu> <20190918211503.GA1808@darwi-home-pc> <20190918211713.GA2225@darwi-home-pc> <20190920134609.GA2113@pc> <20190920181216.GA1889@1wt.eu> In-Reply-To: From: Linus Torvalds Date: Fri, 20 Sep 2019 13:02:50 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC v4 1/1] random: WARN on large getrandom() waits and introduce getrandom2() To: Andy Lutomirski Cc: Willy Tarreau , "Ahmed S. Darwish" , Lennart Poettering , "Theodore Y. Ts'o" , "Eric W. Biederman" , "Alexander E. Patrakov" , Michael Kerrisk , Matthew Garrett , lkml , Ext4 Developers List , Linux API , linux-man Content-Type: text/plain; charset="UTF-8" Sender: linux-man-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-man@vger.kernel.org On Fri, Sep 20, 2019 at 12:22 PM Andy Lutomirski wrote: > > Here are some possible approaches that come to mind: > > int count; > while (crng isn't inited) { > msleep(1); > } > > and modify add_timer_randomness() to at least credit a tiny bit to > crng_init_cnt. I'd love that, but we don't actually call add_timer_randomness() for timers. Yeah, the name is misleading. What the "timer" in add_timer_randomness() means is that we look at the timing between calls. And we may actually have (long ago) called it for timer interrupts. But we don't any more. The only actual users of add_timer_randomness() is add_input_randomness() and add_disk_randomness(). And it turns out that even disk IO doesn't really call add_disk_randomness(), so the only _real_ user is that keyboard input thing. Which means that unless you sit at the machine and type things in, add_timer_randomness() _never_ gets called. No, the real source of entropy right now is add_interrupt_randomness(), which is called for all device interrupts. But note the "device interrupts" part. Not the timer interrupt. That's special, and has its own low-level architecture rules. So only the normal IO interrupts (like disk/network/etc). So timers right now do not add _anything_ to the randomness pool. Not noise, not entropy. But yes, what you can do is a jitter entropy thing, which basically does what you suggest, except instead of "msleep(1)" it does something like while (crng isn't inited) { sched_yield(); do_a_round_of_memory_accesses_etc(); add_cycle_counter_entropy(); } and with a lot of handwaving you'll convince a certain amount of people that yes, the timing of the above is unpredictable enough that the entropy you add is real. Linus