Skip to content

Commit 42d720d

Browse files
Nikolay Borisovkees
authored andcommitted
ARM: kexec: Make .text R/W in machine_kexec
With the introduction of Kees Cook's patch to make the kernel .text read-only the existing method by which kexec works got broken since it directly pokes some values in the template code, which resides in the .text section. The current patch changes the way those values are inserted so that poking .text section occurs only in machine_kexec (e.g when we are about to nuke the old kernel and are beyond the point of return). This allows to use set_kernel_text_rw() to directly patch the values in the .text section. I had already sent a patch which achieved this but it was significantly more complicated, so this is a cleaner/straight-forward approach. Signed-off-by: Nikolay Borisov <Nikolay.Borisov@arm.com> Acked-by: Will Deacon <will.deacon@arm.com> [kees: collapsed kexec_boot_atags (will.daecon)] [kees: for bisectability, moved set_kernel_text_rw() to RODATA patch] Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Nicolas Pitre <nico@linaro.org>
1 parent ab0615e commit 42d720d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/arm/kernel/machine_kexec.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern unsigned long kexec_boot_atags;
2929

3030
static atomic_t waiting_for_crash_ipi;
3131

32+
static unsigned long dt_mem;
3233
/*
3334
* Provide a dummy crash_notes definition while crash dump arrives to arm.
3435
* This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
@@ -64,7 +65,7 @@ int machine_kexec_prepare(struct kimage *image)
6465
return err;
6566

6667
if (be32_to_cpu(header) == OF_DT_HEADER)
67-
kexec_boot_atags = current_segment->mem;
68+
dt_mem = current_segment->mem;
6869
}
6970
return 0;
7071
}
@@ -166,9 +167,8 @@ void machine_kexec(struct kimage *image)
166167
kexec_start_address = image->start;
167168
kexec_indirection_page = page_list;
168169
kexec_mach_type = machine_arch_type;
169-
if (!kexec_boot_atags)
170-
kexec_boot_atags = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET;
171-
170+
kexec_boot_atags = dt_mem ?: image->start - KEXEC_ARM_ZIMAGE_OFFSET
171+
+ KEXEC_ARM_ATAGS_OFFSET;
172172

173173
/* copy our kernel relocation code to the control code page */
174174
reboot_entry = fncpy(reboot_code_buffer,

0 commit comments

Comments
 (0)