]> xenbits.xensource.com Git - xen.git/commit
xen/gunzip: Allow perform_gunzip() to be called multiple times
authorJulien Grall <jgrall@amazon.com>
Wed, 3 Mar 2021 19:27:56 +0000 (19:27 +0000)
committerJulien Grall <jgrall@amazon.com>
Tue, 6 Apr 2021 18:30:33 +0000 (19:30 +0100)
commit33bc2a8495f755510f63629ed3f011134416310c
treebda4d01a7955da14cb41a37874aa17db13373bdc
parent3b368340c41823e24559192ccd158cf071bf4a8f
xen/gunzip: Allow perform_gunzip() to be called multiple times

Currently perform_gunzip() can only be called once because the
the internal state (e.g allocate) is not fully re-initialized.

This works fine if you are only booting dom0. But this will break when
booting multiple using the dom0less that uses compressed kernel images.

This can be resolved by re-initializing bytes_out, malloc_ptr,
malloc_count every time perform_gunzip() is called.

Note the latter is only re-initialized for hardening purpose as there is
no guarantee that every malloc() are followed by free() (It should in
theory!).

Take the opportunity to check the return of alloc_heap_pages() to return
an error rather than dereferencing a NULL pointer later on failure.

Reported-by: Charles Chiou <cchiou@ambarella.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/gunzip.c
xen/common/inflate.c