Received: by 2002:a05:7412:a9a3:b0:f9:93eb:408e with SMTP id o35csp68484rdh; Wed, 20 Dec 2023 23:25:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEp0nzwNg/BTXmhNcJsxMvvO9uLGhTvgd69Y3Chbc2zaJpEMZNBKGog+BN5L+sq6W0GVR5 X-Received: by 2002:a05:6a20:7491:b0:18f:97c:3856 with SMTP id p17-20020a056a20749100b0018f097c3856mr341765pzd.48.1703143537260; Wed, 20 Dec 2023 23:25:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703143537; cv=none; d=google.com; s=arc-20160816; b=lFtYBzoV83kA6V7Z4uffeg2ttUq9x4AILIgpMxDxOPduqslTZhSh4I6UOI4VuFkISq iHnGPmuk3QBS4LzqB2g3tZJUQZ/kSqPHXnQ5N86S3dMSRiRMWtuLxRamihUUXvo0G0Na ylKyjCBJsEHwlb6T31Qy/VOL9Pvc59m9b/BAC8TdJBjXisQ7VmbgYUyeEBTK73YXcKbb b2Hii0BOuxm+KZOw/tAkr5Jv9xgp/+Nt2ATv7wl2fTRuz6vV+5Pe1ZT43oN+0aVYO3eU KWvw7MnVmftPY1OPmjyGECV3BOE0LWyRVGSGUUXbGJMt5cCsDXDFRWIT0aAeTD+94hPc sOqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=3Qc/74uLXEwXFA97KYAhkbtjdgUadsJ57ViXLq1y580=; fh=3Rmw3hrCZr4/YM66VoDQzei5WEe1xbduHySxKhuslJo=; b=A02b/drSj8Kz6zfoNps4bOQyoB/2KRS3NyGjaSLcNcPKWTRLGCHUuztgiWO+jhzqXJ /ffnzARXlQM8APc0Mg9IviSWl+yID+wtSamI2Po5TxxDMsJ4eNJ65n5iNeXLUf2CR/cF c9L/TzzqsWhQeQYt25Xi5WBfH0Vqdr3FuHwJ54/0iaP5GM9AbmRMOfAmzgzecqYFBAOb svLhGhSi9Zo0CUGHZtfRD2ozleh4Uw2MzIojg8e0Or4KRPMDPIr+RAkU7juX5h8knlxy m2z73ftdFVFnZjlwsJGDEFUygb+rURh4Py8wUSmGO0i74OMHt56CjQggMXzoc/6EF275 A3OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=csgroup.eu Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l126-20020a632584000000b005cd9e9928e9si1130379pgl.749.2023.12.20.23.25.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 23:25:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=csgroup.eu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 40368B2509C for ; Thu, 21 Dec 2023 07:25:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA684156CE; Thu, 21 Dec 2023 07:24:41 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) (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 B08C9154B1; Thu, 21 Dec 2023 07:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4Swhl00jRsz9v53; Thu, 21 Dec 2023 08:24:28 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yYf08Ml6v6m5; Thu, 21 Dec 2023 08:24:28 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4Swhl005W9z9syd; Thu, 21 Dec 2023 08:24:28 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id F34738B78B; Thu, 21 Dec 2023 08:24:27 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Y0itt8VriYQB; Thu, 21 Dec 2023 08:24:27 +0100 (CET) Received: from PO20335.idsi0.si.c-s.fr (PO25106.IDSI0.si.c-s.fr [192.168.232.169]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9F0148B765; Thu, 21 Dec 2023 08:24:27 +0100 (CET) From: Christophe Leroy To: Luis Chamberlain , linux-modules@vger.kernel.org Cc: Christophe Leroy , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] module: Change module_enable_{nx/x/ro}() to more explicit names Date: Thu, 21 Dec 2023 08:24:24 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <98d4db94f19737fe05fd811a4188ff277b83a334.1703143382.git.christophe.leroy@csgroup.eu> References: <98d4db94f19737fe05fd811a4188ff277b83a334.1703143382.git.christophe.leroy@csgroup.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1703143462; l=3472; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=QFcBndRL8VAEfnsHhYaocMTU1i5wqmmzuLoeFYit1jY=; b=mmMFRfmWA3N5AicawGZ2q8ic238QubUvcwoK3wBNSpTd4IzuWi+BuY8efN1QsoMzFWMTQdjGD Z0nhzzvU2EFBQqK2TTwA+X7L4M0flrwFwHygqSAe2b6YX4bjL00i2Qq X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit It's a bit puzzling to see a call to module_enable_nx() followed by a call to module_enable_x(). This is because one applies on text while the other applies on data. Change name to make that more clear. Signed-off-by: Christophe Leroy --- kernel/module/internal.h | 6 +++--- kernel/module/main.c | 8 ++++---- kernel/module/strict_rwx.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/module/internal.h b/kernel/module/internal.h index a647ab17193d..4f1b98f011da 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -322,9 +322,9 @@ static inline struct module *mod_find(unsigned long addr, struct mod_tree_root * } #endif /* CONFIG_MODULES_TREE_LOOKUP */ -void module_enable_ro(const struct module *mod, bool after_init); -void module_enable_nx(const struct module *mod); -void module_enable_rox(const struct module *mod); +void module_enable_rodata_ro(const struct module *mod, bool after_init); +void module_enable_data_nx(const struct module *mod); +void module_enable_text_rox(const struct module *mod); int module_enforce_rwx_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, char *secstrings, struct module *mod); diff --git a/kernel/module/main.c b/kernel/module/main.c index 1c8f328ca015..64662e55e275 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2568,7 +2568,7 @@ static noinline int do_init_module(struct module *mod) /* Switch to core kallsyms now init is done: kallsyms may be walking! */ rcu_assign_pointer(mod->kallsyms, &mod->core_kallsyms); #endif - module_enable_ro(mod, true); + module_enable_rodata_ro(mod, true); mod_tree_remove_init(mod); module_arch_freeing_init(mod); for_class_mod_mem_type(type, init) { @@ -2733,9 +2733,9 @@ static int complete_formation(struct module *mod, struct load_info *info) module_bug_finalize(info->hdr, info->sechdrs, mod); module_cfi_finalize(info->hdr, info->sechdrs, mod); - module_enable_ro(mod, false); - module_enable_nx(mod); - module_enable_rox(mod); + module_enable_rodata_ro(mod, false); + module_enable_data_nx(mod); + module_enable_text_rox(mod); /* * Mark state as coming so strong_try_module_get() ignores us, diff --git a/kernel/module/strict_rwx.c b/kernel/module/strict_rwx.c index 9345b09f28a5..9b2d58a8d59d 100644 --- a/kernel/module/strict_rwx.c +++ b/kernel/module/strict_rwx.c @@ -26,7 +26,7 @@ static void module_set_memory(const struct module *mod, enum mod_mem_type type, * CONFIG_STRICT_MODULE_RWX because they are needed regardless of whether we * are strict. */ -void module_enable_rox(const struct module *mod) +void module_enable_text_rox(const struct module *mod) { for_class_mod_mem_type(type, text) { if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) @@ -36,7 +36,7 @@ void module_enable_rox(const struct module *mod) } } -void module_enable_ro(const struct module *mod, bool after_init) +void module_enable_rodata_ro(const struct module *mod, bool after_init) { if (!IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) return; @@ -52,7 +52,7 @@ void module_enable_ro(const struct module *mod, bool after_init) module_set_memory(mod, MOD_RO_AFTER_INIT, set_memory_ro); } -void module_enable_nx(const struct module *mod) +void module_enable_data_nx(const struct module *mod) { if (!IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) return; -- 2.41.0