Page MenuHomeFreeBSD

Fix some issues with pmap_protect().
ClosedPublic

Authored by markj on Jan 2 2019, 6:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 18, 12:13 AM
Unknown Object (File)
Mar 7 2024, 11:35 PM
Unknown Object (File)
Feb 12 2024, 11:46 PM
Unknown Object (File)
Dec 22 2023, 11:03 PM
Unknown Object (File)
Nov 25 2023, 5:27 AM
Unknown Object (File)
Nov 22 2023, 6:34 PM
Unknown Object (File)
Nov 22 2023, 6:11 PM
Unknown Object (File)
Nov 22 2023, 3:48 PM
Subscribers

Details

Summary

Note that pmap_protect() is only ever used to remove permissions from
existing mappings.

  • When clearing PTE_W, use an atomic update to the PTE; otherwise we may clobber updates done by the hardware.
  • Handle VM_PROT_EXECUTE.
  • Clear PTE_D and mark the page dirty when removing write permission from a mapping.

Diff Detail

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

Event Timeline

sys/riscv/riscv/pmap.c
1918 ↗(On Diff #52487)

I see that you changed this to atomic clear, so my comment from other review is not relevant.

But what if PTE_D bit set after the pmap_load() but before atomic_clear() ? This seems to be legit and would cause missing dirty set and consequent corruption of the user data. Shouldn't you use atomic_cmpxchg() there and retry on failure ?

markj marked an inline comment as done.
  • Fix the bug that kib pointed out.
sys/riscv/riscv/pmap.c
1918 ↗(On Diff #52487)

Indeed, thanks. :(

BTW, I used _long instead of _64 here because I believe we'll eventually want to support 32-bit kernels. I'll update the macros in D18717 in a separate commit.

This revision is now accepted and ready to land.Jan 2 2019, 11:37 PM
jhb added inline comments.
sys/riscv/riscv/pmap.c
1874 ↗(On Diff #52498)

Oops.

This revision was automatically updated to reflect the committed changes.