summaryrefslogtreecommitdiff
path: root/kexec/kexec-elf.c
diff options
context:
space:
mode:
authorCliff Wickman <cpw@sgi.com>2010-08-23 16:18:05 -0500
committerSimon Horman <horms@verge.net.au>2010-08-24 10:22:02 +0900
commit242acd25db83d99a8f6ea48d14c215dd64f3635f (patch)
treea118d4b205885a3f3c103cd68954e4bea833d943 /kexec/kexec-elf.c
parent3f2012bd7947ec327dc942ab91f115388630cc36 (diff)
kexec: extend KCORE_ELF_HEADERS_SIZE for large memory
A customer has seen the kexec command exhaust its buffer for the ELF headers from /proc/kcore. It found 147 program headers, which requires a buffer of over 8k. (This overflow was on an SGI UV with an extremely large memory, hence many ram ranges.) The default buffer size of 4k is configured in KCORE_ELF_HEADERS_SIZE. The easy solution would probably be to increase the buffer to 16k. That is room for 291 entries, on x86_64. You might want to make the command dynamically enlarge the buffer when it is found to be too small, but I don't think this command's use of a little more memory is of concern. So there is probably no reason to change the program logic in this area. Diffed against kexec-tools-2.0.2 Signed-off-by: Cliff Wickman <cpw@sgi.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/kexec-elf.c')
-rw-r--r--kexec/kexec-elf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kexec/kexec-elf.c b/kexec/kexec-elf.c
index 85d1765..1cdae36 100644
--- a/kexec/kexec-elf.c
+++ b/kexec/kexec-elf.c
@@ -8,6 +8,7 @@
#include <boot/elf_boot.h>
#include "kexec.h"
#include "kexec-elf.h"
+#include "crashdump.h"
static const int probe_debug = 0;
@@ -389,6 +390,9 @@ 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");
}