From b16f811bb13c44e24425ee96d848ca04838b7d77 Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Tue, 7 Sep 2010 20:31:03 -0700 Subject: 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 Signed-off-by: Simon Horman --- kexec/kexec-elf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'kexec/kexec-elf.c') 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; } -- cgit