From patchwork Fri Aug 7 14:45:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 11705805 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 528001392 for ; Fri, 7 Aug 2020 14:45:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C2542075D for ; Fri, 7 Aug 2020 14:45:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bjYPnIbi"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eyy7A/8g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C2542075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=lBM9HdezUPx43mpVC+wAHiJlmU6/Y6scysxSdQqmtCc=; b=bjYPnIbiTSYqSwPkMYG2xrtzJ/ sG4L1JBhcZbrLEOlsYGtHxqaqVwJ74uuKpQlreiuMoXxnWEayyfSmw4ewNVjzAc3pYsn49E4CnJXR ll0oHdwboy+dgWQHOABhh/LWI++8MBsMjjifKrM+PfDJBNtAs+bPi+WbWAdTEkJ/F96EELqhxvM5I AZ0ZarHQHAFodBLoSoSL9vUV6teYBm6q9NyKC6rgGWDJLapkeYRhlaQaqkevV4cBQsS1LeDS3JNmZ R/cK45+h+jeRTPYozhHQWL5FIMWh66Adf/UU7hNKkaV8jExqqWfFcIzNx1CBDA2QIbN7bANfFT9HT TWY2AXEw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k43ce-0000N4-Pv; Fri, 07 Aug 2020 14:45:28 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k43cc-0000MQ-DA for linux-arm-kernel@lists.infradead.org; Fri, 07 Aug 2020 14:45:27 +0000 Received: by mail-pf1-x442.google.com with SMTP id m71so708408pfd.1 for ; Fri, 07 Aug 2020 07:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=zxXsF5v4kySUXX8zekd8kr4bDxHN8XmHqdakABYtG0g=; b=eyy7A/8gb8nHja2j11uzp8oHZ6E98tg2hH3eO0ZwrKbQ5UQaOFP/jzDAL3HpSDSQ7V 6z5ODYeZkmoyziFq6M7nb2plZ4qEbXU5fltUB6mNKaQ+dsXl2D0nX1SKPZR+1uIahI3F tiuPMoX909fG7aaNDcVG5PhBNUl/s9UwT+ncsjw4F4uhupZgEbiBv2e49aZXwFGWJSYs 3IOCjNvoX+dLw850w7iRmno/uWfSSOlMAaRKYHBnJ7aWk2haScLlboEs9vTq+TabeVs+ wvHE54nzX0yZi2FsqOxykr08hJiB5RujuDmU3VDf5x+B4tXF7lfINJhbJfviaXHhgvRO 1NDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=zxXsF5v4kySUXX8zekd8kr4bDxHN8XmHqdakABYtG0g=; b=oWkSMYOEnFfY+7D7NHDkKUrnrPlemigIe8LTGc2x9bDvaybS3WxVN3iW3Jpzz1h4uq gkj6mHNO44PzQdKA23/FCiT3eP03uiv+jDO1ngLtoU+NiR2LyjtKZgy4qDXUdrQZv+i3 4mdFepVcYG4kJH5oNxeh8bhi0ud8V/0EGpe1VBb5IcZWePL1FiuAiCGZFG62g3PkMU1e TV9jcM92im+G0CSxrUsX32sa8amu81mhuDRWIrn0GEdD7To87upBwu9NX9jTE0xgArTY Um4N1C3XJWWKXTmYvj1vqOBVzzEvpfmT0SNH56akjgfPr3VhaIxtUAMsE8qN1gx0COqN 46sg== X-Gm-Message-State: AOAM5322pSqZCKZaCItj24oLDA+yk1mnVmSGBxR2uj2NRScecUG+BK48 jeXjLNTgcymeSzjGsfWT2Sw= X-Google-Smtp-Source: ABdhPJwCUSP9BQrZXdhJpcJmeIwQobyUtdREgxCv7vpjeBZ9e3qvFLc520Ft6/bc1SXVUS9ygapc2w== X-Received: by 2002:a62:830d:: with SMTP id h13mr13130034pfe.269.1596811524143; Fri, 07 Aug 2020 07:45:24 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b23sm5730657pfo.12.2020.08.07.07.45.23 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 07:45:23 -0700 (PDT) From: Guenter Roeck To: Linus Torvalds Subject: [PATCH v2] arm64: kaslr: Use standard early random function Date: Fri, 7 Aug 2020 07:45:21 -0700 Message-Id: <20200807144521.34732-1-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200807_104526_471070_962456BC X-CRM114-Status: GOOD ( 15.80 ) X-Spam-Score: 0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [groeck7[at]gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [groeck7[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:442 listed in] [list.dnswl.org] 0.0 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_D=C3=ADaz?= , tytso@mit.edu, Catalin Marinas , linux-kernel@vger.kernel.org, Mark Brown , Qian Cai , Guenter Roeck , Will Deacon , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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)) ^~~~~~~~~~~~ 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 Acked-by: Catalin Marinas --- v2: Added Reviewed-by: and Tested-by: tags Removed comment about side effect (it wasn't correct; code functionality is the same) Removed second Fixes: tag (did not apply) arch/arm64/kernel/kaslr.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c index 9ded4237e1c1..b181e0544b79 100644 --- 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;