From patchwork Tue Mar 7 14:04:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 65550 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2458015wrd; Tue, 7 Mar 2023 06:23:19 -0800 (PST) X-Google-Smtp-Source: AK7set+tnPBx9XjjviLGfEYTq6Yyro+Ykn2hLe8d0aJQl6Ad7WiVfQjR+ds9Eqta2kyIbdjp7kJw X-Received: by 2002:a05:6a20:a00e:b0:cc:9643:1f8f with SMTP id p14-20020a056a20a00e00b000cc96431f8fmr13501900pzj.13.1678198999424; Tue, 07 Mar 2023 06:23:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678198999; cv=none; d=google.com; s=arc-20160816; b=UH7mrs6q4udllxEeaii+V3yfTM9T7teFFHtjnFSBuPfL2YV1wwtvnQ7UKpNidfDIZe 4hb+kkOYZxlEjc6BgvTAa968plN+j2GQoc+wJfGepBdm9yPTTh1wBjHVEj2uP72f/3Q3 plcAaprkNsPsQ+Ew/Aj64hEbR76htftB1T8kbP7a7j3Hkz2tXfrr2jiTgH06tro5w4un FhutWI/XD0lBmzS2efyPZzyCymcMfM1srsxzvqczI53av9CBixvx82XwWCG35Cyj9JZH Kk8oEAwZS146thupFbnjTYb7zEcdbhA/dqbLH7dh/e+39rEoygTB/6pjdzyynIN3Ua0J ixHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ua9mt+u4GK0JM8cI7wOp549Ob7vNlSyGM/aSfQbOHQ4=; b=klRvbdYTp2If2kZ6JXNpfW06rJCWaRjvObnYNkjqijxAgl/Aq402yau3PcFsDCXi53 GSOl0yOMF7tgDWs5AAN7uVtqAjb8i55Q/wnsooXD7QSscY+JJUDarkscZAFMCg2vW8Ni kjOTcSiTpgsyqQAl+ojTIYL1ZWDBgfTyit+Q2e17140vz1mXZK2PO7iiFCttH+EHyHwx dsuhIdYQxtU8GJvWFwwjBpF5n7uWLIuPUqgMsACsWzTuFkEnurxnOQ1gNCXX8DpVTb6+ VaeIKqJ03RpssTWtg37w7Sz0nn7NrrLZNsgvdzO8etVBJOA+rwuDJcxGhX9k/DZo4Ayf BYxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YG60S4NT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j62-20020a638b41000000b00507281fb21fsi9698390pge.557.2023.03.07.06.23.06; Tue, 07 Mar 2023 06:23:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YG60S4NT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbjCGOGy (ORCPT + 99 others); Tue, 7 Mar 2023 09:06:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbjCGOGs (ORCPT ); Tue, 7 Mar 2023 09:06:48 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02F0D83143 for ; Tue, 7 Mar 2023 06:06:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 05D1BCE1BDF for ; Tue, 7 Mar 2023 14:06:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 282A4C433A7; Tue, 7 Mar 2023 14:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678198003; bh=zTJJcfi4SEXlPHHgiZzEiE+Bb8xBDVbYVHpApgM1uRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YG60S4NTJZYgf3VEsEcTvEU1ODazqeuMok+heVfq9BEVOpoLLoRlc+L36ndWed+Vd Y/kNnRROpeBA4CAZPt2aPeEnf7Y4IpJ4veTA5A3sb0Ooe9ey1J90gXWhIdK6FBiyHD ndoaG1DMjk0mbVAu3oKL8bXI3aPjCvMWiP6amOjD9EdXwwahb+svONi2hfby7rJupk m00Mp4wQ6WE3qMqPcAauZnNujdlPUJnuGVA4mgZKkismjjOa+G3aWrGaKxfPtdtL0j CJ6VCR1V03Z3EdfcAog4jL4BorLGM0tiu0r1pIi0gyVOFefQk13K1z0R5Ulz/XK/PC gPPE/c6iQ0/+w== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: [PATCH v3 02/60] arm64: mm: Take potential load offset into account when KASLR is off Date: Tue, 7 Mar 2023 15:04:24 +0100 Message-Id: <20230307140522.2311461-3-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307140522.2311461-1-ardb@kernel.org> References: <20230307140522.2311461-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1054; i=ardb@kernel.org; h=from:subject; bh=zTJJcfi4SEXlPHHgiZzEiE+Bb8xBDVbYVHpApgM1uRw=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIYXdhVFh1hf+2B0Xupfde1M390PLw8mn1ebfWHuToyHbc Fq5zt61HaUsDGIcDLJiiiwCs/++23l6olSt8yxZmDmsTCBDGLg4BWAiAnoM/z0bzqXare9T+fh1 5b5a0ZvP995afGTb08qvjU+PhqrP+/OdkaHl1UefP3x2TjnRh8vj1xS7zA3frX5Bc+4bqdrH+t+ s1VgA X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759719194118634382?= X-GMAIL-MSGID: =?utf-8?q?1759719194118634382?= We enable CONFIG_RELOCATABLE even when CONFIG_RANDOMIZE_BASE is disabled, and this permits the loader (i.e., EFI) to place the kernel anywhere in physical memory as long as the base address is 64k aligned. This means that the 'KASLR' case described in the header that defines the size of the statically allocated page tables could take effect even when CONFIG_RANDMIZE_BASE=n. So check for CONFIG_RELOCATABLE instead. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/kernel-pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h index fcd14197756f0619..4d13c73171e1e360 100644 --- a/arch/arm64/include/asm/kernel-pgtable.h +++ b/arch/arm64/include/asm/kernel-pgtable.h @@ -53,7 +53,7 @@ * address is just pushed over a boundary and the start address isn't). */ -#ifdef CONFIG_RANDOMIZE_BASE +#ifdef CONFIG_RELOCATABLE #define EARLY_KASLR (1) #else #define EARLY_KASLR (0)