HomeFreeBSD

riscv: handle page faults in the unmappable region

Description

riscv: handle page faults in the unmappable region

When handling a kernel page fault, check explicitly that stval resides
in either the user or kernel address spaces, and make the page fault
fatal if not. Otherwise, a properly crafted address may appear to
pmap_fault() as a valid and present page in the kernel map, causing the
page fault to be retried continuously. This is mainly due to the fact
that the upper bits of virtual addresses are not validated by most of
the pmap code.

Faults of this nature should only occur due to some kind of bug in the
kernel, but it is best to handle them gracefully when they do.

Handle user page faults in the same way, sending a SIGSEGV immediately
when a malformed address is encountered.

Add an assertion to pmap_l1(), which should help catch other bugs of
this kind that make it this far.

Reviewed by: jrtc27, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31208

Details

Provenance
mhorneAuthored on Oct 7 2021, 9:05 PM
Reviewer
jrtc27
Differential Revision
D31208: riscv: handle page faults in the unmappable region
Parents
rG76c2e71c4c65: pf: remove unused field from pf_kanchor
Branches
Unknown
Tags
Unknown