Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Apr 2024 16:19:50 GMT
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 22c098843127 - main - arm64: correctly handle a failed BTI check in pmap_enter_l2()
Message-ID:  <202404031619.433GJoF9096926@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by alc:

URL: https://cgit.FreeBSD.org/src/commit/?id=22c098843127f6a31e25e94b07b35677f038f6d6

commit 22c098843127f6a31e25e94b07b35677f038f6d6
Author:     Alan Cox <alc@FreeBSD.org>
AuthorDate: 2024-04-03 05:21:08 +0000
Commit:     Alan Cox <alc@FreeBSD.org>
CommitDate: 2024-04-03 16:19:30 +0000

    arm64: correctly handle a failed BTI check in pmap_enter_l2()
    
    If pmap_enter_l2() does not create a mapping because the BTI check
    fails, then we should release the reference on the page table page
    acquired from pmap_alloc_l2().  Otherwise, the page table page will
    never be reclaimed.
---
 sys/arm64/arm64/pmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 12e5e1d73b38..258aa141653b 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -5269,8 +5269,11 @@ pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, u_int flags,
 	 * and let vm_fault() cope.  Check after l2 allocation, since
 	 * it could sleep.
 	 */
-	if (!pmap_bti_same(pmap, va, va + L2_SIZE))
+	if (!pmap_bti_same(pmap, va, va + L2_SIZE)) {
+		KASSERT(l2pg != NULL, ("pmap_enter_l2: missing L2 PTP"));
+		pmap_abort_ptp(pmap, va, l2pg);
 		return (KERN_PROTECTION_FAILURE);
+	}
 
 	/*
 	 * If there are existing mappings, either abort or remove them.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404031619.433GJoF9096926>