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
F96409511: D42530.diff
Tue, Sep 24, 8:27 PM
F96349617: D42530.id136217.diff
Tue, Sep 24, 4:28 PM
F96225585: D42530.id129904.diff
Tue, Sep 24, 3:25 AM
F96225583: D42530.id129904.diff
Tue, Sep 24, 3:25 AM
F96225577: D42530.id129904.diff
Tue, Sep 24, 3:24 AM
Unknown Object (File)
Sun, Sep 22, 10:28 PM
Unknown Object (File)
Sun, Sep 22, 3:26 PM
Unknown Object (File)
Fri, Sep 20, 7:46 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 Skipped
Unit
Tests Skipped

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
1798–1799

Blank line before comment