From bdb15722c1cc668a2a74517dc494d2e45878d690 Mon Sep 17 00:00:00 2001 From: Artur Grabowski Date: Sat, 28 Apr 2007 17:34:34 +0000 Subject: Fix pmap_extract to not return TRUE just because we have a PTP. Make sure that the PTP and the PTE are valid before returning success. deraadt@ ok, tested by many. --- sys/arch/i386/i386/pmap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sys') diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index 309437a0d47..989ac7332d0 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.106 2007/04/26 11:31:51 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.107 2007/04/28 17:34:33 art Exp $ */ /* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */ /* @@ -1959,15 +1959,16 @@ pmap_deactivate(struct proc *p) boolean_t pmap_extract(struct pmap *pmap, vaddr_t va, paddr_t *pap) { - paddr_t retval; - pt_entry_t *ptes; + pt_entry_t *ptes, pte; - if (pmap->pm_pdir[pdei(va)]) { + if (pmap_valid_entry(pmap->pm_pdir[pdei(va)])) { ptes = pmap_map_ptes(pmap); - retval = (paddr_t)(ptes[atop(va)] & PG_FRAME); + pte = ptes[atop(va)]; pmap_unmap_ptes(pmap); + if (!pmap_valid_entry(pte)) + return (FALSE); if (pap != NULL) - *pap = retval | (va & ~PG_FRAME); + *pap = (pte & PG_FRAME) | (va & ~PG_FRAME); return (TRUE); } return (FALSE); -- cgit v1.2.3