Skip to contentSkip to conversation

libxl: Do not generate short block in libxl__datacopier_prefixdata

PATCH RESEND In review Ian Jackson 2 participants 4 messages Nov 12, 2013 – Nov 25, 2013

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 libxl: Do not generate short block in libxl__datacopier_prefixdata

Quoted 1 line · Chunyan Liu

Tried the patch. It worked. Thanks.

Thanks.

IMO this patch should be considered for backporting, too.

Ian.

Quoted 1 line

From 70f4755fba5e6a39e4f8ad55aff2d21f6aa8ff21 Mon Sep 17 00:00:00 2001

From: Ian Jackson <[email protected]>
Date: Tue, 3 Sep 2013 13:41:46 +0100
Subject: [PATCH] libxl: Do not generate short block in
libxl__datacopier_prefixdata

libxl__datacopier_prefixdata would prepend a deliberately short block (not just a half-full one, but one with a short buffer) to the dc->bufs queue. However, this is wrong because datacopier_readable will find it and try to continue to fill it up.

Instead, allocate a full-sized buffer.

---
 tools/libxl/libxl_aoutils.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_aoutils.c +1 -1
index 983a60a..b4eb6e5 100644
@@ -89,7 +89,7 @@ void libxl__datacopier_prefixdata(libxl__egc *egc, libxl__datacopier_state *dc,
 
     assert(len < dc->maxsz - dc->used);
 
-    buf = libxl__zalloc(NOGC, sizeof(*buf) - sizeof(buf->buf) + len);
+    buf = libxl__zalloc(NOGC, sizeof(*buf));
     buf->used = len;
     memcpy(buf->buf, data, len);
 
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Ian Jackson
Quoted 1 line · Chunyan Liu

Tried the patch. It worked. Thanks.

Thanks.

IMO this patch should be considered for backporting, too.

Ian.

From 70f4755fba5e6a39e4f8ad55aff2d21f6aa8ff21 Mon Sep 17 00:00:00 2001
From: Ian Jackson <[email protected]>
Date: Tue, 3 Sep 2013 13:41:46 +0100
Subject: [PATCH] libxl: Do not generate short block in
libxl__datacopier_prefixdata

libxl__datacopier_prefixdata would prepend a deliberately short block (not just a half-full one, but one with a short buffer) to the dc->bufs queue. However, this is wrong because datacopier_readable will find it and try to continue to fill it up.

Quoted 4 lines

Instead, allocate a full-sized buffer.

Quoted 17 lines
---
 tools/libxl/libxl_aoutils.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_aoutils.c +1 -1
index 983a60a..b4eb6e5 100644
@@ -89,7 +89,7 @@ void libxl__datacopier_prefixdata(libxl__egc *egc, libxl__datacopier_state *dc,
 
     assert(len < dc->maxsz - dc->used);
 
-    buf = libxl__zalloc(NOGC, sizeof(*buf) - sizeof(buf->buf) + len);
+    buf = libxl__zalloc(NOGC, sizeof(*buf));
     buf->used = len;
     memcpy(buf->buf, data, len);
 
#2 lore raw

Ian Campbell writes ("Re: [PATCH RESEND] libxl: Do not generate short block in libxl__datacopier_prefixdata"):

Quoted 12 lines · Ian Jackson
Quoted 11 lines

From 70f4755fba5e6a39e4f8ad55aff2d21f6aa8ff21 Mon Sep 17 00:00:00 2001
From: Ian Jackson <[email protected]>
Date: Tue, 3 Sep 2013 13:41:46 +0100
Subject: [PATCH] libxl: Do not generate short block in
libxl__datacopier_prefixdata

libxl__datacopier_prefixdata would prepend a deliberately short block (not just a half-full one, but one with a short buffer) to the dc->bufs queue. However, this is wrong because datacopier_readable will find it and try to continue to fill it up.

Quoted 6 lines
Quoted 4 lines

Instead, allocate a full-sized buffer.

Thanks,

I have put it on my backport list too.

Ian.

#3 lore raw

Ian Jackson writes ("Re: [PATCH RESEND] libxl: Do not generate short block in libxl__datacopier_prefixdata"):

Quoted 3 lines

I have put it on my backport list too.

Now applied to 4.3, 4.2. Was not applicable to 4.1.

Ian.