Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1792295ybj; Sun, 22 Sep 2019 12:03:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzB+euogS7t/tC4iIEjWAt91kkbtbzdkS1rPHqqBYOXEvlbXZfB14pnihZ7Zi7/jhJLzt+9 X-Received: by 2002:a05:6402:1426:: with SMTP id c6mr34009135edx.53.1569178984663; Sun, 22 Sep 2019 12:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569178984; cv=none; d=google.com; s=arc-20160816; b=uoBYBwPQKSnocikZPRNDCz40XuZYC0wfbgkh9NahhjbokzLhGppuC8j8dRv6/vCI1Q bFV50zmq+4W0eg+bUhE2kw9ECpHGMgLNU9GVpsFV8l8ULvKf/A6creU+0rJNl6S9Lujs QFi+axXo7Gx75J4UVdOmFjBWT2L6NARGNt58iKIO6AH94D4FqxWmtYt2eSYaTywDEDd0 7qYv3YdCWDedDokbBKWZabLPokuxuMIEFR5AFucfzBoH3GR8bp6WjExwAB0kE1VCJD4g gv7n3Ihl15PfZLsUo5045hBnFRDJyvtEXYQrJfEg4aTdbG9TZXA7x539Q/KCTZO+zVgk OPpw== 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=xvN2KQ56pBfopzR5NTpYWY+sY/vGc2/ameqmoybjDrQ=; b=lZaoeFvssqCiPKP2anH2gV8UNBAbOKxnpy9J5xrRFHm29dZRI+pGM4UKWRX3cIpSUZ bLTS/2skh6dyowttrpPs1/Q6TtCpqudHVqXVRR5y3UC1cKeVvremPy/gWqtqcI2U1bPe PvmvaNJwHNAeLR5PV0Zth817mcxApDIUzsY339MlfUvAfvkaSYTnHS+8PynREFTLC9ZY UyZRzacsRWe0wKATow94M7QOP6O4D/QM1ka9kA4GJz1Ty4PpoR8rWAfO3ZVXORyMfAD9 2tdKX+DRcnVMB7oPu9MwcWL3WoIg2JkzgAE0tkBPxPvSl+PjTDLhDmymd3eqzRMEXUpz rfZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="dbuf/UXM"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 pv13si4024445ejb.79.2019.09.22.12.02.40; Sun, 22 Sep 2019 12:03:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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=@linux-foundation.org header.s=google header.b="dbuf/UXM"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728109AbfITUDM (ORCPT + 99 others); Fri, 20 Sep 2019 16:03:12 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:38566 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727339AbfITUDM (ORCPT ); Fri, 20 Sep 2019 16:03:12 -0400 Received: by mail-lf1-f66.google.com with SMTP id u28so5872258lfc.5 for ; Fri, 20 Sep 2019 13:03:09 -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=r0eR8Q+h0xa72ii0T0DaP9UPP2TuC3Ft6IMsWk+vl4XeqXiUkp//yp7/XqYJw0Opca DfP2a7ajErNQVYcQA0j53tcUttg8JOU9Ku9VSpBn1dDpDlCFSLjiWfuXOGsK/eV4htT+ pOk9hH6db7nf/CmLDS361/wED5I1joqwB9HBIsSmUzqIfLVs14cWeUrmvPc4d24xSwas C10G6iPN5P72qDgu7D846hSiW0XqiO8B5HnnAMhVAjHQ2pF+V+1SmAfe3Y3iWDyXNFbf mmw2YGpPONveVeV6gS8g+5iER3m4LyJM0kvQWQ1RpLVAWKDYi6BzermbXvsh2jGNQcy5 WfkA== X-Gm-Message-State: APjAAAXYaUpiDzVCwDXVEzuG/EoaeYy8O78cmkuHE8yFym9tKhbHQcrT BBtEhXqg8A0egSjCnyyhkzQwONH1q3s= X-Received: by 2002:a19:beca:: with SMTP id o193mr9952276lff.137.1569009788539; Fri, 20 Sep 2019 13:03:08 -0700 (PDT) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com. [209.85.167.43]) by smtp.gmail.com with ESMTPSA id f6sm684584lfl.78.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-f43.google.com with SMTP id r2so5862326lfn.8 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-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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