[PATCH next] modpost: Initialize builtin_modname to stop SIGSEGVs

Hugh Dickins posted 1 patch 3 days, 15 hours ago
scripts/mod/file2alias.c | 1 +
1 file changed, 1 insertion(+)
[PATCH next] modpost: Initialize builtin_modname to stop SIGSEGVs
Posted by Hugh Dickins 3 days, 15 hours ago
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")
Signed-off-by: Hugh Dickins <hughd@google.com>
---
 scripts/mod/file2alias.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 7da9735e7ab3..b3333560b95e 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -94,6 +94,7 @@ module_alias_printf(struct module *mod, bool append_wildcard,
 		}
 	}
 
+	new->builtin_modname = NULL;
 	list_add_tail(&new->node, &mod->aliases);
 }
 
-- 
2.48.2
Re: [PATCH next] modpost: Initialize builtin_modname to stop SIGSEGVs
Posted by Nathan Chancellor 3 days, 8 hours ago
On Sat, 27 Sep 2025 21:28:06 -0700, Hugh Dickins wrote:
> 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,
-- 
Nathan Chancellor <nathan@kernel.org>
Re: [PATCH next] modpost: Initialize builtin_modname to stop SIGSEGVs
Posted by Nicolas Schier 3 days, 14 hours ago
On Sat, Sep 27, 2025 at 09:28:06PM -0700, Hugh Dickins wrote:
> 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")
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
>  scripts/mod/file2alias.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> index 7da9735e7ab3..b3333560b95e 100644
> --- a/scripts/mod/file2alias.c
> +++ b/scripts/mod/file2alias.c
> @@ -94,6 +94,7 @@ module_alias_printf(struct module *mod, bool append_wildcard,
>  		}
>  	}
>  
> +	new->builtin_modname = NULL;
>  	list_add_tail(&new->node, &mod->aliases);
>  }
>  
> -- 
> 2.48.2

Thanks!

Reviewed-by: Nicolas Schier <nsc@kernel.org>

-- 
Nicolas