diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2026-07-15 14:58:32 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2026-07-15 14:58:32 +0000 |
| commit | 4b0ae7e001a97e5449835bb8a2e6c2e6f53aac39 (patch) | |
| tree | 36558231e0a36d7176ee0e595fc649aaa9b27bd7 | |
| parent | f2202ab5abda7fb09538a1ceda77569b67d83084 (diff) | |
stand: Recognize SHT_INIT_ARRAY sections as constructor sections
Pass such a section to the kernel using modinfo, otherwise link_elf.c
won't execute constructors for the file. This is required for KASAN,
otherwise redzones for global buffers are not poisoned during boot.
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D58244
| -rw-r--r-- | stand/common/load_elf.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index a6ea60c74b84..1c4efb8c4156 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -726,7 +726,8 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_t ef, uint64_t off) if (shstr) { for (i = 0; i < ehdr->e_shnum; i++) { if (strcmp(shstr + shdr[i].sh_name, - ".ctors") != 0) + ".ctors") != 0 && + shdr[i].sh_type != SHT_INIT_ARRAY) continue; ctors = shdr[i].sh_addr; file_addmetadata(fp, MODINFOMD_CTORS_ADDR, |
