All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: fix an issue with kaslr-enabled vmlinux
@ 2017-08-24  7:32 AKASHI Takahiro
  2018-02-02 18:34 ` Goel, Sameer
  0 siblings, 1 reply; 2+ messages in thread
From: AKASHI Takahiro @ 2017-08-24  7:32 UTC (permalink / raw)
  To: horms; +Cc: AKASHI Takahiro, kexec

Normally vmlinux for arm64 is of ET_EXEC type, while if built with
CONFIG_RANDAMIZE_BASE (that is KASLR), it will be of ET_DYN type.
Meanwhile, physical address field of segments in vmlinux has actually
the same value as virtual address field.

Accordingly, in this case, it totally makes no sense to check for
validity of segments against physical memory ranges and, if necessary,
relocate them in elf_exec_load() on arm64.

This patch allows to unconditionally skip the check on arm64.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 include/elf.h          | 3 ++-
 kexec/kexec-elf-exec.c | 6 +++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/elf.h b/include/elf.h
index 5db637b..b7677a2 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -258,7 +258,8 @@ typedef struct
 #define EM_OPENRISC	92		/* OpenRISC 32-bit embedded processor */
 #define EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
 #define EM_XTENSA	94		/* Tensilica Xtensa Architecture */
-#define EM_NUM		95
+#define EM_AARCH64	183		/* ARM AARCH64 */
+#define EM_NUM		184
 
 /* If it is necessary to assign new unofficial EM_* values, please
    pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
diff --git a/kexec/kexec-elf-exec.c b/kexec/kexec-elf-exec.c
index cb62d04..a9329ac 100644
--- a/kexec/kexec-elf-exec.c
+++ b/kexec/kexec-elf-exec.c
@@ -63,9 +63,13 @@ int elf_exec_load(struct mem_ehdr *ehdr, struct kexec_info *info)
 
 	/* If I have a dynamic executable find it's size
 	 * and then find a location for it in memory.
+	 * Note on arm64:
+	 * arm64's vmlinux has virtual address in physical address
+	 * field of PT_LOAD segments. So the following validity check
+	 * and relocation makes no sense on arm64.
 	 */
 	base = 0;
-	if (ehdr->e_type == ET_DYN) {
+	if ((ehdr->e_machine != EM_AARCH64) && (ehdr->e_type == ET_DYN)) {
 		unsigned long first, last, align;
 		first = ULONG_MAX;
 		last  = 0;
-- 
2.14.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] arm64: fix an issue with kaslr-enabled vmlinux
  2017-08-24  7:32 [PATCH] arm64: fix an issue with kaslr-enabled vmlinux AKASHI Takahiro
@ 2018-02-02 18:34 ` Goel, Sameer
  0 siblings, 0 replies; 2+ messages in thread
From: Goel, Sameer @ 2018-02-02 18:34 UTC (permalink / raw)
  To: kexec

I tested this fix and it works well. I am wondering which kexec tool release will pick this fix?

On 8/24/2017 1:32 AM, AKASHI Takahiro wrote:
> Normally vmlinux for arm64 is of ET_EXEC type, while if built with
> CONFIG_RANDAMIZE_BASE (that is KASLR), it will be of ET_DYN type.
> Meanwhile, physical address field of segments in vmlinux has actually
> the same value as virtual address field.
> 
> Accordingly, in this case, it totally makes no sense to check for
> validity of segments against physical memory ranges and, if necessary,
> relocate them in elf_exec_load() on arm64.
> 
> This patch allows to unconditionally skip the check on arm64.
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  include/elf.h          | 3 ++-
>  kexec/kexec-elf-exec.c | 6 +++++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/include/elf.h b/include/elf.h
> index 5db637b..b7677a2 100644
> --- a/include/elf.h
> +++ b/include/elf.h
> @@ -258,7 +258,8 @@ typedef struct
>  #define EM_OPENRISC	92		/* OpenRISC 32-bit embedded processor */
>  #define EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
>  #define EM_XTENSA	94		/* Tensilica Xtensa Architecture */
> -#define EM_NUM		95
> +#define EM_AARCH64	183		/* ARM AARCH64 */
> +#define EM_NUM		184
>  
>  /* If it is necessary to assign new unofficial EM_* values, please
>     pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
> diff --git a/kexec/kexec-elf-exec.c b/kexec/kexec-elf-exec.c
> index cb62d04..a9329ac 100644
> --- a/kexec/kexec-elf-exec.c
> +++ b/kexec/kexec-elf-exec.c
> @@ -63,9 +63,13 @@ int elf_exec_load(struct mem_ehdr *ehdr, struct kexec_info *info)
>  
>  	/* If I have a dynamic executable find it's size
>  	 * and then find a location for it in memory.
> +	 * Note on arm64:
> +	 * arm64's vmlinux has virtual address in physical address
> +	 * field of PT_LOAD segments. So the following validity check
> +	 * and relocation makes no sense on arm64.
>  	 */
>  	base = 0;
> -	if (ehdr->e_type == ET_DYN) {
> +	if ((ehdr->e_machine != EM_AARCH64) && (ehdr->e_type == ET_DYN)) {
>  		unsigned long first, last, align;
>  		first = ULONG_MAX;
>  		last  = 0;
> 

-- 
 Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-02 18:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-24  7:32 [PATCH] arm64: fix an issue with kaslr-enabled vmlinux AKASHI Takahiro
2018-02-02 18:34 ` Goel, Sameer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.