lkml.org 
[lkml]   [2013]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 01/20] vmcore: refer to e_phoff member explicitly
From
From: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Subject: Re: [PATCH v2 01/20] vmcore: refer to e_phoff member explicitly
Date: Sun, 10 Mar 2013 14:46:31 +0800

> 于 2013年03月05日 15:35, Zhang Yanfei 写道:
>> 于 2013年03月02日 16:35, HATAYAMA Daisuke 写道:
<cut>
>
> One minor suggestion.
>
> Previously, when the code assumes program headers are following immediately
> the ELF header, it uses
>
> elfcorebuf_sz = sizeof(Elf64_Ehdr) + ehdr.e_phnum * sizeof(Elf64_Phdr);
>
> to calculate the size of ELF header and ELF program headers
>
> This patch avoids the assumption, and uses ehdr.e_phoff to get the program
> headers' address. But it will read unrelated contents into elfcorebuf if
> program headers are not following immediately the ELF header. So could the
> code be:
>
> elfcorebuf_sz = sizeof(Elf64_Ehdr) + ehdr.e_phnum * sizeof(Elf64_Phdr);
> addr = elfcorehdr_addr + ehdr.e_phoff;
> memcpy(elfcorebuf, &ehdr, sizeof(Elf64_Ehdr));
> read_from_oldmem(elfcorebuf + sizeof(Elf64_Ehdr), elfcorebuf_sz -
> sizeof(Elf64_Ehdr), &addr, 0);
> (Elf64_Ehdr *)elfcorebuf->e_phoff = sizeof(Elf64_Ehdr);

Thanks. This is not minor suggestion. This is critical. My code is
completely broken. On ELF, segments and headers other than ELF header
can occur in any positions. This means program header table can occur
after segments. So, on terabyte systems, e_phoff can be more than
terabytes.

Sorry, this was due to my carelessness.

Thanks.
HATAYAMA, Daisuke



\
 
 \ /
  Last update: 2013-03-11 02:01    [W:0.081 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site