Page MenuHomeFreeBSD

Set NX on direct map PML4Es.
ClosedPublic

Authored by markj on Sep 22 2019, 7:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 11, 4:53 AM
Unknown Object (File)
Nov 4 2024, 12:37 PM
Unknown Object (File)
Oct 30 2024, 6:02 PM
Unknown Object (File)
Oct 17 2024, 9:49 PM
Unknown Object (File)
Oct 2 2024, 7:15 AM
Unknown Object (File)
Sep 26 2024, 4:57 AM
Unknown Object (File)
Sep 22 2024, 3:55 AM
Unknown Object (File)
Sep 16 2024, 10:20 AM
Subscribers

Details

Summary

For a while now we've been using the direct map without execute
permissions, and we have the ability to dynamically create executable
mappings in the kernel map. To help ensure that the direct map is never
used for code execution, mark the direct map PML4Es as NX as well. No
functional change intended.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26634
Build 25010: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Sep 22 2019, 8:21 PM
sys/amd64/amd64/pmap.c
1545–1559

Doesn't setting pg_nx on the direct map's PML4 entries conflict with what this block is trying to do?

sys/amd64/amd64/pmap.c
1545–1559

I think the omission of pg_nx in the PDPEs is an oversight, and doesn't have any effect since it is set in the PDEs (which also do not set PG_RW). The intent of this block is to ensure that the kernel text is not writeable via the direct map, not to permit execution. So I believe the answer to your question is no.

sys/amd64/amd64/pmap.c
1545–1559

I would argue that the phrase "appropriate permissions" in the above comment is simply too vague. I shouldn't have to infer what "appropriate" means. :-)

  • Set NX on other intermedia direct map PT entries.
  • Clarify a comment.
This revision now requires review to proceed.Sep 22 2019, 11:21 PM
This revision is now accepted and ready to land.Sep 23 2019, 4:08 AM