Bug 31166

Summary: smbfs.ko module loads when compiled in, causes panic
Product: Base System Reporter: brad <brad>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-STABLE   
Hardware: Any   
OS: Any   

Description brad 2001-10-09 17:30:00 UTC
If the following are compiled into the kernel:

options         NETSMB                  #SMB/CIFS requester
options         NETSMBCRYPTO            #encrypted password support for SMB

# mchain library. It can be either loaded as KLD or compiled into kernel
options         LIBMCHAIN               #mbuf management library
options         LIBICONV

mount_smbfs will load smbfs.ko, and any attempt to unload this module will panic the system with a fatal trap

If this is added:

options         SMBFS
It is possible to load the smbfs.ko module anyway, generating seven lines worth of error messaging reading like so:

module_register: module dev_netsmb already exists!
linker_file_sysinit: "smbfs.ko" failed to register! 17
module_register: module smbfs already exists!
linker_file_sysinit: "smbfs.ko" failed to register! 17
WARNING: "nsmb" is usurping "nsmb"'s cdevsw[]
netsmb_dev: loaded
module_register_init: MOD_LOAD (smbfs, c016ebfc, 0xc3c46b00) error 17
kldstat shows smbfs.ko loaded. 

kldunload smbfs.ko will now crash the system.

Fix: 

The best workaround is not to ever attempt unloading the smbfs.ko module, and to include SMBFS in the kernel itself.

This is not however a fix.
How-To-Repeat: 1) Add the following to a kernel:

options         NETSMB                  #SMB/CIFS requester
options         NETSMBCRYPTO            #encrypted password support for SMB

# mchain library. It can be either loaded as KLD or compiled into kernel
options         LIBMCHAIN               #mbuf management library
options         LIBICONV
reboot, mount a windows share, and attempt to unload the smbfs.ko module. Panic is immediate

2) Add "options     SMBFS", and recompile; reboot

kldload smbfs.ko, kldunload smbfs.ko, panic is immediate.
Comment 1 dwmalone freebsd_committer freebsd_triage 2001-11-02 14:42:15 UTC
State Changed
From-To: open->closed

Issue of loading klds which are compiled into the kernel is a duplicate 
of PR 24392.