arm64: add __nocfi to __apply_alternatives
authorSami Tolvanen <samitolvanen@google.com>
Thu, 8 Apr 2021 18:28:40 +0000 (11:28 -0700)
committerKees Cook <keescook@chromium.org>
Thu, 8 Apr 2021 23:04:23 +0000 (16:04 -0700)
__apply_alternatives makes indirect calls to functions whose address
is taken in assembly code using the alternative_cb macro. With
non-canonical CFI, the compiler won't replace these function
references with the jump table addresses, which trips CFI. Disable CFI
checking in the function to work around the issue.

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-16-samitolvanen@google.com
arch/arm64/kernel/alternative.c

index 1184c44..abc8463 100644 (file)
@@ -133,8 +133,8 @@ static void clean_dcache_range_nopatch(u64 start, u64 end)
        } while (cur += d_size, cur < end);
 }
 
-static void __apply_alternatives(void *alt_region,  bool is_module,
-                                unsigned long *feature_mask)
+static void __nocfi __apply_alternatives(void *alt_region,  bool is_module,
+                                        unsigned long *feature_mask)
 {
        struct alt_instr *alt;
        struct alt_region *region = alt_region;