|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen/arm: Fix memory leak in xenmem_add_to_physmap_one
Hi Michal,For the subject title and part of the code, "memory leak" tends to imply the memory is lost forever and therefore can never be recovered. AFAIU, in your case, the memory will be freed when the domain is destroyed. I would suggest to clarify it so it doesn't sound like a security issue. What about: "xen/arm: mm: Release the old page reference in xenmem_add_to_physmap_one()" On 05/02/2026 12:58, Michal Orzel wrote: When a guest maps pages via XENMEM_add_to_physmap to a GFN that already has an existing mapping, the old page at that GFN was not being removed, causing a memory leak. This affects all mapping spaces including XENMAPSPACE_shared_info, XENMAPSPACE_grant_table, and XENMAPSPACE_gmfn_foreign. The memory would be reclaimed on domain destruction. Add logic to remove the previously mapped page before creating the new mapping, matching the x86 implementation approach. Additionally, skip removal if the same MFN is being remapped. Can you explain why we skip the removal but not the insertion in this case?
I saw Jan mentionned the fact that we have two section with the P2M lock taken. But isn't it in fact 3 sections as gfn_to_mfn(d, gfn) also take a lock? I am not against the idea of not solving the locking right now. But I think it would at least be good to document it so this doesn't come as a surprise. For here and the second "return" statement below. Above callers may have taken a reference on the new page. So shouldn't we drop it like this is done at the end of the function? Based on the thread with Jan, is this statement actually correct? Could we reach this call with an MMIO (or event foreign mapping). In which case, I am guessing we could fail? If so, is this the intended behavior change? Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |