Page MenuHomeFreeBSD

linker: Reset DMAP protections in link_elf_unload_file()
Needs ReviewPublic

Authored by markj on Wed, Dec 31, 4:37 PM.
Tags
None
Referenced Files
F141103105: D54438.id.diff
Wed, Dec 31, 9:53 PM
F141103004: D54438.id168805.diff
Wed, Dec 31, 9:51 PM
F141102000: D54438.diff
Wed, Dec 31, 9:31 PM
Subscribers

Details

Reviewers
jhb
alc
kib
andrew
Summary

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 I see no
reason not to handle this within the kernel linker. Moreover, we were
not resetting permissions in the kernel map on arm64.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69549
Build 66432: arc lint + arc unit

Event Timeline

markj requested review of this revision.Wed, Dec 31, 4:37 PM
sys/kern/link_elf.c
828

Why do you need prot and mask? If you would directly order the function to either calculate the access bits based on PF_ flags or to set it to RW regardless of the PF_ phdr flags, it would be IMO cleaner and even slightly more compact.