Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88f78b7e authored by Sami Tolvanen's avatar Sami Tolvanen
Browse files

ANDROID: x86: map CFI jump tables in pti_clone_entry_text



Allow CFI enabled entry code to make indirect calls by also mapping
CFI jump tables, and add a check to ensure the jump table section is
not empty.

Bug: 145297900
Change-Id: I1204c50a139ba62234f3bb4699c50921a831162b
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent 9c7e3869
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#include <asm/extable.h>

extern char __brk_base[], __brk_limit[];
extern char __cfi_jt_start[], __cfi_jt_end[];
extern char __end_rodata_aligned[];

#if defined(CONFIG_X86_64)
+11 −0
Original line number Diff line number Diff line
@@ -141,6 +141,13 @@ SECTIONS
		*(.text.__x86.indirect_thunk)
		__indirect_thunk_end = .;
#endif

#ifdef CONFIG_CFI_CLANG
		. = ALIGN(PAGE_SIZE);
		__cfi_jt_start = .;
		*(.text..L.cfi.jumptable .text..L.cfi.jumptable.*)
		__cfi_jt_end = .;
#endif
	} :text = 0x9090

	NOTES :text :note
@@ -457,3 +464,7 @@ INIT_PER_CPU(irq_stack_backing_store);
           "kexec control code size is too big");
#endif

#ifdef CONFIG_CFI_CLANG
. = ASSERT((__cfi_jt_end - __cfi_jt_start > 0),
	   "CFI jump table is empty");
#endif
+9 −0
Original line number Diff line number Diff line
@@ -505,6 +505,15 @@ static void pti_clone_entry_text(void)
	pti_clone_pgtable((unsigned long) __entry_text_start,
			  (unsigned long) __irqentry_text_end,
			  PTI_CLONE_PMD);

	/*
	 * If CFI is enabled, also map jump tables, so the entry code can
	 * make indirect calls.
	 */
	if (IS_ENABLED(CONFIG_CFI_CLANG))
		pti_clone_pgtable((unsigned long) __cfi_jt_start,
				  (unsigned long) __cfi_jt_end,
				  PTI_CLONE_PMD);
}

/*