Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1572811ybk; Thu, 21 May 2020 09:59:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxAwF2K1xqbZahyFO6ESvxf/gCxBZmOJrqEQE/nt/fvsjeq4JCVXkFLwvscP4ZnOhN2r0h X-Received: by 2002:a17:907:2711:: with SMTP id w17mr4738258ejk.8.1590080382013; Thu, 21 May 2020 09:59:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590080382; cv=none; d=google.com; s=arc-20160816; b=F4EacCH8xL4k05vVIxGQDh0KSd2cw4oXs7XPD2DBTOKzqh0Dv4bw9MpVmp0MA61qJu IzGMikdICNho0BhlSFg2xpc4M1fegh/TIIKStomTLARVyuXJZjdsDSl0y6WdoOngKiLr CIQBJb+d2fAyeeFP4AVhu81q98i2mF3ntgv5C4ylyT1oZhl5iq8tqXH/RvRmEEgZM/yN zOlLPs3yGZvYzqlNq0i4hZNw3/ZgytYubgChuj9435WmHJ3c2EBHo+Cc5bnTxBsMngg+ nzzw+14x7fvpdVjMS0g1TRAYSPwK71cd7X+/bs7h5xIK+dccj8yZWkrGiyPwi+O1BfBJ jl9w== 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 :ironport-sdr:ironport-sdr; bh=IbJ5ijD3l+ocLGOjhVg8njh7vQ53hXdAXlwhP9H5IEE=; b=JulQ0lD19aiMCZ7Q6Hkc6A09psgZYPc/BaPld8e+GnBxJHbOKn9NPAKah4J2qbsoF+ 2VMl8Y5lzHSeKBRF36Aa61Pj1P+Snpj9JIckVSRjm5zVb/2yLSEQVRib8ltlEXqFsYGy fgP5fHT82GSLT0gsVbPIWYGTDu4B71iipRH09B1dg2XYNlZbbFDZcBbZHSzJYKKOMdtG gF1pvvhpkQx888KwwXcgT4MU9hYroUMRJ5wWw73V3wNTUe/Um3MpuNykdwm+0T2GTvnC Iu8JEfVSA06yRh13z//yWkDB0EL4RRSsg1jLNJaU28KcA4w9dzz67PRfYLwgMg4lBUs3 cJOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u2si4113803edp.67.2020.05.21.09.59.18; Thu, 21 May 2020 09:59:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730148AbgEUQ5O (ORCPT + 99 others); Thu, 21 May 2020 12:57:14 -0400 Received: from mga02.intel.com ([134.134.136.20]:46206 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730138AbgEUQ5N (ORCPT ); Thu, 21 May 2020 12:57:13 -0400 IronPort-SDR: 9Dat/G+NoPA+jHDfIwhKpnrQ+7B5eUfLpaKaJFmoF7blU5bVAh6wQf7Q9tbvUNPMniXL6N/0Jn AWwDXG4hasxg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2020 09:57:13 -0700 IronPort-SDR: KgL5+3LiB678fkrVbNIM5wWyFQbpKLy3nifdCghODahi4pxKbFaFjODkotTb+qwuLsUR/0jd9P SfCtZjOQgyxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,418,1583222400"; d="scan'208";a="309094705" Received: from kcaccard-mobl.amr.corp.intel.com (HELO kcaccard-mobl1.jf.intel.com) ([10.212.147.236]) by FMSMGA003.fm.intel.com with ESMTP; 21 May 2020 09:57:11 -0700 From: Kristen Carlson Accardi To: keescook@chromium.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, "H. Peter Anvin" Cc: arjan@linux.intel.com, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, rick.p.edgecombe@intel.com, Kristen Carlson Accardi Subject: [PATCH v2 3/9] x86/boot: Allow a "silent" kaslr random byte fetch Date: Thu, 21 May 2020 09:56:34 -0700 Message-Id: <20200521165641.15940-4-kristen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200521165641.15940-1-kristen@linux.intel.com> References: <20200521165641.15940-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.20.1