From: Ian Jackson Subject: Re: [PATCH 4 00/16] XSA55 libelf fixes for unstable Date: Wed, 5 Jun 2013 12:53:04 +0100 Message-ID: <20911.9888.259660.722857@mariner.uk.xensource.com> References: <1370368803-9436-1-git-send-email-ian.jackson@eu.citrix.com> <20910.11527.520166.95800@mariner.uk.xensource.com> <51AE5EAC.8080905@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <51AE5EAC.8080905@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: "xen-devel@lists.xensource.com" , "mattjd@gmail.com" , "security@xen.org" List-Id: xen-devel@lists.xenproject.org Andrew Cooper writes ("Re: [PATCH 4 00/16] XSA55 libelf fixes for unstable"): > Xen warning: dom0 kernel broken ELF: program segments total to more > than the input image size I had a total brain fart when I wrote this, and forgot about uninitialised data. I think this patch (added to the end of the series) should fix it. If you report success I intend to provide a v5 of my series with this integrated in its proper place. Thanks, Ian. Signed-off-by: Ian Jackson diff --git a/xen/common/libelf/libelf-loader.c b/xen/common/libelf/libelf-loader.c index fbc8de7..1e3c869 100644 --- a/xen/common/libelf/libelf-loader.c +++ b/xen/common/libelf/libelf-loader.c @@ -298,7 +298,12 @@ elf_errorstatus elf_load_binary(struct elf_binary *elf) ELF_HANDLE_DECL(elf_phdr) phdr; uint64_t i, count, paddr, offset, filesz, memsz; elf_ptrval dest; - elf_ptrval remain_allow_copy = elf->size; + uint64_t remain_allow_copy = (uint64_t)elf->dest_size * 2; + /* + * Let bizarre ELFs write the output image up to twice; this + * calculation is just to ensure our copying loop is no worse than + * O(domain_size). + */ count = elf_uval(elf, elf->ehdr, e_phnum); for ( i = 0; i < count; i++ )