xen: privcmd: do not return pages which we have failed to unmap
PATCH 1/1 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 foced to leak them. Log that we have done so.
The potential for failure only exists for autotranslated guest (e.g. ARM and x86 PVH).
--- drivers/xen/privcmd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/xen/privcmd.c +7 -1
@@ -533,11 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) {struct page **pages = vma->vm_private_data;int numpgs = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; +int rc;if (!xen_feature (XENFEAT_auto_translated_physmap) || !numpgs || !pages)return ; -xen_unmap_domain_mfn_range (vma, numpgs, pages); + rc =xen_unmap_domain_mfn_range (vma, numpgs, pages); +if (rc <0 ) { +pr_crit ("unable to unmap MFN range: leaking %d pages\n" , + numpgs); +return ; + }free_xenballooned_pages (numpgs, pages);kfree (pages); }
Signature · 1 line
1.7.10.4
Quoted 5 lines · Ian Campbell
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 foced to leak them. Log that we have done so.
^forced
Quoted 3 lines
The potential for failure only exists for autotranslated guest (e.g. ARM and x86 PVH).
[...]
Quoted 6 lines
drivers/xen/privcmd.c +0
-0@@ -533,11 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) {struct page **pages = vma->vm_private_data;int numpgs = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ;
drivers/xen/privcmd.c static void privcmd_close(struct vm_area_struct *vma) · line 544
Quoted 10 lines
drivers/xen/privcmd.c +5
-1+int rc;if (!xen_feature (XENFEAT_auto_translated_physmap) || !numpgs || !pages)return ; -xen_unmap_domain_mfn_range (vma, numpgs, pages); + rc =xen_unmap_domain_mfn_range (vma, numpgs, pages); +if (rc <0 ) { +pr_crit ("unable to unmap MFN range: leaking %d pages\n" , + numpgs);
kfree(pages) here? I think that would be safe. Although at this point it probably doesn't really matter.
David
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-1- xen_unmap_domain_mfn_range(vma, numpgs, pages); + rc = xen_unmap_domain_mfn_range(vma, numpgs, pages); + if (rc < 0) { + pr_crit("unable to unmap MFN range: leaking %d pages\n", + numpgs);kfree(pages) here? I think that would be safe. Although at this point it probably doesn't really matter.
I suppose we might as well not make it any worse than it needs to be and it's easy enough to arrange.
---------------------8<---------------------
Quoted 1 line
From
900f1e903bacf376800b078aef03e8d5ff524562Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Wed, 4 Dec 2013 14:19:52 +0000
Subject: [PATCH] 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).
---
v2: Don't leak the actual pages array as well
Log rc
--- drivers/xen/privcmd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/xen/privcmd.c +7 -2
@@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) {struct page **pages = vma->vm_private_data;int numpgs = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; +int rc;if (!xen_feature (XENFEAT_auto_translated_physmap) || !numpgs || !pages)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); }
Signature · 1 line
1.7.10.4
David Vrabel
Reviewed-byQuoted 11 lines · Ian Campbell
Subject: [PATCH] xen: privcmd: do not return pages which we have failed to
unmapThis 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).
David
Stefano Stabellini
Acked-byQuoted 21 lines · Ian Campbell
Quoted 1 line
From
900f1e903bacf376800b078aef03e8d5ff524562Mon Sep 17 00:00:00 2001From: Ian Campbell <[email protected]>
Date: Wed, 4 Dec 2013 14:19:52 +0000
Subject: [PATCH] xen: privcmd: do not return pages which we have failed to
unmapThis 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 <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>Cc Stefano Stabellini <[email protected]>
Quoted 3 lines
---
v2: Don't leak the actual pages array as well
Log rc
Konrad, you can go ahead and add it to xentip, unless you would rather have me do it.
Quoted 32 lines
drivers/xen/privcmd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/xen/privcmd.c +7
-2@@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) {struct page **pages = vma->vm_private_data;int numpgs = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; +int rc;if (!xen_feature (XENFEAT_auto_translated_physmap) || !numpgs || !pages)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); }Signature · 1 line
1.7.10.4
Quoted 27 lines · Stefano Stabellini
Quoted 21 lines · Ian Campbell
Quoted 1 line
From
900f1e903bacf376800b078aef03e8d5ff524562Mon Sep 17 00:00:00 2001From: Ian Campbell <[email protected]>
Date: Wed, 4 Dec 2013 14:19:52 +0000
Subject: [PATCH] xen: privcmd: do not return pages which we have failed to
unmapThis 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 <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>Cc Stefano Stabellini <[email protected]>Quoted 3 lines
---
v2: Don't leak the actual pages array as well
Log rc
Quoted 4 lines
Konrad, you can go ahead and add it to xentip, unless you would rather have me do it.
Why don't you do it. Thanks!
Quoted 34 lines
Quoted 34 lines
drivers/xen/privcmd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/xen/privcmd.c +7
-2@@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) {struct page **pages = vma->vm_private_data;int numpgs = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; +int rc;if (!xen_feature (XENFEAT_auto_translated_physmap) || !numpgs || !pages)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); }Signature · 1 line
1.7.10.4
Quoted 28 lines · Konrad Rzeszutek Wilk
Quoted 27 lines · Stefano Stabellini
Quoted 24 lines · Ian Campbell
Quoted 1 line
From
900f1e903bacf376800b078aef03e8d5ff524562Mon Sep 17 00:00:00 2001From: Ian Campbell <[email protected]>
Date: Wed, 4 Dec 2013 14:19:52 +0000
Subject: [PATCH] xen: privcmd: do not return pages which we have failed to
unmapThis 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 <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>Cc Stefano Stabellini <[email protected]>---
v2: Don't leak the actual pages array as well
Log rc
Quoted 6 lines
Quoted 4 lines
Konrad, you can go ahead and add it to xentip, unless you would rather have me do it.
Why don't you do it. Thanks!
done
Quoted 34 lines
Quoted 33 lines
Quoted 33 lines
drivers/xen/privcmd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/xen/privcmd.c +7
-2@@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) {struct page **pages = vma->vm_private_data;int numpgs = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; +int rc;if (!xen_feature (XENFEAT_auto_translated_physmap) || !numpgs || !pages)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); }Signature · 1 line
1.7.10.4