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)
Wed, Nov 6, 11:43 PM
Unknown Object (File)
Tue, Nov 5, 10:41 AM
Unknown Object (File)
Wed, Oct 30, 12:33 PM
Unknown Object (File)
Thu, Oct 17, 11:17 AM
Unknown Object (File)
Wed, Oct 16, 6:21 PM
Unknown Object (File)
Wed, Oct 16, 6:20 PM
Unknown Object (File)
Wed, Oct 16, 6:20 PM
Unknown Object (File)
Wed, Oct 16, 5:59 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