Re: [PATCH] module: .strtab must be null terminated
From: Alexey Dobriyan
Date: Sat Oct 19 2024 - 11:25:40 EST
> + strhdr = &info->sechdrs[info->index.str];
> + if (strhdr->sh_size > 0 && info->strtab[strhdr->sh_size - 1] != '\0') {
> + pr_err("module %s: string table isn't null terminated\n",
> + info->name ?: "(missing .modinfo section or name field)");
> + goto no_exec;
> + }
Reviewed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
The _very_ correct test is "there must be NUL between last index used
and the end of the section somewhere".
.shstrtab has the same overly restrictive test:
if (info->secstrings[strhdr->sh_size - 1] != '\0') {
But, of course, it doesn't matter in practice.