HomeFreeBSD

linker: Reset DMAP protections in link_elf_unload_file()

Description

linker: Reset DMAP protections in link_elf_unload_file()

On x86, when a preloaded kernel module is unloaded, we free the backing
(physically contiguous) pages. The ET_REL linker will have adjusted
protections on segments of the preloaded file, which updates the direct
map, so the original protections must be restored when unloading the
module.

Previously this was handled in kmem_bootstrap_free(), but there is no
apparent reason not to handle this within the kernel linker. Moreover,
we were not resetting permissions in the kernel map on arm64.

Reviewed by: alc, kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D54438

(cherry picked from commit 203e5a1eeec1153b0bcb230ccfb90531fa8cbeb5)

Details

Provenance
markjAuthored on Jan 6 2026, 4:48 PM
Reviewer
alc
Differential Revision
D54438: linker: Reset DMAP protections in link_elf_unload_file()
Parents
rGa30def1e98a2: in6: Modify address prefix lifetimes when updating address lifetimes
Branches
Unknown
Tags
Unknown