Mailing List Archive

[xen-unstable] The current libxl_set_memory_target function subtracts a negative amount
# HG changeset patch
# User Stefano Stabellini <stefano.stabellini@eu.citrix.com>
# Date 1296588308 0
# Node ID 74cd0f668546d14b5965d8f1e715da1662915646
# Parent 18807b89083dd6ff27f95974a6d7ee1111179b07
The current libxl_set_memory_target function subtracts a negative amount
from an uint32_t variable without checking if the operation wraps
around.

This patch fixes this bug (that I previously believed to be an
hypervisor issue):
http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=1729

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
tools/libxl/libxl.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff -r 18807b89083d -r 74cd0f668546 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Tue Feb 01 19:23:31 2011 +0000
+++ b/tools/libxl/libxl.c Tue Feb 01 19:25:08 2011 +0000
@@ -2059,9 +2059,12 @@ retry_transaction:
goto out;
}

- if (relative)
- new_target_memkb = current_target_memkb + target_memkb;
- else
+ if (relative) {
+ if (target_memkb < 0 && abs(target_memkb) > current_target_memkb)
+ new_target_memkb = 0;
+ else
+ new_target_memkb = current_target_memkb + target_memkb;
+ } else
new_target_memkb = target_memkb;
if (new_target_memkb > memorykb) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog