]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
module: deprecate usage of *_gpl sections in module loader
authorSiddharth Nayyar <sidnayyar@google.com>
Thu, 26 Mar 2026 21:25:06 +0000 (21:25 +0000)
committerSami Tolvanen <samitolvanen@google.com>
Tue, 31 Mar 2026 23:42:52 +0000 (23:42 +0000)
The *_gpl section are not being used populated by modpost anymore. Hence
the module loader doesn't need to find and process these sections in
modules.

This patch also simplifies symbol finding logic in module loader since
*_gpl sections don't have to be searched anymore.

Signed-off-by: Siddharth Nayyar <sidnayyar@google.com>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
include/linux/module.h
kernel/module/internal.h
kernel/module/main.c

index 917b29332e15b8911cca9cd51136c56a70b9dcee..7566815fabbe8bb6fb2dd61efe9864f9b3ff2924 100644 (file)
@@ -435,9 +435,6 @@ struct module {
        unsigned int num_kp;
 
        /* GPL-only exported symbols. */
-       unsigned int num_gpl_syms;
-       const struct kernel_symbol *gpl_syms;
-       const u32 *gpl_crcs;
        bool using_gplonly_symbols;
 
 #ifdef CONFIG_MODULE_SIG
index 69b84510e097adc559d5697bd720662a647f93d3..061161cc79d90887e818e879367e67815223c560 100644 (file)
@@ -53,10 +53,7 @@ extern const size_t modinfo_attrs_count;
 /* Provided by the linker */
 extern const struct kernel_symbol __start___ksymtab[];
 extern const struct kernel_symbol __stop___ksymtab[];
-extern const struct kernel_symbol __start___ksymtab_gpl[];
-extern const struct kernel_symbol __stop___ksymtab_gpl[];
 extern const u32 __start___kcrctab[];
-extern const u32 __start___kcrctab_gpl[];
 extern const u8 __start___kflagstab[];
 
 #define KMOD_PATH_LEN 256
index c243d6b79cdd09ad58dc52753655d0caa0033620..c4f7689535165ac0f96742a7d214b256f9c2a76b 100644 (file)
@@ -1495,29 +1495,17 @@ EXPORT_SYMBOL_GPL(__symbol_get);
  */
 static int verify_exported_symbols(struct module *mod)
 {
-       unsigned int i;
        const struct kernel_symbol *s;
-       struct {
-               const struct kernel_symbol *sym;
-               unsigned int num;
-       } arr[] = {
-               { mod->syms, mod->num_syms },
-               { mod->gpl_syms, mod->num_gpl_syms },
-       };
-
-       for (i = 0; i < ARRAY_SIZE(arr); i++) {
-               for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
-                       struct find_symbol_arg fsa = {
-                               .name   = kernel_symbol_name(s),
-                               .gplok  = true,
-                       };
-                       if (find_symbol(&fsa)) {
-                               pr_err("%s: exports duplicate symbol %s"
-                                      " (owned by %s)\n",
-                                      mod->name, kernel_symbol_name(s),
-                                      module_name(fsa.owner));
-                               return -ENOEXEC;
-                       }
+       for (s = mod->syms; s < mod->syms + mod->num_syms; s++) {
+               struct find_symbol_arg fsa = {
+                       .name   = kernel_symbol_name(s),
+                       .gplok  = true,
+               };
+               if (find_symbol(&fsa)) {
+                       pr_err("%s: exports duplicate symbol %s (owned by %s)\n",
+                               mod->name, kernel_symbol_name(s),
+                               module_name(fsa.owner));
+                       return -ENOEXEC;
                }
        }
        return 0;
@@ -2675,12 +2663,15 @@ static int find_module_sections(struct module *mod, struct load_info *info)
        mod->syms = section_objs(info, "__ksymtab",
                                 sizeof(*mod->syms), &mod->num_syms);
        mod->crcs = section_addr(info, "__kcrctab");
-       mod->gpl_syms = section_objs(info, "__ksymtab_gpl",
-                                    sizeof(*mod->gpl_syms),
-                                    &mod->num_gpl_syms);
-       mod->gpl_crcs = section_addr(info, "__kcrctab_gpl");
        mod->flagstab = section_addr(info, "__kflagstab");
 
+       if (section_addr(info, "__ksymtab_gpl"))
+               pr_warn("%s: ignoring obsolete section __ksymtab_gpl\n",
+                       mod->name);
+       if (section_addr(info, "__kcrctab_gpl"))
+               pr_warn("%s: ignoring obsolete section __kcrctab_gpl\n",
+                       mod->name);
+
 #ifdef CONFIG_CONSTRUCTORS
        mod->ctors = section_objs(info, ".ctors",
                                  sizeof(*mod->ctors), &mod->num_ctors);
@@ -2890,8 +2881,7 @@ static int check_export_symbol_sections(struct module *mod)
                return -ENOEXEC;
        }
 #ifdef CONFIG_MODVERSIONS
-       if ((mod->num_syms && !mod->crcs) ||
-           (mod->num_gpl_syms && !mod->gpl_crcs)) {
+       if (mod->num_syms && !mod->crcs) {
                return try_to_force_load(mod,
                                         "no versions for exported symbols");
        }