Re: panic booting with if_tap_load="YES" in loader.conf

From: Mark Johnston <markj_at_freebsd.org>
Date: Sat, 18 May 2019 01:33:28 -0400
On Fri, May 17, 2019 at 10:18:57PM -0600, Rebecca Cran wrote:
> I just updated from r346856 to r347950 and ran into a new panic, caused
> by having if_tap_load="YES" in /boot/loader.conf - because it's already
> built-in to the kernel:

I think this patch should fix the panic, but I only compile-tested it.
I considered having the logic live in preload_delete_name() instead, but
the boot-time ucode code must still defer the deletion somewhat.

diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index 6ceb34d66b74..10b28d5d375c 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
_at__at_ -1179,11 +1179,41 _at__at_ link_elf_unload_file(linker_file_t file)
 	free(ef->typoff, M_LINKER);
 }
 
+struct pending_unload {
+	char		pathname[MAXPATHLEN];
+	SLIST_ENTRY(pending_unload) next;
+};
+SLIST_HEAD(, pending_unload) pending = SLIST_HEAD_INITIALIZER(pending);
+
 static void
-link_elf_unload_preload(linker_file_t file)
+link_elf_unload_pending(void *arg __unused)
 {
-	if (file->pathname != NULL)
+	struct pending_unload *file;
+
+	while ((file = SLIST_FIRST(&pending)) != NULL) {
 		preload_delete_name(file->pathname);
+		SLIST_REMOVE_HEAD(&pending, next);
+		free(file, M_LINKER);
+	}
+}
+SYSINIT(unload_pending, SI_SUB_CONFIGURE + 1, SI_ORDER_ANY,
+    link_elf_unload_pending, NULL);
+
+static void
+link_elf_unload_preload(linker_file_t lf)
+{
+	struct pending_unload *file;
+
+	if (lf->pathname != NULL) {
+		if (!cold) {
+			preload_delete_name(lf->pathname);
+			return;
+		}
+		file = malloc(sizeof(*file), M_LINKER, M_WAITOK);
+		(void)strlcpy(file->pathname, lf->pathname,
+		    sizeof(file->pathname));
+		SLIST_INSERT_HEAD(&pending, file, next);
+	}
 }
 
 static const char *
Received on Sat May 18 2019 - 03:33:36 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:20 UTC