From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB2C12D02B; Thu, 26 Oct 2023 10:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZyX3dszi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1DD8C433C8; Thu, 26 Oct 2023 10:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698315889; bh=WN2YIA4Ghusd7FbmcNZrWw/oKLuywPkap4tOfxaAQ4k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZyX3dsziPkRUXG2UWwCRe9pQvhY4J8EKCi1UMJicG8n+1K8kuqLhkCHInfodKwhzx IGdZJx3E0WGYfJuhn5slU+daxFVHZfLRqURf8zRCQM4mPgPcJg6TqmPoqs/pWtOypa aGTSZPjPNBzHwtWONSwhXj/25YMcitUcojHP1kRQ49c14Z4eV6Kpw2ampGhmL7G6Sm v7J3Ia4FdxDhFLmdhSb20AH9mufPj5bcJmpVjmk+yiUwvbVfd/gsYS5NT3Ej9E93W4 br849v8H22PcC0TOPiwgXMZFArfvyVNNVM97V2kwDBdHjqJI1bEYt3iRHEo7Tm6Bk9 Y3kn5Rw8Exupg== Date: Thu, 26 Oct 2023 11:24:39 +0100 From: Will Deacon To: Mike Rapoport Cc: linux-kernel@vger.kernel.org, Andrew Morton , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Mark Rutland , Michael Ellerman , Nadav Amit , "Naveen N. Rao" , Palmer Dabbelt , Puranjay Mohan , Rick Edgecombe , Russell King , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v3 04/13] mm/execmem, arch: convert remaining overrides of module_alloc to execmem Message-ID: <20231026102438.GA6924@willie-the-truck> References: <20230918072955.2507221-1-rppt@kernel.org> <20230918072955.2507221-5-rppt@kernel.org> <20231023171420.GA4041@willie-the-truck> <20231026085800.GK2824@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231026085800.GK2824@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) On Thu, Oct 26, 2023 at 11:58:00AM +0300, Mike Rapoport wrote: > On Mon, Oct 23, 2023 at 06:14:20PM +0100, Will Deacon wrote: > > On Mon, Sep 18, 2023 at 10:29:46AM +0300, Mike Rapoport wrote: > > > diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c > > > index dd851297596e..cd6320de1c54 100644 > > > --- a/arch/arm64/kernel/module.c > > > +++ b/arch/arm64/kernel/module.c > > > @@ -20,6 +20,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #include > > > #include > > > @@ -108,46 +109,38 @@ static int __init module_init_limits(void) > > > > > > return 0; > > > } > > > -subsys_initcall(module_init_limits); > > > > > > -void *module_alloc(unsigned long size) > > > +static struct execmem_params execmem_params __ro_after_init = { > > > + .ranges = { > > > + [EXECMEM_DEFAULT] = { > > > + .flags = EXECMEM_KASAN_SHADOW, > > > + .alignment = MODULE_ALIGN, > > > + }, > > > + }, > > > +}; > > > + > > > +struct execmem_params __init *execmem_arch_params(void) > > > { > > > - void *p = NULL; > > > + struct execmem_range *r = &execmem_params.ranges[EXECMEM_DEFAULT]; > > > > > > - /* > > > - * Where possible, prefer to allocate within direct branch range of the > > > - * kernel such that no PLTs are necessary. > > > - */ > > > > Why are you removing this comment? I think you could just move it next > > to the part where we set a 128MiB range. > > Oops, my bad. Will add it back. Thanks. > > > - if (module_direct_base) { > > > - p = __vmalloc_node_range(size, MODULE_ALIGN, > > > - module_direct_base, > > > - module_direct_base + SZ_128M, > > > - GFP_KERNEL | __GFP_NOWARN, > > > - PAGE_KERNEL, 0, NUMA_NO_NODE, > > > - __builtin_return_address(0)); > > > - } > > > + module_init_limits(); > > > > Hmm, this used to be run from subsys_initcall(), but now you're running > > it _really_ early, before random_init(), so randomization of the module > > space is no longer going to be very random if we don't have early entropy > > from the firmware or the CPU, which is likely to be the case on most SoCs. > > Well, it will be as random as KASLR. Won't that be enough? I don't think that's true -- we have the 'kaslr-seed' property for KASLR, but I'm not seeing anything like that for the module randomisation and I also don't see why we need to set these limits so early. Will