Skip to content

Commit

Permalink
kernel/kexec_file.c: make purgatory_info->ehdr const
Browse files Browse the repository at this point in the history
The kexec_purgatory buffer is read-only.  Thus all pointers into
kexec_purgatory are read-only, too.  Point this out by explicitly
marking purgatory_info->ehdr as 'const' and update the comments in
purgatory_info.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Philipp Rudo <[email protected]>
Acked-by: Dave Young <[email protected]>
Cc: AKASHI Takahiro <[email protected]>
Cc: Eric Biederman <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Thiago Jung Bauermann <[email protected]>
Cc: Vivek Goyal <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Philipp Rudo authored and torvalds committed Apr 14, 2018
1 parent d2b8178 commit 65c225d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions include/linux/kexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ struct compat_kexec_segment {

#ifdef CONFIG_KEXEC_FILE
struct purgatory_info {
/* Pointer to elf header of read only purgatory */
Elf_Ehdr *ehdr;

/* Pointer to purgatory sechdrs which are modifiable */
/*
* Pointer to elf header at the beginning of kexec_purgatory.
* Note: kexec_purgatory is read only
*/
const Elf_Ehdr *ehdr;
/*
* Temporary, modifiable buffer for sechdrs used for relocation.
* This memory can be freed post image load.
*/
Elf_Shdr *sechdrs;
/*
* Temporary buffer location where purgatory is loaded and relocated
* This memory can be freed post image load
* Temporary, modifiable buffer for stripped purgatory used for
* relocation. This memory can be freed post image load.
*/
void *purgatory_buf;

Expand Down
4 changes: 2 additions & 2 deletions kernel/kexec_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min,
if (kexec_purgatory_size <= 0)
return -EINVAL;

pi->ehdr = (Elf_Ehdr *)kexec_purgatory;
pi->ehdr = (const Elf_Ehdr *)kexec_purgatory;

ret = __kexec_load_purgatory(image, min, max, top_down);
if (ret)
Expand All @@ -965,9 +965,9 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min,
static Elf_Sym *kexec_purgatory_find_symbol(struct purgatory_info *pi,
const char *name)
{
const Elf_Ehdr *ehdr;
Elf_Sym *syms;
Elf_Shdr *sechdrs;
Elf_Ehdr *ehdr;
int i, k;
const char *strtab;

Expand Down

0 comments on commit 65c225d

Please sign in to comment.