Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp324675rdh; Thu, 26 Oct 2023 03:25:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn0nq+eQCmQ93kkWyH2EgUHqAODdRXI2sD5FtIqjOfmzZZ0l8Mq97qfnBcPqr+7o5lQDDO X-Received: by 2002:a25:a28e:0:b0:d9a:52dc:15d6 with SMTP id c14-20020a25a28e000000b00d9a52dc15d6mr3855314ybi.2.1698315915296; Thu, 26 Oct 2023 03:25:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698315915; cv=none; d=google.com; s=arc-20160816; b=vStWqhokv5THacFTfsiT9yKnANK/T/fPW9jgfgcorPPrYVfB7HteS2ibnQ3/UpUNR9 xL9BT1pMrp5905yxqzBw3GaBMKYtq08Xy2RQWqS8BQvLOSIOn/HiwgwtB+uAxe50SMmf JqUshfebaMJSBkdLyOauiJx8ECFI/WHrxc777ahlg0fcvzJGP1sqBoOLS3tR9KRy2T5R FbyiTpyitCKhxjAt5Ywe8jFLq8MXficERlGpak0uZ+Q/wd26FUAk0otDny6Vc0VySuKi rDRcFHjduLKolkyPFqXwxPC3aS5s22JHHpGMJ1fQ7E6fDfcb2MmRHO8zZa2sIv+oASM1 5yCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=IYuWW2mai+mszjKM9HqrM4yCjQ9Ykqq12Al635QJOZM=; fh=OJK98ATgFJmfCN0gRmseDUU5URm5/2Pk0J7JwopS/Jo=; b=ogWjr1I0L0WxPg5FGpYzSQmSaPgP8iN5Fn7c7QuoOU/FZK7SZRfnavXmy4kGG7Qenw K3SLtD8/dn5Vj18Hg9iJbteJ9bWqgQBTSVhjDe8P/asUvcvGRstMxmvfSPgZ0MqRcltp xUK5V4TmigexIQAS6FxTDicXLiYNNpVgYrXOYh6xdT+oNyGtnxWRjpb65hcu4aZA/Rn+ TdqZhbom90nsYdONW4QJ7pMGaUAozH/nz+nM/f0WQSV2N/TRKURUnP8BziDEdJqs1Zh1 RZiWeaUVcnzTxKpMIAiSLnYT+rWFbumQTpjSp0A/RZBRR4uddJLSUdDyJaTJ3cFFg2Gd 5cLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZyX3dszi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id p63-20020a252942000000b00d9a4cbda9bfsi13855138ybp.173.2023.10.26.03.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 03:25:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZyX3dszi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9BEBE8135CF1; Thu, 26 Oct 2023 03:25:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234893AbjJZKYw (ORCPT + 99 others); Thu, 26 Oct 2023 06:24:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbjJZKYv (ORCPT ); Thu, 26 Oct 2023 06:24:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C66A4DC; Thu, 26 Oct 2023 03:24:49 -0700 (PDT) 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> 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) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 26 Oct 2023 03:25:12 -0700 (PDT) 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