Received: by 10.192.165.148 with SMTP id m20csp383757imm; Wed, 25 Apr 2018 00:43:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx49MyILXSPXcuf6FP40D7XMnD1Ym+KY4gIWgT1yiL0C2HrVmQJW745aBqe9H43oOsDQwR66k X-Received: by 10.98.69.142 with SMTP id n14mr26944982pfi.42.1524642201485; Wed, 25 Apr 2018 00:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524642201; cv=none; d=google.com; s=arc-20160816; b=S5y7k7PNs+kuavjbZroAX+1AJJmOKyj97cjjQIxoLzF+0ByWMsXSE3VFaFku4GRBQU xlBewcSdSP4uNo5ZYuhSjBaIsOxWbBIqmCE7QgOOZCurap1jum0Pt/N2gSkywOj42a6R btpljI4NLG53R+n0TFRrf8n+fMP7Kg6PaFBdd1ebGSLkweJ7e0IjCM73rFOUDLAEJPxH YtsRsrrFxb5Ieiwfz+ZwAs9QY2sqttYY4OGbgW/8RiZ3/UQf3A+9gWV6puhntkGVWxqS GF4ryy8Q583JZnjTU378m5Hoimbl7TYv612A32IzojZMIIznDANBEBAgQuMfKXaj57dp 1KNQ== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=Vv9QSzUhoSs/PEn08uR1+qilPcCqSKG8v8nVTP7WMPQ=; b=0ZxVb7TZwIh0rFN+WQUjOjIvW/he15v4dz19z2cM0KmyCQppDUdDA6KwrCoxBzm/4s +TGNpQygaq7+plXZ6+b8UEKr0ed6Tc+9anQHJyWVT2cDy5WzrLkycslEu+YSiCQvMgCz BT7ajqiN5hHOb6SbkiyARjsEYSfqm1YrQDHDJxs34XtGY7Ih9GGL1o1zwhWMZu+ptzBi wIGmFTmRc+v4cmps5vSwnnq/P9vC6cEnUEBuTFk2a0t22Zr+mfHSPzY/XnYc+h9ytqo0 mRxiDPhINJ6secm8qDfE93XL+F8HG1QnY81oI3eQ24n4awjdcXA1DdvYpHNqpaHoMgpu fT2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@thunk.org header.s=ef5046eb header.b=NsHHR92b; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j8si13261246pgt.582.2018.04.25.00.43.06; Wed, 25 Apr 2018 00:43:21 -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=fail header.i=@thunk.org header.s=ef5046eb header.b=NsHHR92b; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751320AbeDYHlz (ORCPT + 99 others); Wed, 25 Apr 2018 03:41:55 -0400 Received: from imap.thunk.org ([74.207.234.97]:54880 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbeDYHlt (ORCPT ); Wed, 25 Apr 2018 03:41:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Vv9QSzUhoSs/PEn08uR1+qilPcCqSKG8v8nVTP7WMPQ=; b=NsHHR92bv5SdAEVvIuN/hEfvqV BiLH5pJM6jsmMuO7yjjmKnEXVmHQnxoGA539APtrVP0z+nv2qCPeTGsuUC7P8mTwhrVLv0Lkt4/Kt WSs8j6DXyMGYSzkuFhCsZO+PPuam+Fc4mo7WQfKYDbIQgbwA23WazMCyl5WvcYH1+7vg=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.89) (envelope-from ) id 1fBF3i-0001mL-Kg; Wed, 25 Apr 2018 07:41:46 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id E713D7A0147; Wed, 25 Apr 2018 03:41:44 -0400 (EDT) Date: Wed, 25 Apr 2018 03:41:44 -0400 From: "Theodore Y. Ts'o" To: Paul Menzel Cc: linux-kernel@vger.kernel.org Subject: Re: Linux messages full of `random: get_random_u32 called from` Message-ID: <20180425074144.GA18803@thunk.org> Mail-Followup-To: "Theodore Y. Ts'o" , Paul Menzel , linux-kernel@vger.kernel.org References: <42c1b84b-ab1f-5577-6304-e0985a637cf9@molgen.mpg.de> <20180424135621.GD4189@thunk.org> <20180424154904.GC30619@thunk.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Does this help on your system? - Ted commit 4e00b339e264802851aff8e73cde7d24b57b18ce Author: Theodore Ts'o Date: Wed Apr 25 01:12:32 2018 -0400 random: rate limit unseeded randomness warnings On systems without sufficient boot randomness, no point spamming dmesg. Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org diff --git a/drivers/char/random.c b/drivers/char/random.c index 721dca8db9cf..cd888d4ee605 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -261,6 +261,7 @@ #include #include #include +#include #include #include #include @@ -438,6 +439,16 @@ static void _crng_backtrack_protect(struct crng_state *crng, static void process_random_ready_list(void); static void _get_random_bytes(void *buf, int nbytes); +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 int ratelimit_disable __read_mostly; + +module_param_named(ratelimit_disable, ratelimit_disable, int, 0644); +MODULE_PARM_DESC(ratelimit_disable, "Disable random ratelimit suppression"); + /********************************************************************** * * OS independent entropy store. Here are the functions which handle @@ -932,6 +943,18 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r) process_random_ready_list(); wake_up_interruptible(&crng_init_wait); pr_notice("random: crng init done\n"); + if (unseeded_warning.missed) { + pr_notice("random: %d get_random_xx warning(s) missed " + "due to ratelimiting\n", + unseeded_warning.missed); + unseeded_warning.missed = 0; + } + if (urandom_warning.missed) { + pr_notice("random: %d urandom warning(s) missed " + "due to ratelimiting\n", + urandom_warning.missed); + urandom_warning.missed = 0; + } } } @@ -1572,8 +1595,9 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller, #ifndef CONFIG_WARN_ALL_UNSEEDED_RANDOM print_once = true; #endif - pr_notice("random: %s called from %pS with crng_init=%d\n", - func_name, caller, crng_init); + if (__ratelimit(&unseeded_warning)) + pr_notice("random: %s called from %pS with crng_init=%d\n", + func_name, caller, crng_init); } /* @@ -1767,6 +1791,10 @@ static int rand_initialize(void) init_std_data(&blocking_pool); crng_initialize(&primary_crng); crng_global_init_time = jiffies; + if (ratelimit_disable) { + urandom_warning.interval = 0; + unseeded_warning.interval = 0; + } return 0; } early_initcall(rand_initialize); @@ -1834,9 +1862,10 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) if (!crng_ready() && maxwarn > 0) { maxwarn--; - printk(KERN_NOTICE "random: %s: uninitialized urandom read " - "(%zd bytes read)\n", - current->comm, nbytes); + if (__ratelimit(&urandom_warning)) + printk(KERN_NOTICE "random: %s: uninitialized " + "urandom read (%zd bytes read)\n", + current->comm, nbytes); spin_lock_irqsave(&primary_crng.lock, flags); crng_init_cnt = 0; spin_unlock_irqrestore(&primary_crng.lock, flags);