Hi Alexander,
I'm OK with your code modifications, however I have one question,
should we deal with the new __kflagstab section introduced by the
kernel commit? I haven't dive deep into the kernel implementation, but
just curious since the *_gpl sections are removed, how should we
handle those symbols which used to belong to the section, will they be
handled within the non gpl section(so no extra code change for crash),
or handled within the new __kflagstab section(thus extra code change
for crash is needed)?
Thanks,
Tao Liu
On Tue, Apr 28, 2026 at 10:16 PM Alexander Egorenkov
<egorenar(a)linux.ibm.com> wrote:
The commit b4760ff2a5e4 ("module: deprecate usage of *_gpl sections in module
loader")
eliminated separate GPL symbol sections representing GPL only symbols.
Therefore, depending on whether the member gpl_syms is present
in struct module, decide whether GPL module symbols are separated or not.
https://lore.kernel.org/all/20260326-kflagstab-v5-4-fa0796fe88d9@google.com
Signed-off-by: Alexander Egorenkov <egorenar(a)linux.ibm.com>
---
kernel.c | 13 ++++++++-----
symbols.c | 9 +++++++--
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/kernel.c b/kernel.c
index 8781d6a22414..35e6fd61f077 100644
--- a/kernel.c
+++ b/kernel.c
@@ -3634,9 +3634,11 @@ module_init(void)
case KMOD_V2:
MEMBER_OFFSET_INIT(module_num_syms, "module",
"num_syms");
MEMBER_OFFSET_INIT(module_list, "module", "list");
- MEMBER_OFFSET_INIT(module_gpl_syms, "module",
"gpl_syms");
- MEMBER_OFFSET_INIT(module_num_gpl_syms, "module",
- "num_gpl_syms");
+ if (MEMBER_EXISTS("module", "gpl_syms")) {
+ MEMBER_OFFSET_INIT(module_gpl_syms, "module",
"gpl_syms");
+ MEMBER_OFFSET_INIT(module_num_gpl_syms, "module",
+ "num_gpl_syms");
+ }
if (MEMBER_EXISTS("module", "mem")) { /* 6.4 and
later */
kt->flags2 |= KMOD_MEMORY; /* MODULE_MEMORY() can be
used. */
@@ -3830,8 +3832,9 @@ module_init(void)
nsyms = UINT(modbuf + OFFSET(module_nsyms));
break;
case KMOD_V2:
- nsyms = UINT(modbuf + OFFSET(module_num_syms)) +
- UINT(modbuf + OFFSET(module_num_gpl_syms));
+ nsyms = UINT(modbuf + OFFSET(module_num_syms));
+ if (VALID_MEMBER(module_num_gpl_syms))
+ nsyms += UINT(modbuf + OFFSET(module_num_gpl_syms));
break;
}
diff --git a/symbols.c b/symbols.c
index e6865cabef74..7b00e26ab0cf 100644
--- a/symbols.c
+++ b/symbols.c
@@ -1976,9 +1976,14 @@ store_module_symbols_6_4(ulong total, int mods_installed)
"module buffer", FAULT_ON_ERROR);
syms = ULONG(modbuf + OFFSET(module_syms));
- gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
nsyms = UINT(modbuf + OFFSET(module_num_syms));
- ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
+ if (VALID_MEMBER(module_gpl_syms)) {
+ gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
+ ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
+ } else {
+ gpl_syms = 0;
+ ngplsyms = 0;
+ }
nksyms = UINT(modbuf + OFFSET(module_num_symtab));
--
2.51.0