kern/71388: panic due mac_policy_list_conditional_busy called before mac_init

Dan Lukes dan at
Sat Sep 4 22:40:22 PDT 2004

>Number:         71388
>Category:       kern
>Synopsis:       panic due mac_policy_list_conditional_busy called before mac_init
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 05 05:40:20 GMT 2004
>Originator:     Dan Lukes
>Release:        FreeBSD 5.3-BETA3 i386
System: FreeBSD 5.3-BETA3 #5: Sun Sep 5 05:30:03 CEST 2004 /usr/obj/usr/src/sys/Dan i386
cvsup of RELENG_5 on Sep  5 01:55 CEST
src/sys/kern/kern_mac.c,v 1.113 2004/07/15 08:26:05 phk

option MAC within kernel configuration file; 
no other MAC_* options nor modules

a kernel loadable module with an external reference that can't be resolved
by linker

	On the start of boot, when linker link the preloaded modules,
including the one with unresolvable external reference, the system paniced:

panic: mtx_lock() of spin mutex (null) @ /usr/src/sys/kern/kern_mac.c:239

	Preload module that has unresolvable reference
(for example, if_fxp when miibus.ko unavaiable) on boot (kernel with MAC


	I'm sorry, no exact fix hint. 

	The relevant part of source:
233: int
234: mac_policy_list_conditional_busy(void)
235: {
236: #ifndef MAC_STATIC
237:         int ret;
239:         mtx_lock(&mac_policy_mtx);

	The mac_policy_mtx is NULL as mac_init has not been called yet.

	The mac_policy_list_conditional_busy is called from
mac_check_kld_unload via MAC_CHECK macro.

	Althought I have no back-trace, the caller of mac_check_kld_unload
seems to be link_elf_link_preload via linker_file_unload.

	I'm not sure about the best place to test that the MAC layer is not
initialized yet. May be mac_policy_list_conditional_busy should return error
when called with mac_policy_mtx==NULL 

More information about the freebsd-bugs mailing list