Page MenuHomeFreeBSD

kern linker: Do not try to unload kernel
ClosedPublic

Authored by zlei on Nov 9 2023, 3:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 14, 8:29 PM
Unknown Object (File)
Mon, Apr 29, 7:54 PM
Unknown Object (File)
Sun, Apr 28, 7:57 PM
Unknown Object (File)
Apr 5 2024, 2:49 PM
Unknown Object (File)
Apr 5 2024, 12:06 PM
Unknown Object (File)
Mar 26 2024, 8:48 AM
Unknown Object (File)
Dec 23 2023, 2:20 AM
Unknown Object (File)
Dec 19 2023, 9:18 PM

Details

Summary

The userland or kernel shall not unload the kernel module.

MFC after: 2 weeks

Test Plan
# kldstat 
Id Refs Address                Size Name
 1    1 0xffffffff80200000  1d35008 kernel
# kldunload kernel
kldunload: can't unload file: Device busy

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

zlei requested review of this revision.Nov 9 2023, 3:43 PM
This revision is now accepted and ready to land.Nov 9 2023, 3:44 PM

I was about to commit this I found that prior to d9ce8a41eac9 (kern_linker: Handle module-loading failures in preloaded .ko files) the kernel can not be unloaded.

CC the author @cem for this. See also discuss at ML https://lists.freebsd.org/archives/freebsd-current/2023-November/004950.html .

So this is more a regression than a feature.

I tested FreeBSD-11.4-RELEASE-amd64-bootonly.iso which does not have d9ce8a41eac9 ,:

# kldunload kernel
kldunload: can't unload file: Device busy

There is also log kldunload: attempt to unload file that was loaded by the kernel from dmesg.

So I can conclude d9ce8a41eac9 introduced regression.

jhb added a subscriber: jhb.

Yes, this is a regression from d9ce8a41eac9 and I think this is the right way to fix it.

sys/kern/kern_linker.c
1866–1867

Blank line before comment