aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2024-03-31 18:14:02 +0000
committerMark Johnston <markj@FreeBSD.org>2024-03-31 18:15:11 +0000
commit7ef5c19b219e47684afd9d8d9126df39edc8d885 (patch)
tree9a79112cdbb4c98691bcd54a6a1c8fce8045f983 /sys/kern/kern_linker.c
parent43b4da44118e4fe29e9d7456db4390c9cbb53636 (diff)
downloadsrc-7ef5c19b219e47684afd9d8d9126df39edc8d885.tar.gz
src-7ef5c19b219e47684afd9d8d9126df39edc8d885.zip
kern linker: Don't invoke dtors without having invoked ctors
I have a kernel module which fails to load because of an unrecognized relocation type. link_elf_load_file() fails before the module's ctors are invoked and it calls linker_file_unload(), which causes the module's dtors to be executed, resulting in a kernel panic. Add a flag to the linker file to ensure that dtors are not invoked if unloading due to an error prior to ctors being invoked. At the moment I only implemented this for link_elf_obj.c since link_elf.c doesn't invoke dtors, but I refactored link_elf.c to make them more similar. Fixes: 9e575fadf491 ("link_elf_obj: Invoke fini callbacks") Reviewed by: zlei, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44559
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 54b7466124db..08b85867d781 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -657,6 +657,7 @@ linker_make_file(const char *pathname, linker_class_t lc)
return (NULL);
lf->ctors_addr = 0;
lf->ctors_size = 0;
+ lf->ctors_invoked = LF_NONE;
lf->dtors_addr = 0;
lf->dtors_size = 0;
lf->refs = 1;