From 01573e231f18eb2d99162747186f59511f56b64d Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Fri, 08 Dec 2023 10:40:48 +0000 Subject: [PATCH] 移去rt --- kernel/include/linux/cfi.h | 45 ++++++++++++++++++++++++--------------------- 1 files changed, 24 insertions(+), 21 deletions(-) diff --git a/kernel/include/linux/cfi.h b/kernel/include/linux/cfi.h index e27033d..b381c6c 100644 --- a/kernel/include/linux/cfi.h +++ b/kernel/include/linux/cfi.h @@ -1,38 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Clang Control Flow Integrity (CFI) support. + * + * Copyright (C) 2019 Google LLC + */ #ifndef _LINUX_CFI_H #define _LINUX_CFI_H -#include <linux/stringify.h> - #ifdef CONFIG_CFI_CLANG -#ifdef CONFIG_MODULES - -typedef void (*cfi_check_fn)(uint64_t, void *, void *); +typedef void (*cfi_check_fn)(uint64_t id, void *ptr, void *diag); /* Compiler-generated function in each module, and the kernel */ -#define CFI_CHECK_FN __cfi_check -#define CFI_CHECK_FN_NAME __stringify(CFI_CHECK_FN) +extern void __cfi_check(uint64_t id, void *ptr, void *diag); -extern void CFI_CHECK_FN(uint64_t, void *, void *); +/* + * Force the compiler to generate a CFI jump table entry for a function + * and store the jump table address to __cfi_jt_<function>. + */ +#define __CFI_ADDRESSABLE(fn) \ + const void* __cfi_jt_ ## fn __visible = (void *)&fn; #ifdef CONFIG_CFI_CLANG_SHADOW -extern void cfi_module_add(struct module *mod, unsigned long min_addr, - unsigned long max_addr); -extern void cfi_module_remove(struct module *mod, unsigned long min_addr, - unsigned long max_addr); +extern void cfi_module_add(struct module *mod, unsigned long base_addr); +extern void cfi_module_remove(struct module *mod, unsigned long base_addr); + #else -static inline void cfi_module_add(struct module *mod, unsigned long min_addr, - unsigned long max_addr) -{ -} -static inline void cfi_module_remove(struct module *mod, unsigned long min_addr, - unsigned long max_addr) -{ -} +static inline void cfi_module_add(struct module *mod, unsigned long base_addr) {} +static inline void cfi_module_remove(struct module *mod, unsigned long base_addr) {} + #endif /* CONFIG_CFI_CLANG_SHADOW */ -#endif /* CONFIG_MODULES */ +#else /* !CONFIG_CFI_CLANG */ + +#define __CFI_ADDRESSABLE(fn) + #endif /* CONFIG_CFI_CLANG */ #endif /* _LINUX_CFI_H */ -- Gitblit v1.6.2