From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28AE3C433EF for ; Fri, 24 Jun 2022 13:09:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OKR3zw3BUtv6904/P/vZ4X5itMBNd/fR8aJGfMV0xLE=; b=ZFtaD/+Z381LBB DqTtjQ0qYCuPUTNrlN1/nkxasklsJNY4WVqk1Gq9xN384b9sdNPpUOyyphgqPiIjZ5Komg2Ls5h0l 1Kzd7rG9jvmWR6zHSVUKTcaEpa67RhpIAqD+F4R890WABVzmmjbcjdDEjN1dARlrqT+ah2SQJGcu6 ejSh/j5DND/thQpEyaJ6r5iLjCRjaM/3D+6zNdJP1XXXAcuBmCO/VgmKM+fOqmjFpoFj2HGtwwWBS 546Odqd+Kvqgk5G6h4TkbtqTD9zF6pCiqxIBk0wrypEbreXHUGgyfU3hXw8WqeL2XJsHm1D3kg/od BrPkJsZgvElgGCGkHGZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4j2r-002IU8-K6; Fri, 24 Jun 2022 13:08:21 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4j2n-002ISc-Pj for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2022 13:08:19 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id 43DC5B828CB; Fri, 24 Jun 2022 13:08:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35035C34114; Fri, 24 Jun 2022 13:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656076095; bh=4AmdDL01Va7refTwJZlCJ9hIGQV9z/YdSCEuRy7bdwY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Zpk0wHz6h+9/IWrRuIX1pMGHtQ+r4Bd6dCwZOc4BUP/wJjg46oDhJV5jFTPrCabKt FXuoljEYl08LrhUbzF0vV3jcmhwnwcue4SH/t9Cb82zbhhvSgCP8r4vNPz9F/sV8Ca P8BLNkJMMxWuTMEHtuXNUTp/e8RO3M/SFPzUGo6qV/e3WxUp3yFSzUmZitBGqd3emA m8ciu1ZtPyKg1FeACTTjRjHmCsmszYDgroU3FH+lg+DuhDrPsFrOJcQgiXJXCP2Lmr vdMvm+Pkx6wTYuObax8UDfSnEZVcyU26tmv8ltO3O7ZCUpXiUC8nxZA2G3Za95ITXA 70oCme6I97ILw== Date: Fri, 24 Jun 2022 14:08:09 +0100 From: Will Deacon To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, Marc Zyngier , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown , Anshuman Khandual Subject: Re: [PATCH v4 19/26] arm64: kaslr: defer initialization to late initcall where permitted Message-ID: <20220624130808.GE18561@willie-the-truck> References: <20220613144550.3760857-1-ardb@kernel.org> <20220613144550.3760857-20-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220613144550.3760857-20-ardb@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220624_060818_038489_825F5CCB X-CRM114-Status: GOOD ( 23.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 13, 2022 at 04:45:43PM +0200, Ard Biesheuvel wrote: > The early KASLR init code runs extremely early, and anything that could > be deferred until later should be. So let's defer the randomization of > the module region until much later - this also simplifies the > arithmetic, given that we no longer have to reason about the link time > vs load time placement of the core kernel explicitly. Also get rid of > the global status variable, and infer the status reported by the > diagnostic print from other KASLR related context. > > While at it, get rid of the special case for KASAN without > KASAN_VMALLOC, which never occurs in practice. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/kernel/kaslr.c | 95 +++++++++----------- > 1 file changed, 40 insertions(+), 55 deletions(-) [...] > @@ -163,33 +169,12 @@ u64 __init kaslr_early_init(void) > * when ARM64_MODULE_PLTS is enabled. > */ > module_range = MODULES_VSIZE - (u64)(_etext - _stext); > - module_alloc_base = (u64)_etext + offset - MODULES_VSIZE; > } > > /* use the lower 21 bits to randomize the base of the module region */ > module_alloc_base += (module_range * (seed & ((1 << 21) - 1))) >> 21; > module_alloc_base &= PAGE_MASK; > > - return offset; > -} > - > -static int __init kaslr_init(void) > -{ > - switch (kaslr_status) { > - case KASLR_ENABLED: > - pr_info("KASLR enabled\n"); > - break; > - case KASLR_DISABLED_CMDLINE: > - pr_info("KASLR disabled on command line\n"); > - break; > - case KASLR_DISABLED_NO_SEED: > - pr_warn("KASLR disabled due to lack of seed\n"); > - break; > - case KASLR_DISABLED_FDT_REMAP: > - pr_warn("KASLR disabled due to FDT remapping failure\n"); > - break; > - } > - > return 0; > } > -core_initcall(kaslr_init) > +late_initcall(kaslr_init) Are you sure this isn't too late? I'm nervous that we might have called request_module() off the back of all the other initcalls that we've run by this point. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel