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