Xen Security Advisory 25 (CVE-2012-4544, CVE-2012-2625) - Xen domain builder Out-of-memory due to malicious kernel/ramdisk
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Xen Security Advisory CVE-2012-4544,CVE-2012-2625 / XSA-25
version 2Xen domain builder Out-of-memory due to malicious kernel/ramdisk
UPDATES IN VERSION 2
====================
Clarify that XSA-25 is reporting, via the Xen.org security process, both CVE-2012-4544 and CVE-2012-2625.
Also we would like to apologise for the fact that xen-announce's copy of version 1 of this advisory was delayed in mailing list moderation.
ISSUE DESCRIPTION
=================
The Xen PV domain builder contained no validation of the size of the supplied kernel or ramdisk either before or after decompression. This could cause the toolstack to consume all available RAM in the domain running the domain builder. (CVE-2012-4544)
Additionally, under similar circumstances pygrub consume excessive amount of memory under similar circumstances to the above. (CVE-2012-2625)
IMPACT
======
A malicious guest administrator who can supply a kernel or ramdisk can exhaust memory in domain 0 leading to a denial of service attack.
VULNERABLE SYSTEMS
==================
All versions of Xen are vulnerable.
MITIGATION
==========
Running only trusted kernels and ramdisks will avoid these vulnerabilities.
Using pvgrub also avoids these vulnerabilities since the builder will run in guest context. (nb: use of pygrub *is* vulnerable).
Running only HVM guests will avoid these vulnerabilities.
RESOLUTION
==========
Applying the appropriate attached patch resolves these issues.
The pygrub problem (CVE-2012-2625) was fixed in xen-unstable (and the fix inherited by Xen 4.2.x) in revision 25589:60f09d1ab1fe but not called out as a security problem. This fix is also included, where necessary, in the patches below.
xsa25-unstable.patch Xen unstable xsa25-4.2.patch Xen 4.2.x xsa25-4.1.patch Xen 4.1.x
$ sha256sum xsa25*.patch 613e4b82cdc9cabf9cbd52076118887b298c47e680c2066a28a77f12e9f90606 xsa25-4.1.patch 135bc089d003f9b97991764c37b1ab8d37e9cbcfa1b9bd7429b4503abe00c8f5 xsa25-4.2.patch 534495b7eef6e599f5814f0a67fc84fbe2e8eee9d223a09ad178ff63bdcda3dd xsa25-unstable.patch
Note that these patches impose a new size limit of 1Gby on both the compressed and uncompressed sizes of ramdisks. On some systems it may be desirable to relax these limits and risk virtual address or memory exhaustion in the toolstack. This can be achieved by setting XC_DOM_DECOMPRESS_MAX to the desired limit (in bytes). This can be done by building with "APPEND_CFLAGS=-DXC_DOM_DECOMPRESS_MAX=<limit>" or by editing tools/libxc/xc_dom.h directly.
NOTE REGARDING LACK OF EMBARGO
==============================
These issues have already been discussed in public in various places, including https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2012-2625
and http://bugs.debian.org/688125. This advisory is therefore not subject to an embargo.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iQEcBAEBAgAGBQJQokGyAAoJEIP+FMlX6CvZl7wH/RdoQHGDcbgVEh5fuS5VzPpw RZ0sm6bpI7eclqaN6+thX9SA5qeycvyj2zq769yUGSiHR+BUNw6HRJZ+XAAF0IIx nb4VEdS2+Hz1kyTUAeZu3z/5HyfFamKY9Lhhj/47DBTtO5Xl1pjOCA0bC4ZDtIm1 ffFVhOmTcmQEWXW1z27Vj9hSgQeGsqHTcOys6H0nYpLITDIZqBkGv8MZl4X0/Wtl zs2prG8HEWsysKel5Q/dt7De84OV3LgP1/2a+aMkLi+RgKWP+naKAXfYqVAS4mLw K+mv2MrmhgNxzEWp/sZX0q1QNvnJf+xKYHOBcP+hUlQIQwD/NQejdAdmNVPem7s= =Pfj+
-----END PGP SIGNATURE-----
libxc: builder: limit maximum size of kernel/ramdisk.
Allowing user supplied kernels of arbitrary sizes, especially during decompression, can swallow up dom0 memory leading to either virtual address space exhaustion in the builder process or allocation failures/OOM killing of both toolstack and unrelated processes.
We disable these checks when building in a stub domain for pvgrub since this uses the guest's own memory and is isolated.
Decompression of gzip compressed kernels and ramdisks has been safe since 14954:58205257517d (Xen 3.1.0 onwards).
This is XSA-25 / CVE-2012-4544.
Also make explicit checks for buffer overflows in various decompression routines. These were already ruled out due to other properties of the code but check them as a belt-and-braces measure.
stubdom/grub/kexec.c +4 -0
@@ -137,6 +137,10 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char dom =xc_dom_allocate (xc_handle, cmdline, features); dom->allocate = kexec_allocate; +/* We are using guest owned memory, therefore no limits. */ +xc_dom_kernel_max_size (dom,0 ); +xc_dom_ramdisk_max_size (dom,0 ); + dom->kernel_blob = kernel; dom->kernel_size = kernel_size;
tools/libxc/xc_dom.h +22 -1
@@ -52,6 +52,9 @@ struct xc_dom_image {void *ramdisk_blob;size_t ramdisk_size; +size_t max_kernel_size; +size_t max_ramdisk_size; +/* arguments and parameters */ char *cmdline;uint32_t f_requested[XENFEAT_NR_SUBMAPS ];
@@ -175,6 +178,23 @@ void xc_dom_release_phys(struct xc_dom_image *dom);void xc_dom_release (struct xc_dom_image *dom);int xc_dom_mem_init (struct xc_dom_image *dom,unsigned int mem_mb); +/* Set this larger if you have enormous ramdisks/kernels. Note that +* you should trust all kernels not to be maliciously large (e.g. to +* exhaust all dom0 memory) if you do this (see CVE-2012-4544 / +* XSA-25). You can also set the default independently for +* ramdisks/kernels in xc_dom_allocate() or call +* xc_dom_{kernel,ramdisk}_max_size. +*/ +#ifndef XC_DOM_DECOMPRESS_MAX +#define XC_DOM_DECOMPRESS_MAX (1024*1024*1024)/* 1GB */ +#endif + +int xc_dom_kernel_check_size (struct xc_dom_image *dom,size_t sz); +int xc_dom_kernel_max_size (struct xc_dom_image *dom,size_t sz); + +int xc_dom_ramdisk_check_size (struct xc_dom_image *dom,size_t sz); +int xc_dom_ramdisk_max_size (struct xc_dom_image *dom,size_t sz); +size_t xc_dom_check_gzip (xc_interface *xch,void *blob,size_t ziplen); int xc_dom_do_gunzip(xc_interface *xch,
@@ -224,7 +244,8 @@ void xc_dom_log_memory_footprint(struct xc_dom_image *dom);void *xc_dom_malloc (struct xc_dom_image *dom,size_t size);void *xc_dom_malloc_page_aligned (struct xc_dom_image *dom,size_t size);void *xc_dom_malloc_filemap (struct xc_dom_image *dom, -const char *filename,size_t * size); +const char *filename,size_t * size, +const size_t max_size);char *xc_dom_strdup (struct xc_dom_image *dom,const char *str);/* --- alloc memory pool ------------------------------------------- */
tools/libxc/xc_dom_bzimageloader.c +55 -4
121 lines not on this page · raw message
tools/libxc/xc_dom_core.c +73 -4
135 lines not on this page · raw message
tools/pygrub/src/pygrub +44 -17
87 lines not on this page · raw message
libxc: builder: limit maximum size of kernel/ramdisk.
Allowing user supplied kernels of arbitrary sizes, especially during decompression, can swallow up dom0 memory leading to either virtual address space exhaustion in the builder process or allocation failures/OOM killing of both toolstack and unrelated processes.
We disable these checks when building in a stub domain for pvgrub since this uses the guest's own memory and is isolated.
Decompression of gzip compressed kernels and ramdisks has been safe since 14954:58205257517d (Xen 3.1.0 onwards).
This is XSA-25 / CVE-2012-4544.
Also make explicit checks for buffer overflows in various decompression routines. These were already ruled out due to other properties of the code but check them as a belt-and-braces measure.
stubdom/grub/kexec.c +4 -0
@@ -137,6 +137,10 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char dom =xc_dom_allocate (xc_handle, cmdline, features); dom->allocate = kexec_allocate; +/* We are using guest owned memory, therefore no limits. */ +xc_dom_kernel_max_size (dom,0 ); +xc_dom_ramdisk_max_size (dom,0 ); + dom->kernel_blob = kernel; dom->kernel_size = kernel_size;
tools/libxc/xc_dom.h +22 -1
@@ -55,6 +55,9 @@ struct xc_dom_image {void *ramdisk_blob;size_t ramdisk_size; +size_t max_kernel_size; +size_t max_ramdisk_size; +/* arguments and parameters */ char *cmdline;uint32_t f_requested[XENFEAT_NR_SUBMAPS ];
@@ -180,6 +183,23 @@ void xc_dom_release_phys(struct xc_dom_image *dom);void xc_dom_release (struct xc_dom_image *dom);int xc_dom_mem_init (struct xc_dom_image *dom,unsigned int mem_mb); +/* Set this larger if you have enormous ramdisks/kernels. Note that +* you should trust all kernels not to be maliciously large (e.g. to +* exhaust all dom0 memory) if you do this (see CVE-2012-4544 / +* XSA-25). You can also set the default independently for +* ramdisks/kernels in xc_dom_allocate() or call +* xc_dom_{kernel,ramdisk}_max_size. +*/ +#ifndef XC_DOM_DECOMPRESS_MAX +#define XC_DOM_DECOMPRESS_MAX (1024*1024*1024)/* 1GB */ +#endif + +int xc_dom_kernel_check_size (struct xc_dom_image *dom,size_t sz); +int xc_dom_kernel_max_size (struct xc_dom_image *dom,size_t sz); + +int xc_dom_ramdisk_check_size (struct xc_dom_image *dom,size_t sz); +int xc_dom_ramdisk_max_size (struct xc_dom_image *dom,size_t sz); +size_t xc_dom_check_gzip (xc_interface *xch,void *blob,size_t ziplen); int xc_dom_do_gunzip(xc_interface *xch,
@@ -240,7 +260,8 @@ void xc_dom_log_memory_footprint(struct xc_dom_image *dom);void *xc_dom_malloc (struct xc_dom_image *dom,size_t size);void *xc_dom_malloc_page_aligned (struct xc_dom_image *dom,size_t size);void *xc_dom_malloc_filemap (struct xc_dom_image *dom, -const char *filename,size_t * size); +const char *filename,size_t * size, +const size_t max_size);char *xc_dom_strdup (struct xc_dom_image *dom,const char *str);/* --- alloc memory pool ------------------------------------------- */
tools/libxc/xc_dom_bzimageloader.c +55 -4
121 lines not on this page · raw message
tools/libxc/xc_dom_core.c +73 -4
135 lines not on this page · raw message
libxc: builder: limit maximum size of kernel/ramdisk.
Allowing user supplied kernels of arbitrary sizes, especially during decompression, can swallow up dom0 memory leading to either virtual address space exhaustion in the builder process or allocation failures/OOM killing of both toolstack and unrelated processes.
We disable these checks when building in a stub domain for pvgrub since this uses the guest's own memory and is isolated.
Decompression of gzip compressed kernels and ramdisks has been safe since 14954:58205257517d (Xen 3.1.0 onwards).
This is XSA-25 / CVE-2012-4544.
Also make explicit checks for buffer overflows in various decompression routines. These were already ruled out due to other properties of the code but check them as a belt-and-braces measure.
stubdom/grub/kexec.c +4 -0
@@ -137,6 +137,10 @@ void kexec(void *kernel, long kernel_siz dom =xc_dom_allocate (xc_handle, cmdline, features); dom->allocate = kexec_allocate; +/* We are using guest owned memory, therefore no limits. */ +xc_dom_kernel_max_size (dom,0 ); +xc_dom_ramdisk_max_size (dom,0 ); + dom->kernel_blob = kernel; dom->kernel_size = kernel_size;
tools/libxc/xc_dom.h +22 -1
@@ -55,6 +55,9 @@ struct xc_dom_image {void *ramdisk_blob;size_t ramdisk_size; +size_t max_kernel_size; +size_t max_ramdisk_size; +/* arguments and parameters */ char *cmdline;uint32_t f_requested[XENFEAT_NR_SUBMAPS ];
@@ -194,6 +197,23 @@ void xc_dom_release_phys(struct xc_dom_ivoid xc_dom_release (struct xc_dom_image *dom);int xc_dom_mem_init (struct xc_dom_image *dom,unsigned int mem_mb); +/* Set this larger if you have enormous ramdisks/kernels. Note that +* you should trust all kernels not to be maliciously large (e.g. to +* exhaust all dom0 memory) if you do this (see CVE-2012-4544 / +* XSA-25). You can also set the default independently for +* ramdisks/kernels in xc_dom_allocate() or call +* xc_dom_{kernel,ramdisk}_max_size. +*/ +#ifndef XC_DOM_DECOMPRESS_MAX +#define XC_DOM_DECOMPRESS_MAX (1024*1024*1024)/* 1GB */ +#endif + +int xc_dom_kernel_check_size (struct xc_dom_image *dom,size_t sz); +int xc_dom_kernel_max_size (struct xc_dom_image *dom,size_t sz); + +int xc_dom_ramdisk_check_size (struct xc_dom_image *dom,size_t sz); +int xc_dom_ramdisk_max_size (struct xc_dom_image *dom,size_t sz); +size_t xc_dom_check_gzip (xc_interface *xch,void *blob,size_t ziplen); int xc_dom_do_gunzip(xc_interface *xch,
@@ -254,7 +274,8 @@ void xc_dom_log_memory_footprint(structvoid *xc_dom_malloc (struct xc_dom_image *dom,size_t size);void *xc_dom_malloc_page_aligned (struct xc_dom_image *dom,size_t size);void *xc_dom_malloc_filemap (struct xc_dom_image *dom, -const char *filename,size_t * size); +const char *filename,size_t * size, +const size_t max_size);char *xc_dom_strdup (struct xc_dom_image *dom,const char *str);/* --- alloc memory pool ------------------------------------------- */
tools/libxc/xc_dom_bzimageloader.c +55 -4
121 lines not on this page · raw message
tools/libxc/xc_dom_core.c +73 -4
135 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel