On 8/29/25 12:54 PM, Siddharth Nayyar wrote: > Read __kflagstab section for vmlinux and modules to determine whether > kernel symbols are GPL only. > > Signed-off-by: Siddharth Nayyar <sidnay...@google.com> > --- > [...] > @@ -2607,6 +2605,7 @@ static int find_module_sections(struct module *mod, > struct load_info *info) > sizeof(*mod->gpl_syms), > &mod->num_gpl_syms); > mod->gpl_crcs = section_addr(info, "__kcrctab_gpl"); > + mod->flagstab = section_addr(info, "__kflagstab"); > > #ifdef CONFIG_CONSTRUCTORS > mod->ctors = section_objs(info, ".ctors",
The module loader should always at least get through the signature and blacklist checks without crashing due to a corrupted ELF file. After that point, the module content is to be trusted, but we try to error out for most issues that would cause problems later on. For __kflagstab, I believe it would be useful to check that the section is present to prevent the code from potentially crashing due to a NULL dereference deep in find_exported_symbol_in_section(). You can rename check_export_symbol_versions() to check_export_symbol_sections() and add the following: if (mod->num_syms && !mod->flagstab) { pr_err("%s: no flags for exported symbols\n", mod->name); return -ENOEXEC; } -- Thanks, Petr