Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3776172ybt; Tue, 23 Jun 2020 10:25:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHoebnsnYQ0UxFGLE1Q0M9PL5Liu2Xfh0VGjYwi0oV3p/Mb+2HV9CCQZTI2nSetNZ7rrLK X-Received: by 2002:a17:906:1196:: with SMTP id n22mr20783061eja.33.1592933129072; Tue, 23 Jun 2020 10:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592933129; cv=none; d=google.com; s=arc-20160816; b=CvJYOpEwNgVWEeK9Mf77qc6+SAIC+eb8OpFbaZtYDafzTYit1ICS1NDZhnZo8l02vN DXV4e2CGHwdsao4bOYQj5Z8sinvz6+ITeG0NHWJGioDyduCHIjPOBD9liCO040Kyt4g0 ITK4eW9M0kcDOrmzuG7YHTnv73at7b/tAoQxX7/+NJimDbW2XzeVf1r5pvgTWoShgYnv BQdp5Ag57/VZ1Q05pGcndFANiQUYof3faurN4S6swbMpPfk9ZSYZiNsd3U/CiIRjkHTf jH0PHAdYJrPLnRQ/HVA+XjQlG8jeadPlHXMeQ6L2gzANECXllpvhb58wwBKMZ/04XLOW tTQQ== 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=jevAbo5hPA0XyaDCL+vqo3vw9yAAkSQqn5hIhKbCUDsvw9Q5QUdWHWQvJb7u22SzeS LCBs8jjuTOva3OiPeeLcnSlHV5K4Mk/6jwNEc6bpxciZ138yMP/7gqgyD8pPy7Bzjbri SXPqr0055+rGr9D5+ve6tGJuINy2XQzvEaIwDfOBEm2b/xc5sjC0FhDjRH5G/GnyAZb3 BPmZkLwjZK9zgKFT55xBk63mU79nbAmoj+GB36wuTYn2UEUQD7bCSICO92/nEzjGb2mN v6PAylBEPpAAgKiAM26uY0BEcOSFeBfskJkneZFClu+HU0u+vMegHTY433KdhJvBojc2 hmJg== 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 nh4si11229409ejb.339.2020.06.23.10.24.48; Tue, 23 Jun 2020 10:25:29 -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 S1733094AbgFWRYc (ORCPT + 99 others); Tue, 23 Jun 2020 13:24:32 -0400 Received: from mga11.intel.com ([192.55.52.93]:61940 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733038AbgFWRY3 (ORCPT ); Tue, 23 Jun 2020 13:24:29 -0400 IronPort-SDR: feFd/DGGWyDacQhbT00LJZixPrlI39QzQ6EZVGnDQxyqOd+U7QfGu2oip4h6aresouH0GBimvx lZ8M8pozaM0A== X-IronPort-AV: E=McAfee;i="6000,8403,9661"; a="142391472" X-IronPort-AV: E=Sophos;i="5.75,272,1589266800"; d="scan'208";a="142391472" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2020 10:24:28 -0700 IronPort-SDR: llNtVSkrgMcmxCmJG381SB+dUKLXCcjUoFhA4ZlO63DA+91vjvYIpPHBjhrwR6x/Z0NPR+RGMQ DkhGiKQHYAmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,272,1589266800"; d="scan'208";a="423080050" Received: from kcaccard-mobl.amr.corp.intel.com (HELO kcaccard-mobl1.jf.intel.com) ([10.213.182.184]) by orsmga004.jf.intel.com with ESMTP; 23 Jun 2020 10:24:26 -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 v3 03/10] x86/boot: Allow a "silent" kaslr random byte fetch Date: Tue, 23 Jun 2020 10:23:20 -0700 Message-Id: <20200623172327.5701-4-kristen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200623172327.5701-1-kristen@linux.intel.com> References: <20200623172327.5701-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