The patch titled Subject: kernel/kexec_file.c: make purgatory_info->ehdr const has been added to the -mm tree. Its filename is kexec_file-make-purgatory_info-ehdr-const.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/kexec_file-make-purgatory_info-ehdr-const.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/kexec_file-make-purgatory_info-ehdr-const.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Philipp Rudo <prudo@xxxxxxxxxxxxxxxxxx> Subject: kernel/kexec_file.c: make purgatory_info->ehdr const 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/20180321112751.22196-4-prudo@xxxxxxxxxxxxxxxxxx Signed-off-by: Philipp Rudo <prudo@xxxxxxxxxxxxxxxxxx> Cc: AKASHI Takahiro <takahiro.akashi@xxxxxxxxxx> Cc: Dave Young <dyoung@xxxxxxxxxx> Cc: Eric Biederman <ebiederm@xxxxxxxxxxxx> Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Thiago Jung Bauermann <bauerman@xxxxxxxxxxxxxxxxxx> Cc: Vivek Goyal <vgoyal@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/kexec.h | 17 +++++++++++------ kernel/kexec_file.c | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff -puN include/linux/kexec.h~kexec_file-make-purgatory_info-ehdr-const include/linux/kexec.h --- a/include/linux/kexec.h~kexec_file-make-purgatory_info-ehdr-const +++ a/include/linux/kexec.h @@ -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; diff -puN kernel/kexec_file.c~kexec_file-make-purgatory_info-ehdr-const kernel/kexec_file.c --- a/kernel/kexec_file.c~kexec_file-make-purgatory_info-ehdr-const +++ a/kernel/kexec_file.c @@ -983,7 +983,7 @@ int kexec_load_purgatory(struct kimage * 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) @@ -1007,9 +1007,9 @@ out: 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; _ Patches currently in -mm which might be from prudo@xxxxxxxxxxxxxxxxxx are kexec_file-silence-compile-warnings.patch kexec_file-remove-checks-in-kexec_purgatory_load.patch kexec_file-make-purgatory_info-ehdr-const.patch kexec_file-search-symbols-in-read-only-kexec_purgatory.patch kexec_file-use-read-only-sections-in-arch_kexec_apply_relocations.patch kexec_file-split-up-__kexec_load_puragory.patch kexec_file-remove-unneeded-for-loop-in-kexec_purgatory_setup_sechdrs.patch kexec_file-remove-unneeded-variables-in-kexec_purgatory_setup_sechdrs.patch kexec_file-remove-mis-use-of-sh_offset-field-during-purgatory-load.patch kexec_file-allow-archs-to-set-purgatory-load-address.patch kexec_file-move-purgatories-sha256-to-common-code.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html