Page MenuHomeFreeBSD

Fix some problems in SPARSE_MAPPING in the kernel linker.
ClosedPublic

Authored by markj on Sep 22 2019, 7:39 PM.
Tags
None
Referenced Files
F170623231: D21756.id62474.diff
Sat, Sep 5, 4:49 PM
F170586169: D21756.id62474.diff
Sat, Sep 5, 12:55 PM
F170499668: D21756.diff
Sat, Sep 5, 3:02 AM
Unknown Object (File)
Fri, Sep 4, 4:32 AM
Unknown Object (File)
Fri, Sep 4, 3:31 AM
Unknown Object (File)
Thu, Sep 3, 11:24 PM
Unknown Object (File)
Wed, Sep 2, 1:53 AM
Unknown Object (File)
Tue, Sep 1, 11:09 PM
Subscribers

Details

Summary
  • Fix some style bugs.
  • Ensure that the end of the mapping passed to vm_page_wire() is page-aligned. vm_map_wire() expects this.
  • Wire pages before reading data into them to ensure that the mapping is backed by resident pages.
  • Apply the protections specified in the segment descriptor using vm_map_protect().
  • Ensure that on amd64 we load KLDs above KERNBASE.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Is there any way to enable SPARSE_MAPPING except manually adding #define ?

sys/kern/link_elf.c
1101 ↗(On Diff #62434)

I suspect this is too rough. In principle, the segments need not be page-aligned, and you might remove W or X from a neighbor segment that shares the page with us.

I think the easiest would be to refuse loading such objects.

In D21756#474923, @kib wrote:

Is there any way to enable SPARSE_MAPPING except manually adding #define ?

No. I'm considering adding a kernel option for it, but it needs a better name than SPARSE_MAPPING IMO.

Reject KLDs with unaligned segment base addrs when SPARSE_MAPPING is defined.

markj added inline comments.
sys/kern/link_elf.c
994 ↗(On Diff #62474)

I am not sure why we cannot just use kernel_object here. OBJT_DEFAULT doesn't make a lot of sense, since the memory will not be pageable.

This revision is now accepted and ready to land.Sep 23 2019, 5:11 PM