Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp386958rdb; Thu, 5 Oct 2023 08:42:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXKkR6uE7TgOBttC6yXssRi3Q0q6z0r9hH82wXvE10e4cQmLa/zek0VwDB2yQsp2vSKKaZ X-Received: by 2002:a05:6a21:6d9f:b0:13a:dd47:c31a with SMTP id wl31-20020a056a216d9f00b0013add47c31amr2515652pzb.20.1696520562870; Thu, 05 Oct 2023 08:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696520562; cv=none; d=google.com; s=arc-20160816; b=ceWqpeIAvc0wKPVok4HIT42YOMZsj8cN6wH1me7gIS9D47C+iuxCbXWs6X0G1Uy68c HQaL7C4HboKQbhozowK1+Dr8FcA4XrLcSG5toivDPYmkv9VWitgEkVApSF6+3JQsduV4 RQJiiyt4DMDQZ+er1LGD6OxSlmxHzALwz3VZJdP/LZ6GfgI+Fvfon436kOUjxsg1RPmp tvj/0cWtARamo2goeziDQswaMl/mJ5gaK3tye6KjqmMRmTPp8/1nozVazKRVv8nGXmTY W5hZT4EBtNG9Jt3oC+uRsdzKYDIPh+J7pqduSf0goxKHEL82cm9AvESvBSjyEZ7E5lLr 7TTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nAf5AvqwiVW1SB2iAUKfakH3uyPakHpyUVR2NXft5Bw=; fh=z75Quz749aXkDGKyaGa5Wu4WfeH0RiIlZveyJlGkKkI=; b=Bs8MW9zbp+YuluD7MPqAY0obmpHysNZdsJwpLmpVZR+fvIxH5QCjEJejQa39jfKSh5 Kj3JJZJrKwU/lAnp/dGXjctxABx52WgX9wd+eoSt1s/5DXRk//nHJQpno9DHZRsE/hVE eCWZoqPS3g7iFDY79iTEVzg/JHXs9vVB6bLQEJPWyq9Itq7EJ9smkG9mY+CUYMwPosvT uaOd/a+DFgRrj+ug+unUqLhCk7DCXq/1oYYKQbsKngMY7k66VrDobR0FpwrXbPVB3ZUN cGWwPe7u1uekKB5E9rZ4WYmfmdTnT/fUxFtpkmurvOHKSVOzCAhSX9GJSHva/MmcEdxP mfSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=htbvcSdK; 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 m24-20020a637d58000000b0056949c3eda8si1708389pgn.119.2023.10.05.08.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:42:42 -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=htbvcSdK; 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 9A843824197C; Thu, 5 Oct 2023 08:42:40 -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 S233834AbjJEPm0 (ORCPT + 99 others); Thu, 5 Oct 2023 11:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234164AbjJEPmJ (ORCPT ); Thu, 5 Oct 2023 11:42:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6192569226; Thu, 5 Oct 2023 07:57:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CBD6C433CC; Thu, 5 Oct 2023 05:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696483777; bh=0Btg3YXrlgdZvN9c5GBtYXuhH18hqWIB+5O6R7ueqJA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=htbvcSdKFwWteJskCo57Zoc+HETH4Yk4itDoLxeJ1ZG4lHI/6dRpo8c5g9SXm397o Eun4d3xnthNfZVwdWsofKvM4QWBVN4HTm3hLqzLiQBrntUL8UgEGY5xtChyLJeLSvA +kiu09tPGlxznwtPobf/uLurpuN8CBF2/SLMhDWs179ymyb2Urny866sSuGF/ojv6+ iWewEluv5jVsvROGeyy57su15Hs4TbNbwzhji63ZqwBfc3BmxOSDIm1/YBjJDN2t9v ZHq7tnS5BF0NS66xJ3m6K4ABlSRKqepeLUIUEhNo390B9QIPXevXF5ZN3BxZUTA4Ed Ef2zRBvRZ4gnQ== Date: Thu, 5 Oct 2023 08:28:24 +0300 From: Mike Rapoport To: "Edgecombe, Rick P" Cc: "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "deller@gmx.de" , "mcgrof@kernel.org" , "bjorn@kernel.org" , "davem@davemloft.net" , "nadav.amit@gmail.com" , "linux@armlinux.org.uk" , "netdev@vger.kernel.org" , "linux-mips@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "hca@linux.ibm.com" , "catalin.marinas@arm.com" , "kent.overstreet@linux.dev" , "puranjay12@gmail.com" , "palmer@dabbelt.com" , "linux-s390@vger.kernel.org" , "chenhuacai@kernel.org" , "tsbogend@alpha.franken.de" , "linux-trace-kernel@vger.kernel.org" , "mpe@ellerman.id.au" , "linux-parisc@vger.kernel.org" , "x86@kernel.org" , "mark.rutland@arm.com" , "christophe.leroy@csgroup.eu" , "linuxppc-dev@lists.ozlabs.org" , "rostedt@goodmis.org" , "will@kernel.org" , "dinguyen@kernel.org" , "naveen.n.rao@linux.ibm.com" , "sparclinux@vger.kernel.org" , "linux-modules@vger.kernel.org" , "bpf@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "song@kernel.org" , "linux-mm@kvack.org" , "loongarch@lists.linux.dev" , "akpm@linux-foundation.org" Subject: Re: [PATCH v3 04/13] mm/execmem, arch: convert remaining overrides of module_alloc to execmem Message-ID: <20231005052824.GE3303@kernel.org> References: <20230918072955.2507221-1-rppt@kernel.org> <20230918072955.2507221-5-rppt@kernel.org> <3483c4712306060ac56f07f5db9b146d69fc7e9e.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3483c4712306060ac56f07f5db9b146d69fc7e9e.camel@intel.com> 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, 05 Oct 2023 08:42:40 -0700 (PDT) On Wed, Oct 04, 2023 at 12:29:36AM +0000, Edgecombe, Rick P wrote: > On Mon, 2023-09-18 at 10:29 +0300, Mike Rapoport wrote: > > diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c > > index 5f71a0cf4399..9d37375e2f05 100644 > > --- a/arch/x86/kernel/module.c > > +++ b/arch/x86/kernel/module.c > > > > -void *module_alloc(unsigned long size) > > +struct execmem_params __init *execmem_arch_params(void) > > ?{ > > -???????gfp_t gfp_mask = GFP_KERNEL; > > -???????void *p; > > - > > -???????if (PAGE_ALIGN(size) > MODULES_LEN) > > -???????????????return NULL; > > +???????unsigned long module_load_offset = 0; > > +???????unsigned long start; > > ? > > -???????p = __vmalloc_node_range(size, MODULE_ALIGN, > > -??????????????????????????????? MODULES_VADDR + > > get_module_load_offset(), > > -??????????????????????????????? MODULES_END, gfp_mask, PAGE_KERNEL, > > -??????????????????????????????? VM_FLUSH_RESET_PERMS | > > VM_DEFER_KMEMLEAK, > > -??????????????????????????????? NUMA_NO_NODE, > > __builtin_return_address(0)); > > +???????if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_enabled()) > > +???????????????module_load_offset = > > +???????????????????????get_random_u32_inclusive(1, 1024) * > > PAGE_SIZE; > > Minor: > I think you can skip the IS_ENABLED(CONFIG_RANDOMIZE_BASE) part because > CONFIG_RANDOMIZE_MEMORY depends on CONFIG_RANDOMIZE_BASE (which is > checked in kaslr_enabled()). Thanks, I'll look into it. -- Sincerely yours, Mike.