]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Disallow preemptive creation of wired superpage mappings.
authormarkj <markj@FreeBSD.org>
Thu, 21 Mar 2019 19:52:50 +0000 (19:52 +0000)
committermarkj <markj@FreeBSD.org>
Thu, 21 Mar 2019 19:52:50 +0000 (19:52 +0000)
commit1ab80ddad8264f9d0e4561ad2b20e5b94b3a1b42
tree400be05dafae97004b1ad74c900ebc24c5c12e2b
parent41a70f9371c9d6ee8f1108936c3b8508a6aab41b
Disallow preemptive creation of wired superpage mappings.

There are some unusual cases where a process may cause an mlock()ed
range of memory to be unmapped.  If the application subsequently
faults on that region, the handler may attempt to create a superpage
mapping backed by the resident, wired pages.  However, the pmap code
responsible for creating such a mapping (pmap_enter_pde() on i386
and amd64) does not ensure that a leaf page table page is available
if the superpage is later demoted; the demotion operation must therefore
perform a non-blocking page allocation and must unmap the entire
superpage if the allocation fails.  The pmap layer ensures that this
can never happen for wired mappings, and so the case described above
breaks that invariant.

For now, simply ensure that the MI fault handler never attempts to
create a wired superpage except via promotion.

Reviewed by: kib
Reported by: syzbot+292d3b0416c27c131505@syzkaller.appspotmail.com
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19670
sys/amd64/amd64/pmap.c
sys/i386/i386/pmap.c
sys/vm/vm_fault.c