Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6029930iog; Thu, 23 Jun 2022 09:54:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ucU1whNEcgSvXpJghMgrEGdeUHoDTGIqxvvBOJqJrYS/En/l3DXRPv7KSuAjiZs7tKcwbp X-Received: by 2002:a17:906:77d2:b0:722:e726:addc with SMTP id m18-20020a17090677d200b00722e726addcmr9406261ejn.96.1656003260518; Thu, 23 Jun 2022 09:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656003260; cv=none; d=google.com; s=arc-20160816; b=jNe8fzPDcSGonRTT1L4IZLzZxnmZ0mT7CJufxK11s5hzx8Ou68nP2HnGpDWfcqggzF Gwjfc48ipGEa5ffQrqTW9BPHz+yl7BZTCv2wXxboJpiuo01CaTWePJZquF8MoUswPyou T8fr/TDgujSW36Er3Os+tZGm8JXssBoc+EAh9YlZdVOWth1EOmryJGp6UnAFLs+Kpq2Q 5jdgrkPt5CFNiPhtxayEXsDqqQOj1yNRlE0Yb3+9p1JwXXxiovsSTONGhGxqqngp0T7F RHuGGbrWxkZY+cdmiSKqDR9LSAQ4174fD6BKrefxRNj0xT6lR6q+arysH/L9COBXOO7N cttg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ud/xMZAFenrDbuTwaJ1hhdfFVDVgH//Z/+s0vhuXHCc=; b=iBLCwEQ7+RVp8xByh8xjxH6NQUc9ya8mqac5IA/TvPpHMDPazMOZFsArdffA7muV5+ 5c/EXOp4o65M2LnF8kGZhssnOijT7aJuqgp3v6DZzgxvzNF2NzwmKgvO9HgKJxrQf56F bQUPLhq9G7dOBNSCYFsjfW2kprH6YdG8e9QTaP1B6IFTlkbZMhJTlTHkZEVKbY+4oUef lYGQ2MgntFzwmJNIg+Axkk2OVk5AOf0NZph9jkNwisRGS5gWN+4d2T+gU7VtP+hYm4qn Quim3lkpQ3uYRaVOKmKDn7mHRTRmUGfxKzrhzRDbSzhqx05WoDyRZShtwmEPTYoBfv1w zNWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XulMMaDe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a1709060f8f00b007115a93d536si21139584ejj.598.2022.06.23.09.53.52; Thu, 23 Jun 2022 09:54:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XulMMaDe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232677AbiFWQsC (ORCPT + 99 others); Thu, 23 Jun 2022 12:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232671AbiFWQrB (ORCPT ); Thu, 23 Jun 2022 12:47:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D7C649B4B; Thu, 23 Jun 2022 09:47:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DA08961F4A; Thu, 23 Jun 2022 16:46:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C79F9C3411B; Thu, 23 Jun 2022 16:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656002819; bh=tnmv7JW4ZNhDwG1oVMSeHSRXkCpbPWpz06JUHKDBzTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XulMMaDeUTzkn93lZbdGSW5IGvqSMNXLNClSX71i0+TyvJupr1LXNSP9EypE746UJ dIxbZsf/xbyDS2r37l53uUKILeYtH9ikBZDCX7lUHS7SZN5D6ojS1APpGmLFKywhPp CBE/XsajVtCYTfNi1fF28/N5ezwKKMw7MEuatL4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Theodore Tso , "Jason A. Donenfeld" Subject: [PATCH 4.9 035/264] random: make CPU trust a boot parameter Date: Thu, 23 Jun 2022 18:40:28 +0200 Message-Id: <20220623164345.062513423@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook commit 9b25436662d5fb4c66eb527ead53cab15f596ee0 upstream. Instead of forcing a distro or other system builder to choose at build time whether the CPU is trusted for CRNG seeding via CONFIG_RANDOM_TRUST_CPU, provide a boot-time parameter for end users to control the choice. The CONFIG will set the default state instead. Signed-off-by: Kees Cook Signed-off-by: Theodore Ts'o Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- Documentation/kernel-parameters.txt | 6 ++++++ drivers/char/Kconfig | 4 ++-- drivers/char/random.c | 11 ++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -3577,6 +3577,12 @@ bytes respectively. Such letter suffixes ramdisk_size= [RAM] Sizes of RAM disks in kilobytes See Documentation/blockdev/ramdisk.txt. + random.trust_cpu={on,off} + [KNL] Enable or disable trusting the use of the + CPU's random number generator (if available) to + fully seed the kernel's CRNG. Default is controlled + by CONFIG_RANDOM_TRUST_CPU. + rcu_nocbs= [KNL] The argument is a cpu list, as described above. --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -607,5 +607,5 @@ config RANDOM_TRUST_CPU that CPU manufacturer (perhaps with the insistence or mandate of a Nation State's intelligence or law enforcement agencies) has not installed a hidden back door to compromise the CPU's - random number generation facilities. - + random number generation facilities. This can also be configured + at boot with "random.trust_cpu=on/off". --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -780,6 +780,13 @@ static struct crng_state **crng_node_poo static void invalidate_batched_entropy(void); +static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU); +static int __init parse_trust_cpu(char *arg) +{ + return kstrtobool(arg, &trust_cpu); +} +early_param("random.trust_cpu", parse_trust_cpu); + static void crng_initialize(struct crng_state *crng) { int i; @@ -800,12 +807,10 @@ static void crng_initialize(struct crng_ } crng->state[i] ^= rv; } -#ifdef CONFIG_RANDOM_TRUST_CPU - if (arch_init) { + if (trust_cpu && arch_init) { crng_init = 2; pr_notice("random: crng done (trusting CPU's manufacturer)\n"); } -#endif crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; }