]> git.baikalelectronics.ru Git - kernel.git/commitdiff
kernel/kexec_file.c: make purgatory_info->ehdr const
authorPhilipp Rudo <prudo@linux.vnet.ibm.com>
Fri, 13 Apr 2018 22:36:17 +0000 (15:36 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Apr 2018 00:10:28 +0000 (17:10 -0700)
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@linux.vnet.ibm.com
Signed-off-by: Philipp Rudo <prudo@linux.vnet.ibm.com>
Acked-by: Dave Young <dyoung@redhat.com>
Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/kexec.h
kernel/kexec_file.c

index 08b8b9d00f97254839718ce33ab89290f17a75c9..8c5819d1a808360cd836ea059f1240336aa267b5 100644 (file)
@@ -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;
 
index 81ba4f782486c83dd1886e377d89cf0df67f6401..12cf9c9ff0bc634f50dd17d5d1027ef41f0cfa5e 100644 (file)
@@ -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)
@@ -965,9 +965,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;