]> xenbits.xensource.com Git - xen.git/commit
libxc: Replace alloca() with mmap() for large array sizes
authorAravindh Puthiyaparambil <aravindh@virtuata.com>
Tue, 24 Apr 2012 13:31:36 +0000 (14:31 +0100)
committerAravindh Puthiyaparambil <aravindh@virtuata.com>
Tue, 24 Apr 2012 13:31:36 +0000 (14:31 +0100)
commit8a2a58e21e8f6f85841b6d8b85acb782f1c39e0b
tree4f013c979bb16f5788f5fbf553e77865967682e1
parentc9cca66b8db632792f062f5ff50b1ca301dbeae4
libxc: Replace alloca() with mmap() for large array sizes

Replace alloca() with mmap() for array sizes greater than a page in
xc_linux_osdep.c.

When mapping in large amounts of pages (in the GB range) from a guest
in to Dom0 using xc_map_foreign_bulk(), a segfault occurs in the libxc
client application. This is because the pfn array in
linux_privcmd_map_foreign_bulk() is being allocated using alloca() and
the subsequent memcpy causes the stack to blow. This patch replaces
the alloca() with mmap() for pfn array sizes greater than a page.

Fix an error print with the correct function name.

Do the same for the map array in linux_gnttab_grant_map()

Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com>
Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxc/xc_linux_osdep.c