brintos

brintos / linux-shallow public Read only

0
0
Text · 1.2 KiB · f0df518 Raw
54 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Clang Control Flow Integrity (CFI) support.4 *5 * Copyright (C) 2022 Google LLC6 */7#ifndef _LINUX_CFI_H8#define _LINUX_CFI_H9 10#include <linux/bug.h>11#include <linux/module.h>12#include <asm/cfi.h>13 14#ifndef cfi_get_offset15static inline int cfi_get_offset(void)16{17	return 0;18}19#endif20 21#ifdef CONFIG_CFI_CLANG22enum bug_trap_type report_cfi_failure(struct pt_regs *regs, unsigned long addr,23				      unsigned long *target, u32 type);24 25static inline enum bug_trap_type report_cfi_failure_noaddr(struct pt_regs *regs,26							   unsigned long addr)27{28	return report_cfi_failure(regs, addr, NULL, 0);29}30#endif /* CONFIG_CFI_CLANG */31 32#ifdef CONFIG_ARCH_USES_CFI_TRAPS33bool is_cfi_trap(unsigned long addr);34#else35static inline bool is_cfi_trap(unsigned long addr) { return false; }36#endif37 38#ifdef CONFIG_MODULES39#ifdef CONFIG_ARCH_USES_CFI_TRAPS40void module_cfi_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,41			 struct module *mod);42#else43static inline void module_cfi_finalize(const Elf_Ehdr *hdr,44				       const Elf_Shdr *sechdrs,45				       struct module *mod) {}46#endif /* CONFIG_ARCH_USES_CFI_TRAPS */47#endif /* CONFIG_MODULES */48 49#ifndef CFI_NOSEAL50#define CFI_NOSEAL(x)51#endif52 53#endif /* _LINUX_CFI_H */54