Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10414567ybi; Wed, 24 Jul 2019 22:48:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/7o1D4IGdZsTs2WhBrujmoW60ThS8Ok4g3yDvz7rHkO18ECkG7Evj8BrXRoW2h5SlcUjf X-Received: by 2002:a62:1652:: with SMTP id 79mr14970609pfw.20.1564033689166; Wed, 24 Jul 2019 22:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033689; cv=none; d=google.com; s=arc-20160816; b=oCOdnuAH++T6RnK2WOowHwXiUWhw1KuxgXrdh1FqLpK2A7kS+U37Ui499l4FfEf/Go 9JGEKIyNTT9dbaPQjbu6cD26T8vYrq+zKqRjjRKh5i8LuwIV+FLtYfjdWUKDvBX8+cjt 5y9bFB1LhY9XNS0fPhd9zgGGgmkaQx4rZoSbEa9t0im9AcuJlXiAKO1/xKFaTbBQZlOj vYO4T2dhwG0Cutdje9fnwVjd77xtmbzdtbb09w21+NeGfNjCNh6LQwGbYHIQ4/BAJaiA 6qUMAPXguRjaPM2Yi3oJCJDDa7qxirpDtjO9P/z5NqGy1tPv8V6dMZgALDR33UucNhop Nv6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SPPeLnkU37h6IEEddULHVtoSg4HbUr/YQkJNiVMbBWg=; b=gAapX1TW0u1Ekf6VyHzvI2nVadEIPkfZw2lZIEW1IWe7nU3gqlPt9a8L3X1sRBti8z Pl64wLLA1mkslkmTpL5kUwlJQvU0p/xxnPW8qVORWFLkqyT/BNFT1BMc7gkV6q8K3Y0w jmt+kYTSUX6EfYQgj84qKikdlPGvBBPYyfvIR2/YNkLYTKaHJzFRGXw3/lQmatZgr1dg ilsbU8pZsM7heoHMZrL+zvwEUC5ruI2IHStiL9ocR7IuHRih/02hfaCglsQRfw8cY7uW 1dk9k4o21renyzm354ZNmm8dnc+NaTQRUHPFPKgTk83Cd31hdMqpHbZEWDyOiSQU54f1 V70w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.ca header.s=s2048 header.b=GGlDxOWT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=yahoo.ca Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e16si16413088pgt.2.2019.07.24.22.47.54; Wed, 24 Jul 2019 22:48:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@yahoo.ca header.s=s2048 header.b=GGlDxOWT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=yahoo.ca Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729373AbfGXWdU (ORCPT + 99 others); Wed, 24 Jul 2019 18:33:20 -0400 Received: from sonic316-12.consmr.mail.bf2.yahoo.com ([74.6.130.122]:38897 "EHLO sonic316-12.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728130AbfGXWdU (ORCPT ); Wed, 24 Jul 2019 18:33:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.ca; s=s2048; t=1564007598; bh=SPPeLnkU37h6IEEddULHVtoSg4HbUr/YQkJNiVMbBWg=; h=From:To:Cc:Subject:Date:From:Subject; b=GGlDxOWTHfwZvZeIFIyrmy8YWAlFW5Uf/DNumTcpt4L9YGiVM/OkJXnxeeTDZ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FOQt9bD2BUYrbEgv6YPgDHoD8j0_xfw1abIdqOvOagxM7zo 4KOkpa838AauLOHcLwwLD25DoBW2MLAn4ZxlC.bqA76CSymsZOc2.Mj_x28PbszFTdYIf5auAWV. 7Iw7yMolAJvg1GT3eaIZW3YUMgJffp_IVsNqOntYVBhzumjkbgsvDIcLZWhfwcepVuGooSzOM_Cv ZQY1B4AKEa2KpWR.rbY1kpgrZ.RZdiqhfTaBlJpWGRrU1wR0nHkp1jETLA81pl8tAu35y95OYKSa r8S.SG.koUHnKt4gpVum6inJHUIJxKftSte.Cyq4Fc6eE1ZDcv5fZxL6B4MHvW5Xa1QxCW05Yhuz nScLSnV0D_0Bx.yXjdB_jeV.kQIo1axJDLAzGyUvSC5N1aIKHs8MdE.ODwkPHRSJUTqkBC6BGvfb s3XnDkUN8jdmk2xJuluofryClJd.5gtJptY.BmTsIAM6BtLQjTqTftb8O8_aVHpKcR8UYNCuoTNg n40hs4MHUYjUk7hsWQ74- Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.bf2.yahoo.com with HTTP; Wed, 24 Jul 2019 22:33:18 +0000 Received: by smtp422.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 43333be216d12705f4c89f176b7fa2c0; Wed, 24 Jul 2019 22:33:16 +0000 (UTC) From: "Alex Xu (Hello71)" To: linux-kernel@vger.kernel.org, tytso@mit.edu Cc: arnd@arndb.de, gregkh@linuxfoundation.org, "Alex Xu (Hello71)" Subject: [PATCH] random: print a message when waiting for random Date: Wed, 24 Jul 2019 18:33:13 -0400 Message-Id: <20190724223313.2498-1-alex_y_xu@yahoo.ca> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - many programs now use getrandom on startup, including for cases which may not be security-sensitive (e.g. hash tables) - boot times are faster than ever with the widespread use of high-speed SSD storage - no major distributions currently use RNDADDENTROPY ioctl when restoring the random seed, including systemd and OpenRC. systemd may add this functionality soon (https://github.com/systemd/systemd/pull/13137) but it seems to have some special requirements (systemd-boot) and/or require special opt-in. - despite the availability of virtio-rng, many hosts do not offer it, and many/most distributions do not configure rngd by default in combination, many programs (e.g. sshd, gdm) now block on startup, sometimes for many minutes. in the kernel, we can't fix this easily, but we should at least notify users why their program is stuck. Signed-off-by: Alex Xu (Hello71) --- drivers/char/random.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/char/random.c b/drivers/char/random.c index 5d5ea4ce1442..e4490c6c9c84 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -511,6 +511,8 @@ static struct ratelimit_state unseeded_warning = RATELIMIT_STATE_INIT("warn_unseeded_randomness", HZ, 3); static struct ratelimit_state urandom_warning = RATELIMIT_STATE_INIT("warn_urandom_randomness", HZ, 3); +static struct ratelimit_state wait_for_random_warning = + RATELIMIT_STATE_INIT("warn_wait_for_random", HZ, 3); static int ratelimit_disable __read_mostly; @@ -1745,6 +1747,9 @@ int wait_for_random_bytes(void) { if (likely(crng_ready())) return 0; + if (__ratelimit(&wait_for_random_warning)) + pr_info("random: %s: waiting for randomness\n", + current->comm); return wait_event_interruptible(crng_init_wait, crng_ready()); } EXPORT_SYMBOL(wait_for_random_bytes); @@ -1901,6 +1906,7 @@ int __init rand_initialize(void) if (ratelimit_disable) { urandom_warning.interval = 0; unseeded_warning.interval = 0; + wait_for_random_warning.interval = 0; } return 0; } -- 2.22.0