git: 17093b04c34e - stable/13 - arm64: fix a potential KVA leak in pmap_demote_l1()

Mark Johnston markj at FreeBSD.org
Tue Aug 31 19:09:46 UTC 2021


The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=17093b04c34e50f2de649b64d95e96492639472e

commit 17093b04c34e50f2de649b64d95e96492639472e
Author:     Alan Cox <alc at FreeBSD.org>
AuthorDate: 2021-06-26 03:29:38 +0000
Commit:     Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-08-31 19:09:23 +0000

    arm64: fix a potential KVA leak in pmap_demote_l1()
    
    In the unlikely event that the 1 GB page mapping being demoted is used
    to access the L1 page table page containing the 1 GB page mapping and
    the vm_page_alloc() to allocate a new L2 page table page fails, we
    would leak a page of kernel virtual address space.  Fix this leak.
    
    (cherry picked from commit 5dd84e315a9f777772017f9f628aa67f08a6493a)
---
 sys/arm64/arm64/pmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 0220c0e8710b..4a5dff98f308 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -6219,7 +6219,8 @@ pmap_demote_l1(pmap_t pmap, pt_entry_t *l1, vm_offset_t va)
 	    VM_ALLOC_NOOBJ | VM_ALLOC_WIRED)) == NULL) {
 		CTR2(KTR_PMAP, "pmap_demote_l1: failure for va %#lx"
 		    " in pmap %p", va, pmap);
-		return (NULL);
+		l2 = NULL;
+		goto fail;
 	}
 
 	l2phys = VM_PAGE_TO_PHYS(ml2);
@@ -6248,6 +6249,7 @@ pmap_demote_l1(pmap_t pmap, pt_entry_t *l1, vm_offset_t va)
 
 	pmap_update_entry(pmap, l1, l2phys | L1_TABLE, va, PAGE_SIZE);
 
+fail:
 	if (tmpl1 != 0) {
 		pmap_kremove(tmpl1);
 		kva_free(tmpl1, PAGE_SIZE);


More information about the dev-commits-src-branches mailing list