Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 May 2019 01:33:28 -0400
From:      Mark Johnston <markj@freebsd.org>
To:        Rebecca Cran <rebecca@bluestop.org>
Cc:        freebsd-current@freebsd.org
Subject:   Re: panic booting with if_tap_load="YES" in loader.conf
Message-ID:  <20190518053328.GA7370@raichu>
In-Reply-To: <105ad083-ea95-21a7-35be-de01e32578c4@bluestop.org>
References:  <105ad083-ea95-21a7-35be-de01e32578c4@bluestop.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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
@@ -1179,11 +1179,41 @@ 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 *



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190518053328.GA7370>