diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2010-09-07 20:31:03 -0700 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2010-09-09 17:02:54 +0900 |
commit | b16f811bb13c44e24425ee96d848ca04838b7d77 (patch) | |
tree | 1b09f35b3753a6e4ed64295ca40ec4451ff7304f /kexec | |
parent | 5944fe4d86abf4571dbf915c4ea31cc1a5e3351d (diff) |
kexec elf: Clean up error messages build_mem_phdrs
Don't print uncondintionally print an error message about
KCORE_ELF_HEADERS_SIZE being wrong when the elf headers
are truncated when build_mem_phdrs fails because there
are other reasons we could be truncated (like an
actual damaged elf file).
Instead only print an error message when either probe_debug
is true or we are skipping the total file size checks for
some reason. When we do print an error message limit the
message to the fact that we are truncated and how many
bytes we have and how many bytes we need. The context
of the failure should be able to provide the rest of
the information.
For now add a comment in crashdump-x86_64.c to direct people
to KCORE_ELF_HEADERS_SIZE so that if someone finds the
code things can be adjusted.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec')
-rw-r--r-- | kexec/arch/x86_64/crashdump-x86_64.c | 1 | ||||
-rw-r--r-- | kexec/kexec-elf.c | 10 |
2 files changed, 6 insertions, 5 deletions
diff --git a/kexec/arch/x86_64/crashdump-x86_64.c b/kexec/arch/x86_64/crashdump-x86_64.c index a6ad89c..fc2dd91 100644 --- a/kexec/arch/x86_64/crashdump-x86_64.c +++ b/kexec/arch/x86_64/crashdump-x86_64.c @@ -120,6 +120,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *info, elf_flags |= ELF_SKIP_FILESZ_CHECK; result = build_elf_core_info(buf, size, &ehdr, elf_flags); if (result < 0) { + /* Perhaps KCORE_ELF_HEADERS_SIZE is too small? */ fprintf(stderr, "ELF core (kcore) parse failed\n"); return -1; } diff --git a/kexec/kexec-elf.c b/kexec/kexec-elf.c index 1cdae36..75396ce 100644 --- a/kexec/kexec-elf.c +++ b/kexec/kexec-elf.c @@ -390,11 +390,11 @@ static int build_mem_phdrs(const char *buf, off_t len, struct mem_ehdr *ehdr, phdr_size *= ehdr->e_phnum; if ((uintmax_t)(ehdr->e_phoff + phdr_size) > (uintmax_t)len) { /* The program header did not fit in the file buffer */ - fprintf(stderr, "%d segments require a %ld-byte buffer\n", - ehdr->e_phnum, ehdr->e_phoff + phdr_size); - fprintf(stderr, "KCORE_ELF_HEADERS_SIZE %d too small\n", KCORE_ELF_HEADERS_SIZE); - if (probe_debug) { - fprintf(stderr, "ELF program segment truncated\n"); + if (probe_debug || (flags & ELF_SKIP_FILESZ_CHECK)) { + fprintf(stderr, "ELF program headers truncated" + " have %ju bytes need %ju bytes\n", + (uintmax_t)len, + (uintmax_t)(ehdr->e_phoff + phdr_size)); } return -1; } |