From patchwork Mon Aug 10 15:21:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 266625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLACK, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08558C433DF for ; Mon, 10 Aug 2020 15:38:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7C4B23135 for ; Mon, 10 Aug 2020 15:38:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073925; bh=8aTXwZ4opx8LLQJfKMRpxPVdMjiXrdDmraPtP16ipPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RwmvXRbHJbk2AZXGF5h/NghTpEJJXPXnB3CQJkp3Y5+e3nhmLd5lbOWNqbZH0g3H7 f4ek9N1jFfDiFJet3X/wZh2ZXe/uJ6r8kx+LIq0zUkGruiMdMiSBAxVkBofphOgcI6 qkd7z5LhWnsg0p/ocuQEM/IBuYCU+rAhqmqBnrM4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728545AbgHJPZg (ORCPT ); Mon, 10 Aug 2020 11:25:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:59408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728539AbgHJPZf (ORCPT ); Mon, 10 Aug 2020 11:25:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 43CC920658; Mon, 10 Aug 2020 15:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073134; bh=8aTXwZ4opx8LLQJfKMRpxPVdMjiXrdDmraPtP16ipPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PJ9V2mWvfgouekQ/8P4txSPjnW1WFGDk900eiaaZ+QrtWV3v75CL8iq8iYQCKJwyM RTdKH/tHJj1HlXFjJgEmLeCNMOJgrPSE08kHeFN9+TiLvOEg/kse9+XLG7zEZNvUGb bA7VTHK7H9Al9pDeQ/aTzBFZCi7iDHCmeuU855IE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qian Cai , Mark Brown , Mark Rutland , Guenter Roeck , Linus Torvalds , Sedat Dilek Subject: [PATCH 5.7 79/79] arm64: kaslr: Use standard early random function Date: Mon, 10 Aug 2020 17:21:38 +0200 Message-Id: <20200810151816.114898609@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151812.114485777@linuxfoundation.org> References: <20200810151812.114485777@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Guenter Roeck commit 9bceb80b3cc483e6763c39a4928402fa82815d3e upstream. Commit 585524081ecd ("random: random.h should include archrandom.h, not the other way around") tries to fix a problem with recursive inclusion of linux/random.h and arch/archrandom.h for arm64. Unfortunately, this results in the following compile error if ARCH_RANDOM is disabled. arch/arm64/kernel/kaslr.c: In function 'kaslr_early_init': arch/arm64/kernel/kaslr.c:128:6: error: implicit declaration of function '__early_cpu_has_rndr'; did you mean '__early_pfn_to_nid'? [-Werror=implicit-function-declaration] if (__early_cpu_has_rndr()) { ^~~~~~~~~~~~~~~~~~~~ __early_pfn_to_nid arch/arm64/kernel/kaslr.c:131:7: error: implicit declaration of function '__arm64_rndr' [-Werror=implicit-function-declaration] if (__arm64_rndr(&raw)) ^~~~~~~~~~~~ The problem is that arch/archrandom.h is only included from linux/random.h if ARCH_RANDOM is enabled. If not, __arm64_rndr() and __early_cpu_has_rndr() are undeclared, causing the problem. Use arch_get_random_seed_long_early() instead of arm64 specific functions to solve the problem. Reported-by: Qian Cai Fixes: 585524081ecd ("random: random.h should include archrandom.h, not the other way around") Cc: Qian Cai Cc: Mark Brown Reviewed-by: Mark Rutland Reviewed-by: Mark Brown Tested-by: Mark Brown Signed-off-by: Guenter Roeck Signed-off-by: Linus Torvalds Cc: Sedat Dilek Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/kaslr.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/arch/arm64/kernel/kaslr.c +++ b/arch/arm64/kernel/kaslr.c @@ -84,6 +84,7 @@ u64 __init kaslr_early_init(u64 dt_phys) void *fdt; u64 seed, offset, mask, module_range; const u8 *cmdline, *str; + unsigned long raw; int size; /* @@ -122,15 +123,12 @@ u64 __init kaslr_early_init(u64 dt_phys) } /* - * Mix in any entropy obtainable architecturally, open coded - * since this runs extremely early. + * Mix in any entropy obtainable architecturally if enabled + * and supported. */ - if (__early_cpu_has_rndr()) { - unsigned long raw; - if (__arm64_rndr(&raw)) - seed ^= raw; - } + if (arch_get_random_seed_long_early(&raw)) + seed ^= raw; if (!seed) { kaslr_status = KASLR_DISABLED_NO_SEED;