Arm: adjust locking in p2m_get_page_from_gfn()

In order to safely acquire a reference for a foreign page mapping, the
P2M lock needs to be held until we have the reference in hand (or
getting one failed). Otherwise the page can change P2M type and
ownership in between.

This is CVE-2025-58145 / part of XSA-473.

Fixes: 9486a8d07b ("xen/arm: Handle remove foreign mapping")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
master commit: 2275bf83a1
master date: 2025-09-09 14:12:57 +0200
This commit is contained in:
Jan Beulich committed 2025-09-09 14:25:58 +02:00
1 parent 46c0b23f17
commit c90cec6dfd
1 file changed
+13 -5
+13 -5
View File
@@ -591,18 +591,22 @@ mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t)
struct page_info *p2m_get_page_from_gfn(struct domain *d, gfn_t gfn,
p2m_type_t *t)
{
struct p2m_domain *p2m = p2m_get_hostp2m(d);
struct page_info *page;
p2m_type_t p2mt;
mfn_t mfn = p2m_lookup(d, gfn, &p2mt);
mfn_t mfn;
p2m_read_lock(p2m);
mfn = p2m_get_entry(p2m, gfn, &p2mt, NULL, NULL, NULL);
if ( t )
*t = p2mt;
if ( !p2m_is_any_ram(p2mt) )
return NULL;
if ( !mfn_valid(mfn) )
if ( !p2m_is_any_ram(p2mt) || !mfn_valid(mfn) )
{
p2m_read_unlock(p2m);
return NULL;
}
page = mfn_to_page(mfn);
@@ -614,6 +618,8 @@ struct page_info *p2m_get_page_from_gfn(struct domain *d, gfn_t gfn,
{
const struct domain *fdom = page_get_owner_and_reference(page);
p2m_read_unlock(p2m);
if ( fdom )
{
if ( fdom != d )
@@ -624,6 +630,8 @@ struct page_info *p2m_get_page_from_gfn(struct domain *d, gfn_t gfn,
return NULL;
}
p2m_read_unlock(p2m);
return get_page(page, d) ? page : NULL;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.