Skip to contentSkip to conversation

xen/xenbus: Don't leak memory when unmapping the ring on HVM backend

PATCH Applied Julien Grall 4 participants 7 messages Aug 10, 2015 – Aug 11, 2015 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/xenbus: Don't leak memory when unmapping the ring on HVM backend

The commit ccc9d90a9a8b5c4ad7e9708ec41f75ff9e98d61d "xenbus_client:
Extend interface to support multi-page ring" removes the call to free_xenballooned_pages in xenbus_unmap_ring_vfree_hvm.

This will result to not give back the pages to Linux and loose them forever. It only happens when the backends are running in HVM domains.

---
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: Wei Liu <[email protected]>

Appeared in Linux 4.1. HVM backend, which is always the case on ARM, will leak every mapped ring (i.e ~12KB per domain with 1 disk and 1 vif).

---
 drivers/xen/xenbus/xenbus_client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_client.c +3 -1
index 9ad3272..e303535 100644
@@ -814,8 +814,10 @@ static int xenbus_unmap_ring_vfree_hvm(struct xenbus_device *dev, void *vaddr)
 
 	rv = xenbus_unmap_ring(dev, node->handles, node->nr_handles,
 			       addrs);
-	if (!rv)
+	if (!rv) {
 		vunmap(vaddr);
+		free_xenballooned_pages(node->nr_handles, node->hvm.pages);
+	}
 	else
 		WARN(1, "Leaking %p, size %u page(s)\n", vaddr,
 		     node->nr_handles);
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Julien Grall

The commit ccc9d90a9a8b5c4ad7e9708ec41f75ff9e98d61d "xenbus_client:
Extend interface to support multi-page ring" removes the call to free_xenballooned_pages in xenbus_unmap_ring_vfree_hvm.

This will result to not give back the pages to Linux and loose them forever. It only happens when the backends are running in HVM domains.

Quoted 29 lines

---
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: Wei Liu <[email protected]>

Appeared in Linux 4.1. HVM backend, which is always the case on ARM, will leak every mapped ring (i.e ~12KB per domain with 1 disk and 1 vif).

---
  drivers/xen/xenbus/xenbus_client.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_client.c +3 -1
index 9ad3272..e303535 100644
@@ -814,8 +814,10 @@ static int xenbus_unmap_ring_vfree_hvm(struct xenbus_device *dev, void *vaddr)
 
  	rv = xenbus_unmap_ring(dev, node->handles, node->nr_handles,
  			       addrs);
-	if (!rv)
+	if (!rv) {
  		vunmap(vaddr);
+		free_xenballooned_pages(node->nr_handles, node->hvm.pages);
+	}
  	else
  		WARN(1, "Leaking %p, size %u page(s)\n", vaddr,
  		     node->nr_handles);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Julien Grall
Quoted 8 lines · Julien Grall

The commit ccc9d90a9a8b5c4ad7e9708ec41f75ff9e98d61d "xenbus_client:
Extend interface to support multi-page ring" removes the call to free_xenballooned_pages in xenbus_unmap_ring_vfree_hvm.

This will result to not give back the pages to Linux and loose them forever. It only happens when the backends are running in HVM domains.

Quoted 29 lines

---
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: Wei Liu <[email protected]>

Appeared in Linux 4.1. HVM backend, which is always the case on ARM, will leak every mapped ring (i.e ~12KB per domain with 1 disk and 1 vif).

---
  drivers/xen/xenbus/xenbus_client.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_client.c +3 -1
index 9ad3272..e303535 100644
@@ -814,8 +814,10 @@ static int xenbus_unmap_ring_vfree_hvm(struct xenbus_device *dev, void *vaddr)
 
  	rv = xenbus_unmap_ring(dev, node->handles, node->nr_handles,
  			       addrs);
-	if (!rv)
+	if (!rv) {
  		vunmap(vaddr);
+		free_xenballooned_pages(node->nr_handles, node->hvm.pages);
+	}
  	else
  		WARN(1, "Leaking %p, size %u page(s)\n", vaddr,
  		     node->nr_handles);
