tools/libxencall: enforce proper alignment of hypercall buffers
authorJuergen Gross <jgross@suse.com>
Fri, 8 Jun 2018 09:51:12 +0000 (11:51 +0200)
committerWei Liu <wei.liu2@citrix.com>
Tue, 10 Jul 2018 15:04:56 +0000 (16:04 +0100)
xencall_alloc_buffer() is used throughout Xen tools for allocating
hypercall buffers. Allocation is done at page granularity. For simple
administration each allocated set of pages contains a small header
holding the number of pages of that set. The hypercall buffer is
located directly after the 4 byte sized header, leading to a wrong
alignment for e.g. pointers.

Repair that by using a 16 byte sized header enforcing the same
alignment as malloc().

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libs/call/buffer.c

index 2d8fc29ac6649a2c72e42cba0b8bff3897a1430c..0b6af2db603f743af3ac4c8036dc616dd1eac6e9 100644 (file)
@@ -151,6 +151,7 @@ void xencall_free_buffer_pages(xencall_handle *xcall, void *p, size_t nr_pages)
 
 struct allocation_header {
     int nr_pages;
+    int pad[3];
 };
 
 void *xencall_alloc_buffer(xencall_handle *xcall, size_t size)