Skip to content

Commit

Permalink
powerpc/fadump: use the correct VMCOREINFO_NOTE_SIZE for phdr
Browse files Browse the repository at this point in the history
vmcoreinfo_max_size stands for the vmcoreinfo_data, the correct one we
should use is vmcoreinfo_note whose total size is VMCOREINFO_NOTE_SIZE.

Like explained in commit 7701996 ("kdump: fix exported size of
vmcoreinfo note"), it should not affect the actual function, but we
better fix it, also this change should be safe and backward compatible.

After this, we can get rid of variable vmcoreinfo_max_size, let's use
the corresponding macros directly, fewer variables means more safety for
vmcoreinfo operation.

[[email protected]: fix build warning]
  Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Xunlei Pang <[email protected]>
Reviewed-by: Mahesh Salgaonkar <[email protected]>
Reviewed-by: Dave Young <[email protected]>
Cc: Hari Bathini <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Eric Biederman <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Michael Holzheu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Xunlei Pang authored and torvalds committed Jul 12, 2017
1 parent 203e9e4 commit 5203f49
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
3 changes: 1 addition & 2 deletions arch/powerpc/kernel/fadump.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,8 +999,7 @@ static int fadump_create_elfcore_headers(char *bufp)

phdr->p_paddr = fadump_relocate(paddr_vmcoreinfo_note());
phdr->p_offset = phdr->p_paddr;
phdr->p_memsz = vmcoreinfo_max_size;
phdr->p_filesz = vmcoreinfo_max_size;
phdr->p_memsz = phdr->p_filesz = VMCOREINFO_NOTE_SIZE;

/* Increment number of program headers. */
(elf->e_phnum)++;
Expand Down
1 change: 0 additions & 1 deletion include/linux/crash_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ phys_addr_t paddr_vmcoreinfo_note(void);

extern u32 *vmcoreinfo_note;
extern size_t vmcoreinfo_size;
extern size_t vmcoreinfo_max_size;

Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type,
void *data, size_t data_len);
Expand Down
3 changes: 1 addition & 2 deletions kernel/crash_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
/* vmcoreinfo stuff */
static unsigned char *vmcoreinfo_data;
size_t vmcoreinfo_size;
size_t vmcoreinfo_max_size = VMCOREINFO_BYTES;
u32 *vmcoreinfo_note;

/*
Expand Down Expand Up @@ -343,7 +342,7 @@ void vmcoreinfo_append_str(const char *fmt, ...)
r = vscnprintf(buf, sizeof(buf), fmt, args);
va_end(args);

r = min(r, vmcoreinfo_max_size - vmcoreinfo_size);
r = min(r, (size_t)VMCOREINFO_BYTES - vmcoreinfo_size);

memcpy(&vmcoreinfo_data[vmcoreinfo_size], buf, r);

Expand Down

0 comments on commit 5203f49

Please sign in to comment.