Reviewed-by on v1 1/1
#3 lore raw
In reply to Julien Grall
Quoted 7 lines · Julien Grall

The commit ccc9d90a9a8b5c4ad7e9708ec41f75ff9e98d61d "xenbus_client:
Extend interface to support multi-page ring" removes the call to free_xenballooned_pages in xenbus_unmap_ring_vfree_hvm.

This will result to not give back the pages to Linux and loose them forever. It only happens when the backends are running in HVM domains.

Quoted 8 lines

---
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: Wei Liu <[email protected]>

Quoted 24 lines

Appeared in Linux 4.1. HVM backend, which is always the case on ARM, will leak every mapped ring (i.e ~12KB per domain with 1 disk and 1 vif).

---
 drivers/xen/xenbus/xenbus_client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_client.c +3 -1
index 9ad3272..e303535 100644
@@ -814,8 +814,10 @@ static int xenbus_unmap_ring_vfree_hvm(struct xenbus_device *dev, void *vaddr)
 
 	rv = xenbus_unmap_ring(dev, node->handles, node->nr_handles,
 			       addrs);
-	if (!rv)
+	if (!rv) {
 		vunmap(vaddr);
+		free_xenballooned_pages(node->nr_handles, node->hvm.pages);
+	}
 	else
 		WARN(1, "Leaking %p, size %u page(s)\n", vaddr,
 		     node->nr_handles);
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#4 lore raw
In reply to Julien Grall
Quoted 7 lines · Julien Grall

The commit ccc9d90a9a8b5c4ad7e9708ec41f75ff9e98d61d "xenbus_client:
Extend interface to support multi-page ring" removes the call to free_xenballooned_pages in xenbus_unmap_ring_vfree_hvm.

This will result to not give back the pages to Linux and loose them forever. It only happens when the backends are running in HVM domains.

Quoted 8 lines

---
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: Wei Liu <[email protected]>

Quoted 24 lines

Appeared in Linux 4.1. HVM backend, which is always the case on ARM, will leak every mapped ring (i.e ~12KB per domain with 1 disk and 1 vif).

---
 drivers/xen/xenbus/xenbus_client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_client.c +3 -1
index 9ad3272..e303535 100644
@@ -814,8 +814,10 @@ static int xenbus_unmap_ring_vfree_hvm(struct xenbus_device *dev, void *vaddr)
 
 	rv = xenbus_unmap_ring(dev, node->handles, node->nr_handles,
 			       addrs);
-	if (!rv)
+	if (!rv) {
 		vunmap(vaddr);
+		free_xenballooned_pages(node->nr_handles, node->hvm.pages);
+	}
 	else
 		WARN(1, "Leaking %p, size %u page(s)\n", vaddr,
 		     node->nr_handles);
Signature · 1 line
2.1.4
Applied
#5 lore raw
In reply to Julien Grall
Quoted 6 lines · Julien Grall

The commit ccc9d90a9a8b5c4ad7e9708ec41f75ff9e98d61d "xenbus_client:
Extend interface to support multi-page ring" removes the call to free_xenballooned_pages in xenbus_unmap_ring_vfree_hvm.

This will result to not give back the pages to Linux and loose them forever. It only happens when the backends are running in HVM domains.

Applied to for-linus-4.2 and tagged for stable, thanks.

David

Applied
#6 lore raw
In reply to Julien Grall
Quoted 6 lines · Julien Grall

The commit ccc9d90a9a8b5c4ad7e9708ec41f75ff9e98d61d "xenbus_client:
Extend interface to support multi-page ring" removes the call to free_xenballooned_pages in xenbus_unmap_ring_vfree_hvm.

This will result to not give back the pages to Linux and loose them forever. It only happens when the backends are running in HVM domains.

Applied to for-linus-4.2 and tagged for stable, thanks.

David