Commit | Line | Data |
---|---|---|
cf68fffb ST |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | /* | |
3 | * Clang Control Flow Integrity (CFI) support. | |
4 | * | |
89245600 | 5 | * Copyright (C) 2022 Google LLC |
cf68fffb ST |
6 | */ |
7 | #ifndef _LINUX_CFI_H | |
8 | #define _LINUX_CFI_H | |
9 | ||
89245600 ST |
10 | #include <linux/bug.h> |
11 | #include <linux/module.h> | |
12 | ||
cf68fffb | 13 | #ifdef CONFIG_CFI_CLANG |
89245600 ST |
14 | enum bug_trap_type report_cfi_failure(struct pt_regs *regs, unsigned long addr, |
15 | unsigned long *target, u32 type); | |
cf68fffb | 16 | |
89245600 ST |
17 | static inline enum bug_trap_type report_cfi_failure_noaddr(struct pt_regs *regs, |
18 | unsigned long addr) | |
19 | { | |
20 | return report_cfi_failure(regs, addr, NULL, 0); | |
21 | } | |
cf68fffb | 22 | |
89245600 ST |
23 | #ifdef CONFIG_ARCH_USES_CFI_TRAPS |
24 | bool is_cfi_trap(unsigned long addr); | |
25 | #endif | |
cf68fffb ST |
26 | #endif /* CONFIG_CFI_CLANG */ |
27 | ||
89245600 ST |
28 | #ifdef CONFIG_MODULES |
29 | #ifdef CONFIG_ARCH_USES_CFI_TRAPS | |
30 | void module_cfi_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, | |
31 | struct module *mod); | |
32 | #else | |
33 | static inline void module_cfi_finalize(const Elf_Ehdr *hdr, | |
34 | const Elf_Shdr *sechdrs, | |
35 | struct module *mod) {} | |
36 | #endif /* CONFIG_ARCH_USES_CFI_TRAPS */ | |
37 | #endif /* CONFIG_MODULES */ | |
38 | ||
cf68fffb | 39 | #endif /* _LINUX_CFI_H */ |