[PATCH 03/13] vmcore: fill unused part of buffer for ELF headers with 0

HATAYAMA Daisuke d.hatayama at jp.fujitsu.com
Thu Feb 14 05:11:59 EST 2013


Via mmap() we export the range [elfcorebuf_sz, roundup(elfcorebuf_sz,
PAGE_SIZE)] to user-space. We need to fill this range with 0.

Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
---

 fs/proc/vmcore.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 5010ead..43d338a 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -328,6 +328,11 @@ static int __init merge_note_headers_elf64(char *elfptr, size_t *elfsz,
 	*elfsz = *elfsz - i;
 	memmove(tmp, tmp+i, ((*elfsz)-sizeof(Elf64_Ehdr)-sizeof(Elf64_Phdr)));
 
+	/* Fill unused part with zero */
+	memset(elfptr + sizeof(Elf64_Ehdr) +
+	       (ehdr_ptr->e_phnum - nr_ptnote + 1) * sizeof(Elf64_Phdr), 0,
+	       (nr_ptnote - 1) * sizeof(Elf64_Phdr));
+
 	/* Modify e_phnum to reflect merged headers. */
 	ehdr_ptr->e_phnum = ehdr_ptr->e_phnum - nr_ptnote + 1;
 




More information about the kexec mailing list