소스 검색

xen: privcmd: do not return pages which we have failed to unmap

This failure represents a hypervisor issue, but if it does occur then nothing
good can come of returning pages which still refer to a foreign owned page
into the general allocation pool.

Instead we are forced to leak them. Log that we have done so.

The potential for failure only exists for autotranslated guest (e.g. ARM and
x86 PVH).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Ian Campbell 11 년 전
부모
커밋
b6497b383f
1개의 변경된 파일7개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      drivers/xen/privcmd.c

+ 7 - 2
drivers/xen/privcmd.c

@@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma)
 {
 {
 	struct page **pages = vma->vm_private_data;
 	struct page **pages = vma->vm_private_data;
 	int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
 	int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+	int rc;
 
 
 	if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages)
 	if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages)
 		return;
 		return;
 
 
-	xen_unmap_domain_mfn_range(vma, numpgs, pages);
-	free_xenballooned_pages(numpgs, pages);
+	rc = xen_unmap_domain_mfn_range(vma, numpgs, pages);
+	if (rc == 0)
+		free_xenballooned_pages(numpgs, pages);
+	else
+		pr_crit("unable to unmap MFN range: leaking %d pages. rc=%d\n",
+			numpgs, rc);
 	kfree(pages);
 	kfree(pages);
 }
 }