Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2134324ybh; Fri, 17 Jul 2020 10:03:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgmSpPqKzc39faKPBBUAiUt9H9H5k9FuFLckOYGm/OP7y18cG/8eQKCw5WSP1ssvn4DnBG X-Received: by 2002:a17:906:a055:: with SMTP id bg21mr9440814ejb.516.1595005437760; Fri, 17 Jul 2020 10:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595005437; cv=none; d=google.com; s=arc-20160816; b=uzHrpFOGLzo/PH3UtK4jROwxXmiZ8YONr6LrAnmiJV1LAFFu3nu3lxfsRVeT/ABdjp ssOkv1OE8e5XmQPMnmoUdWahHVIrVCkR+I7qzwVd5t6disKwnhfBbrBxf65bjwQ7eX8W kIcuuk9TfGUTCVSZooEkUd2Y73v1HHPzs60IoSVx6Lk3wNCXTccT5C3Qb5mDbtaCqZBs qRBXlyiFEbuSH7jMW0Z3PSTUMeLlrB3Dh4QZb4pMRuP09Hm1DPNhssXtMQ1ADM73aLbe jmIN94N0PirTKlNCERuWRaATqoy1LL8kspjQV7VKIeI4XrwvaUXN3s9nmwrGqCItTuix zVDg== 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=FHhZWLMVcDdGUcMccJ4Twx1ya+nCiDzGxZWFKRf9Y0L949kmFUL9Nm/+SgKWF2Zxdg cwYjaln4t5OmzEfJsFuVoQbPGmMCRkGzVW2IQF/6nAghXxewhN/HM8dTpt9R3RGP9AHV KuYIO3vWIwa/Q0RHoqKlUE3zMFHlKQ4u4f4wyKKIskWMBXXzmMvpkT5TFXUyStoutl7/ s7phkJIwIakNWvlsXeQH1jSjgXXmPSe1BJNTPq3Fen/EstuQtmq90f3e2+cZFP0+9hpG lReCFjVNtC9aAKYwxCTsWzOblwZOY2mP9mZ6V3a9s3YssGisB3ghfsHiXInbTHqzvS9q UncQ== 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 r25si5934245edo.46.2020.07.17.10.03.34; Fri, 17 Jul 2020 10:03:57 -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 S1728248AbgGQRBM (ORCPT + 99 others); Fri, 17 Jul 2020 13:01:12 -0400 Received: from mga14.intel.com ([192.55.52.115]:45300 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728162AbgGQRA6 (ORCPT ); Fri, 17 Jul 2020 13:00:58 -0400 IronPort-SDR: W/3CCtWv1XteoI17m6/x+EO2xBNrlO+G4ho1HR0QPGJtuYH/PT43RMoOQKiMSfql7LTrTi1D3o 20xKf5gL+xVw== X-IronPort-AV: E=McAfee;i="6000,8403,9685"; a="148798306" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="148798306" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 10:00:35 -0700 IronPort-SDR: tGPG5lPpX8FK4pomOLVaN/xY0TB91kvBXqJqSflLHchyDOENJ7FjAjIsmotk44Nh0AwRvjN+si aLsE2GNJKpiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="270861956" Received: from kcaccard-mobl.amr.corp.intel.com (HELO kcaccard-mobl1.jf.intel.com) ([10.212.33.149]) by fmsmga008.fm.intel.com with ESMTP; 17 Jul 2020 10:00:33 -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 v4 03/10] x86/boot: Allow a "silent" kaslr random byte fetch Date: Fri, 17 Jul 2020 10:00:00 -0700 Message-Id: <20200717170008.5949-4-kristen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200717170008.5949-1-kristen@linux.intel.com> References: <20200717170008.5949-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