Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp809547ybv; Wed, 5 Feb 2020 15:07:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwLb/TF0DbdelOCjzrlGR+LdgtdG6dS7sEosC2tdJQLZvxBc73jbH1yhIgdZzTtni0zCcZ3 X-Received: by 2002:a05:6830:18c4:: with SMTP id v4mr26990538ote.265.1580944060205; Wed, 05 Feb 2020 15:07:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580944060; cv=none; d=google.com; s=arc-20160816; b=AjqkMq4oNe8+oebELm+tCMk0M7jbJ8H/LhDdcErQLKl4OHY7kkwTCdjStqOFA316L6 8l35P1TvqFpu9oX62tOG+QpzhABxgQizlmror8v3CCrc8h/JAfCD+ukv//lxiGXv6Gk9 ptHyX1n8iZmlJNhcqYEEqZNLKllIyX/lJ4qT6Ch+9aUk6DwEH9LKL4e88JpqEZgICJzu TMnDV7YsSuGVaOZ8cfHKZaSvPOdD0IHnkwDKTBeLQmfTiyOtfUUd0h+QQ7xyZe76+2a7 8vgWleh6Lfnf9WwO0VMg6ueILC04leDwWrJRHOKeOhvxZf09Pp0AppUN8J8XnN4RuJTY 822w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SHMpzvBb2rlFBtGh4myeueen2QVmcWDu4yl+UGAU9LU=; b=1FZWpFizJoep9r2Kb5eFqjnAhpr7HM86fWDVa3Qyq5grWZApPtED9wRdnZNLZyNbOq Jl2KgBEtdVe4G09HS9WCL3j/6hQa3RwFsWZx/sZr8mUeDqJ+LWrEq+6Cyrq6WqQA8DiT c+fmp62r+sSYwF53IAdledqlozk3k3yYmIoyk69xXdA2JsmUk1wzJLnVH2tZFTStheyd SEBAYUxs4M75EKq8l5KdPKxC5zM41ocVXK0bBtcWvJjLHWva8f4s4CPshPPiHeASMN9F W99zPj/0/QWERiCIityl8cK/02+Vaja7i1vXKdiy5Siw+7vckG3U7+igBlYAceRZHn97 gMsA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b126si1053838oii.72.2020.02.05.15.07.28; Wed, 05 Feb 2020 15:07:40 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727661AbgBEWkG (ORCPT + 99 others); Wed, 5 Feb 2020 17:40:06 -0500 Received: from mga02.intel.com ([134.134.136.20]:60113 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727149AbgBEWjg (ORCPT ); Wed, 5 Feb 2020 17:39:36 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2020 14:39:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,407,1574150400"; d="scan'208";a="225092441" Received: from unknown (HELO localhost.jf.intel.com) ([10.54.75.26]) by fmsmga007.fm.intel.com with ESMTP; 05 Feb 2020 14:39:35 -0800 From: Kristen Carlson Accardi To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, arjan@linux.intel.com, keescook@chromium.org Cc: rick.p.edgecombe@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Kristen Carlson Accardi Subject: [RFC PATCH 03/11] x86/boot: Allow a "silent" kaslr random byte fetch Date: Wed, 5 Feb 2020 14:39:42 -0800 Message-Id: <20200205223950.1212394-4-kristen@linux.intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200205223950.1212394-1-kristen@linux.intel.com> References: <20200205223950.1212394-1-kristen@linux.intel.com> 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 From: Kees Cook Under earlyprintk, each RNG call produces a debug report line. When shuffling hundreds of functions, this is not useful information (each line is identical and tells us nothing new). Instead, allow for a NULL "purpose" to suppress the debug reporting. Signed-off-by: Kees Cook Signed-off-by: Kristen Carlson Accardi --- arch/x86/lib/kaslr.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/x86/lib/kaslr.c b/arch/x86/lib/kaslr.c index a53665116458..2b3eb8c948a3 100644 --- a/arch/x86/lib/kaslr.c +++ b/arch/x86/lib/kaslr.c @@ -56,11 +56,14 @@ unsigned long kaslr_get_random_long(const char *purpose) unsigned long raw, random = get_boot_seed(); bool use_i8254 = true; - debug_putstr(purpose); - debug_putstr(" KASLR using"); + if (purpose) { + debug_putstr(purpose); + debug_putstr(" KASLR using"); + } if (has_cpuflag(X86_FEATURE_RDRAND)) { - debug_putstr(" RDRAND"); + if (purpose) + debug_putstr(" RDRAND"); if (rdrand_long(&raw)) { random ^= raw; use_i8254 = false; @@ -68,7 +71,8 @@ unsigned long kaslr_get_random_long(const char *purpose) } if (has_cpuflag(X86_FEATURE_TSC)) { - debug_putstr(" RDTSC"); + if (purpose) + debug_putstr(" RDTSC"); raw = rdtsc(); random ^= raw; @@ -76,7 +80,8 @@ unsigned long kaslr_get_random_long(const char *purpose) } if (use_i8254) { - debug_putstr(" i8254"); + if (purpose) + debug_putstr(" i8254"); random ^= i8254(); } @@ -86,7 +91,8 @@ unsigned long kaslr_get_random_long(const char *purpose) : "a" (random), "rm" (mix_const)); random += raw; - debug_putstr("...\n"); + if (purpose) + debug_putstr("...\n"); return random; } -- 2.24.1