Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4406978pxa; Mon, 10 Aug 2020 08:23:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySlCRg4su8XbkuvHjNo2CjWHCMMo0tET0G/9qiGnuoXUpJEjpqnColtcSQGOmXsR4LUlRr X-Received: by 2002:a05:6402:6cc:: with SMTP id n12mr22480627edy.258.1597072985538; Mon, 10 Aug 2020 08:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597072985; cv=none; d=google.com; s=arc-20160816; b=ZPEp0sAKWyenmKkoXrR6xv7/N6KJzW21dfKam9vWO8VvOaGv1yhDjizjVnWmfDJNaP P9cmYHGB7cu+Obj9JtfcOmvTfA2uGdNcgMnZdHP3x2sMvOBRpaJqJHnw0RJpx1fqzytO 8Y0t6v1RLlkm7sfUDG4REW0IUOgGvx4Q8CX3UE8znwN13zSD1tACs22Ur4ua1Qtgi+dy 0zUkWhuoFAvatOuklzVofZGHkLuALiAYlVFaGjN5AEkcDzmnJypUSY+1tvtcOYBbVygH 7rEZbIRFbdYrRnhlMU99ZDBnwoVTI08QoNl90Xa3EQk+1a0sgtjsjqZN7CQfC47mA60N JTWw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R8DpRW/kFLqeZtMuOx1xCfnwwTURfSJZf+vB5aUz3qM=; b=DOOktLerCzhKSnUgxJNugqZER3vCL8mjp3GceCi7xv2P+Fp5/yVZ1TlJFN9Ye7L3F0 iK6Wz4omB7MbX2iq9p+wKzYPWkSzJwygKwjfJPuHYpb1b5DeQGIZka77ho0RyjTYUdIu DKhbb2HhLb//XPfrnI8niJuPSP4Ai1It9iw6Y/4qNbo0EMqfyDnnKVTxP9Iho9qiRGxW PYkK0/Fsd2ekmvwZ8n1EAMaNgJ3BgmzuvHlDfx/ICynhQnzC0ZwH589no5S6qPfUT21f pDBFra5nc6IYaqBp7vxb83UdpSABLAd/gVP3+r3Qg7QP8iV8Ae4n1fAKRjKMJJyiMwCX ZEcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rI1xUe6b; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si6071121ejm.507.2020.08.10.08.22.42; Mon, 10 Aug 2020 08:23:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rI1xUe6b; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbgHJPU5 (ORCPT + 99 others); Mon, 10 Aug 2020 11:20:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:51418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728058AbgHJPUs (ORCPT ); Mon, 10 Aug 2020 11:20:48 -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 F39B02065D; Mon, 10 Aug 2020 15:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597072847; bh=8aTXwZ4opx8LLQJfKMRpxPVdMjiXrdDmraPtP16ipPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rI1xUe6bM4wN1ZsDgcRdEFOGIvkBBqCUZ72mEb/BjXeCfz2tqbSaB9yYVlngMa7Uk sXAFymgT7BEsSaI7M7diFdNkH+VIhW1azV1M/94bNHDhotdsOc3HwTPmbKoDv+BCrM KaYXCgG65kB24wwtIPGz/3EzqOEJl4il4XMeMxpo= 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.8 38/38] arm64: kaslr: Use standard early random function Date: Mon, 10 Aug 2020 17:19:28 +0200 Message-Id: <20200810151805.792836806@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151803.920113428@linuxfoundation.org> References: <20200810151803.920113428@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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;