Skip to contentSkip to conversation

modpost: Initialize builtin_modname to stop SIGSEGVs

PATCH Applied Hugh Dickins 3 participants 3 messages Sep 28, 2025 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modpost: Initialize builtin_modname to stop SIGSEGVs

Segmentation fault ./scripts/mod/modpost -o vmlinux.symvers vmlinux.o stops the kernel build. It comes when write_vmlinux_export_c_file() tries to buf_printf alias->builtin_modname. malloc'ed memory is not necessarily zeroed. NULL new->builtin_modname before adding to aliases.

Fixes 5ab23c7923a1 ("modpost: Create modalias for builtin modules")
---
 scripts/mod/file2alias.c | 1 +
 1 file changed, 1 insertion(+)
scripts/mod/file2alias.c +1 -0
index 7da9735e7ab3..b3333560b95e 100644
@@ -94,6 +94,7 @@ module_alias_printf(struct module *mod, bool append_wildcard,
 		}
 	}
 
+	new->builtin_modname = NULL;
 	list_add_tail(&new->node, &mod->aliases);
 }
 
Signature · 1 line
2.48.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Hugh Dickins

Segmentation fault ./scripts/mod/modpost -o vmlinux.symvers vmlinux.o stops the kernel build. It comes when write_vmlinux_export_c_file() tries to buf_printf alias->builtin_modname. malloc'ed memory is not necessarily zeroed. NULL new->builtin_modname before adding to aliases.

Fixes 5ab23c7923a1 ("modpost: Create modalias for builtin modules")
---
 scripts/mod/file2alias.c | 1 +
 1 file changed, 1 insertion(+)
scripts/mod/file2alias.c +1 -0
index 7da9735e7ab3..b3333560b95e 100644
@@ -94,6 +94,7 @@ module_alias_printf(struct module *mod, bool append_wildcard,
 		}
 	}
 
+	new->builtin_modname = NULL;
 	list_add_tail(&new->node, &mod->aliases);
 }
 
Signature · 1 line
2.48.2

Thanks!

Signature · 1 line
Nicolas
maintainer Applied
#2 lore raw
In reply to Hugh Dickins
Quoted 6 lines · Hugh Dickins

Segmentation fault ./scripts/mod/modpost -o vmlinux.symvers vmlinux.o stops the kernel build. It comes when write_vmlinux_export_c_file() tries to buf_printf alias->builtin_modname. malloc'ed memory is not necessarily zeroed. NULL new->builtin_modname before adding to aliases.

Applied, thanks!

[1/1] modpost: Initialize builtin_modname to stop SIGSEGVs

      https://git.kernel.org/kbuild/c/2ea77fca84f07

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>