Page MenuHomeFreeBSD

kern linker: Do not try to unload kernel
AcceptedPublic

Authored by zlei on Nov 9 2023, 3:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 23 2023, 2:20 AM
Unknown Object (File)
Dec 19 2023, 9:18 PM
Unknown Object (File)
Dec 6 2023, 4:05 AM
Unknown Object (File)
Nov 28 2023, 4:49 PM
Unknown Object (File)
Nov 26 2023, 6:48 AM
Unknown Object (File)
Nov 21 2023, 10:09 PM
Unknown Object (File)
Nov 9 2023, 4:59 PM
Unknown Object (File)
Nov 9 2023, 4:10 PM

Details

Reviewers
kib
dfr
dab
cem
jhb
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