boot time crash in if_detach_internal()

Chris Torek torek at torek.net
Mon Apr 1 09:56:46 UTC 2013


I have been poking about with the bhyve virtualization code in
FreeBSD 10-current, and managed to crash FreeBSD during its
bootstrap process due to the fact that if_detach is called
from boot time configuration code, before the internal domain
system initialization has happened.

I added the following patch to work around the problem.  As
the large comment notes, it might not be quite correct but it
does allow the boot to proceed (of course the "dead" network
device is soon a problem anyway...).

The fix mirrors (more or less) the code in if_attach_internal().
Feel free to accept, ignore, or modify the patch. :-)

Chris

diff --git a/sys/net/if.c b/sys/net/if.c
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -845,6 +845,15 @@
 
 	if_purgeaddrs(ifp);
 
+	/*
+	 * torek: it's not entirely clear to me where and how this
+	 * should go, but if domain_init_status < 2 then there should
+	 * be no inet, inet6, etc items, and this is where the crash
+	 * happens during boot, so let's try this:
+	 */
+	if (domain_init_status < 2)
+		return;
+
 #ifdef INET
 	in_ifdetach(ifp);
 #endif


More information about the freebsd-hackers mailing list