Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2549429ybn; Thu, 26 Sep 2019 13:43:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfctgfOl9uaqhpS39pokGcJnLiG6AoYRxSKwoZrKvfQpQAF81UHA4LFDyq8nYB+ITIqZ6u X-Received: by 2002:aa7:d2c4:: with SMTP id k4mr803196edr.169.1569530586377; Thu, 26 Sep 2019 13:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569530586; cv=none; d=google.com; s=arc-20160816; b=cRJPE/3PRgVR9XOzxw62iIQ/nqRgbhCR8GGTQTSePipCUnntdWIOKYl5VFrSPYtghG OBu5gdCDj7NQZ7bxKZHsHIqs5pxb7zDGajJAUZgIAgCwl0GMRqYJfJrEg5EgoYSRb35g h7rmpDp4p34CQ4V8Lyj4rkTEXBQYgMc0a+GewFxs8bjdfZWWyGAv8rF8fQKDYJbeuSyp Qp350mFth12927b6Z+eN/5hp9XJmoPhcgWIrw6os7rK0ql5ITuQy8Iofauu6ek52w2C8 DJPjY4H+190BX4ukyFho2NMxkOpI3GS+tBJ2DVzAuIK8Bjs7XD39aeqMsbsAHlDF/tBV To8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=v7VtkEEG2LAz9vVB8MM5QKckRl92FYJ98jBUqUE9BwA=; b=EANMaMqQl+IWM1RZDeSpw10Xic7tctEtEV/XwAD6mlVb6hgk98ggbk/nBrXCp2msX9 JVQNJWTQDVzVHKx60sRtds8CBK86/Qwcn8OMdBTMt5NN1jtbIrh6GmLsw1umiKP6TDMh BZaBUJW4mmP5hDXQZSARAkV9Ir1bgGrERWWIxGrLraQRRav5BQ2mwWZzsTRLAxu6KRmx 3tjqvKUi3JbMaxWdH01QT61831R8sys/Jb4fU9KSo/nOMWE8IwK3q3ctKkpiktO3HJKp rprdhQPIMsEw4fNgoooKYbdrrEVbYvnWeNY/TzhphY9ed84Rql726kmZ3SX9f7qQIWQl 5s+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u5spxzCL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m55si267778edc.17.2019.09.26.13.42.30; Thu, 26 Sep 2019 13:43:06 -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=@gmail.com header.s=20161025 header.b=u5spxzCL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728816AbfIZUm3 (ORCPT + 99 others); Thu, 26 Sep 2019 16:42:29 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42283 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbfIZUm3 (ORCPT ); Thu, 26 Sep 2019 16:42:29 -0400 Received: by mail-wr1-f68.google.com with SMTP id n14so262150wrw.9; Thu, 26 Sep 2019 13:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=v7VtkEEG2LAz9vVB8MM5QKckRl92FYJ98jBUqUE9BwA=; b=u5spxzCLQa36RysMhpR/QTwiffH9apHOymwGEfBlshrnSYnVSdLYQTuKSRlBahGMTW kljWooiuX6R0VxnZ0cUGreGtbkLL9qX/hR9bgMaaO6BjvUQ2aXWDK1tGQ9rfNxbwiSSq fFKbhVrD0RlruSVqYVz4o7GMqXxhsRmZSh5NM7ExWQGIb1vFcF9k/a6uJppHVwmJvoAI DxBgnAhlPvJgoCw4QX6sBYfSFqmbXaqFKW0euCCzG5haAewy1g588lLp/JBDHpxMifyq hpWz6Qe4YXpxYViS+EpdOMW0DgRg2lSQ2sQAGcNWsWwEIQD/GGh4NnFfY4+bvjmZdkId VAPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=v7VtkEEG2LAz9vVB8MM5QKckRl92FYJ98jBUqUE9BwA=; b=ub8Q4e+gZZdS9Nb6S/YJKur5BZAIO11nucv7TYsw/TAi8u7Tis42rYwKFKqMXrz92a rT3O5eybi4b0wacHVAc+ZE+rBPOMXXM/kMTNn46qY7XlAjzYwNQdoha+/IhyKgaWS5id 2y/edRJd2qZFjmfkjoIDJJCSXuD0W+XFn4600+F3Jw4pAwsZq9ScMq/CjrBK2xRyEfjB ZoYtnchxbnmwdP8TnnVSAqZoBs1FXLOP/qrAaNBbYr1tdOqTF8jK08RLvWopXR7tCMOK 347i6wZePfwJM4gYAEsnnun7TD+fv9p2zn24eKCtq0tE060JmnxvG3CZp1HRICpj4Xby jYzg== X-Gm-Message-State: APjAAAUuljqjaiGOTiPGguWGVUrisM0Ymuf4TvtPjpVTlLIsg+55EgXj ROHA1APvgZpDQMIam0f3Vmk= X-Received: by 2002:a5d:6306:: with SMTP id i6mr243312wru.323.1569530546588; Thu, 26 Sep 2019 13:42:26 -0700 (PDT) Received: from pc ([5.158.153.52]) by smtp.gmail.com with ESMTPSA id r2sm5722658wma.1.2019.09.26.13.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 13:42:25 -0700 (PDT) Date: Thu, 26 Sep 2019 22:42:17 +0200 From: "Ahmed S. Darwish" To: Linus Torvalds , "Theodore Y. Ts'o" Cc: Florian Weimer , Willy Tarreau , Matthew Garrett , Andy Lutomirski , Lennart Poettering , "Eric W. Biederman" , "Alexander E. Patrakov" , Michael Kerrisk , lkml , linux-ext4 , linux-api , linux-man Subject: [PATCH v5 0/1] random: getrandom(2): warn on large CRNG waits, introduce new flags Message-ID: <20190926204217.GA1366@pc> References: <20190912034421.GA2085@darwi-home-pc> <20190912082530.GA27365@mit.edu> <20190914122500.GA1425@darwi-home-pc> <008f17bc-102b-e762-a17c-e2766d48f515@gmail.com> <20190915052242.GG19710@mit.edu> <20190918211503.GA1808@darwi-home-pc> <20190918211713.GA2225@darwi-home-pc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Summary / Changelog-v5: - Add the new flags GRND_INSECURE and GRND_SECURE_UNBOUNDED_INITIAL_WAIT to getrandom(2), instead of introducing a new getrandom2(2) system call, which nobody liked. - Fix a bug discovered through testing where "int ret = wait_event_interruptible_timeout(waitq, true, MAX_SCHEDULE_TIMEOUT)" returns failure (-1) due to implicit LONG_MAX => int truncation - WARN if a process is stuck on getrandom(,,flags=0) for more than 30 seconds ... defconfig and bootparam configurable - Add documentation for "random.getrandom_wait_threshold" kernel param - Extra comments @ include/uapi/linux/random.h and random.c::getrandom. Explicit recommendations to *exclusively* use the new flags. - GRND_INSECURE never issue any warning, even if CRNG is not inited. Similarly for GRND_SECURE_UNBOUNDED_INITIAL_WAIT, no matter how big the unbounded wait is. In a reply to the V4 patch, Linus posted a related patch [*] with the following additions: - Drop the original random.c behavior of having each /dev/urandom "CRNG not inited" warning also _reset_ the crng_init_cnt entropy. This is not included in this patch, as IMHO this can be done as a separate patch on top. - Limit GRND_RANDOM max count/buflen to 32MB instead of 2GB. This is very sane obviously, and can be done in a separate patch on top. This V5 patch just tries to be as conservative as possible. - GRND_WAIT_ENTROPY and GRND_EXCPLICIT: AFAIK these were primarily added so that getrandom(,,flags=0) can be changed to return weaker non-blocking crypto from non-inited CRG in a possible future. I hope we don't have to resort to that extreme measure.. Hopefully the WARN() on this patch will be enough in nudging distributions to enable more hwrng sources (RDRAND, etc.) .. and also for the user-space developres badly pointed at (hi GDM and Qt) to fix their code. [*] https://lkml.kernel.org/r/CAHk-=wiCqDiU7SE3FLn2W26MS_voUAuqj5XFa1V_tiGTrrW-zQ@mail.gmail.com Ahmed S. Darwish (1): random: getrandom(2): warn on large CRNG waits, introduce new flags .../admin-guide/kernel-parameters.txt | 7 ++ drivers/char/Kconfig | 60 ++++++++++- drivers/char/random.c | 102 +++++++++++++++--- include/uapi/linux/random.h | 27 ++++- 4 files changed, 177 insertions(+), 19 deletions(-) -- 2.23.0