git: b53b21e8f81a - main - amd64 pmap: Release PTP reference on leaf ptpage allocation failure
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 16 Jun 2024 16:20:04 UTC
The branch main has been updated by bnovkov:
URL: https://cgit.FreeBSD.org/src/commit/?id=b53b21e8f81a8d2d233b99cee6426c2f64765a3c
commit b53b21e8f81a8d2d233b99cee6426c2f64765a3c
Author: Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2024-06-13 15:58:49 +0000
Commit: Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2024-06-16 16:19:26 +0000
amd64 pmap: Release PTP reference on leaf ptpage allocation failure
aa3bcaa fixed an edge case invloving mlock() and superpage creation
by creating and inserting a leaf pagetable page for mlock'd superpages.
However, the code does not properly release the reference to the
pagetable page in the error handling path.
This commit fixes the issue by adding calls to 'pmap_abort_ptp'
in the error handling path.
Reported by: alc
Approved by: markj (mentor)
Fixes: aa3bcaa
Differential Revision: https://reviews.freebsd.org/D45577
---
sys/amd64/amd64/pmap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 4d4ecc8ea4e2..dee208fc9145 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -7595,10 +7595,13 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t va, pd_entry_t newpde, u_int flags,
if ((newpde & PG_W) != 0 && pmap != kernel_pmap) {
uwptpg = pmap_alloc_pt_page(pmap, pmap_pde_pindex(va),
VM_ALLOC_WIRED);
- if (uwptpg == NULL)
+ if (uwptpg == NULL) {
+ pmap_abort_ptp(pmap, va, pdpg);
return (KERN_RESOURCE_SHORTAGE);
+ }
if (pmap_insert_pt_page(pmap, uwptpg, true, false)) {
pmap_free_pt_page(pmap, uwptpg, false);
+ pmap_abort_ptp(pmap, va, pdpg);
return (KERN_RESOURCE_SHORTAGE);
}