arm64: add __nocfi to functions that jump to a physical address
authorSami Tolvanen <samitolvanen@google.com>
Thu, 8 Apr 2021 18:28:39 +0000 (11:28 -0700)
committerKees Cook <keescook@chromium.org>
Thu, 8 Apr 2021 23:04:22 +0000 (16:04 -0700)
Disable CFI checking for functions that switch to linear mapping and
make an indirect call to a physical address, since the compiler only
understands virtual addresses and the CFI check for such indirect calls
would always fail.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210408182843.1754385-15-samitolvanen@google.com
arch/arm64/include/asm/mmu_context.h
arch/arm64/kernel/cpu-reset.h
arch/arm64/kernel/cpufeature.c

index 386b96400a575209d22269bdda8b2f6c57834819..d3cef91335396c8df517d621250f361cba6fe434 100644 (file)
@@ -119,7 +119,7 @@ static inline void cpu_install_idmap(void)
  * Atomically replaces the active TTBR1_EL1 PGD with a new VA-compatible PGD,
  * avoiding the possibility of conflicting TLB entries being allocated.
  */
-static inline void cpu_replace_ttbr1(pgd_t *pgdp)
+static inline void __nocfi cpu_replace_ttbr1(pgd_t *pgdp)
 {
        typedef void (ttbr_replace_func)(phys_addr_t);
        extern ttbr_replace_func idmap_cpu_replace_ttbr1;
index f3adc574f9698c1576bc2087980d1288f544db50..9a7b1262ef17a3a6462ffc31d2974f199f5a31c1 100644 (file)
 void __cpu_soft_restart(unsigned long el2_switch, unsigned long entry,
        unsigned long arg0, unsigned long arg1, unsigned long arg2);
 
-static inline void __noreturn cpu_soft_restart(unsigned long entry,
-                                              unsigned long arg0,
-                                              unsigned long arg1,
-                                              unsigned long arg2)
+static inline void __noreturn __nocfi cpu_soft_restart(unsigned long entry,
+                                                      unsigned long arg0,
+                                                      unsigned long arg1,
+                                                      unsigned long arg2)
 {
        typeof(__cpu_soft_restart) *restart;
 
index 0b2e0d7b13ec168dc1104f308ffc6b54cb1868cd..c2f94a5206e0d32af9b55f9cb71604cfca1c498a 100644 (file)
@@ -1445,7 +1445,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
 }
 
 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
-static void
+static void __nocfi
 kpti_install_ng_mappings(const struct arm64_cpu_capabilities *__unused)
 {
        typedef void (kpti_remap_fn)(int, int, phys_addr_t);