ANDROID: cfi: add __cficanonical and fix PREL32 relocations
With non-canonical CFI, the compiler rewrites function references to point to the CFI jump table for indirect call checking. This won't happen when the address is taken in assembly, and will result in a CFI failure if we jump to the address later in C code. This change adds the __cficanonical attribute, which tells the compiler to switch to a canonical jump table for the function. With canonical CFI, the compiler appends a .cfi postfix to the function name, and points the original symbol to the jump table. This allows addresses taken in assembly code to be used for indirect calls without tripping CFI checks. Bug: 145210207 Change-Id: Iaca9d1d95f59d7169168d89bc10bf71420487a67 Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
This commit is contained in:
committed by
Alistair Delva
parent
2c351bb70a
commit
7bc9b9d25b
@@ -67,3 +67,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __nocfi __attribute__((__no_sanitize__("cfi")))
|
#define __nocfi __attribute__((__no_sanitize__("cfi")))
|
||||||
|
#define __cficanonical __attribute__((__cfi_canonical_jump_table__))
|
||||||
|
|||||||
@@ -241,6 +241,10 @@ struct ftrace_likely_data {
|
|||||||
# define __nocfi
|
# define __nocfi
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __cficanonical
|
||||||
|
# define __cficanonical
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef asm_volatile_goto
|
#ifndef asm_volatile_goto
|
||||||
#define asm_volatile_goto(x...) asm goto(x)
|
#define asm_volatile_goto(x...) asm goto(x)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -220,8 +220,8 @@ extern bool initcall_debug;
|
|||||||
__initcall_name(initstub, __iid, id)
|
__initcall_name(initstub, __iid, id)
|
||||||
|
|
||||||
#define __define_initcall_stub(__stub, fn) \
|
#define __define_initcall_stub(__stub, fn) \
|
||||||
int __init __stub(void); \
|
int __init __cficanonical __stub(void); \
|
||||||
int __init __stub(void) \
|
int __init __cficanonical __stub(void) \
|
||||||
{ \
|
{ \
|
||||||
return fn(); \
|
return fn(); \
|
||||||
} \
|
} \
|
||||||
|
|||||||
@@ -1914,8 +1914,8 @@ enum pci_fixup_pass {
|
|||||||
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
|
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
|
||||||
#define ___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
#define ___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||||
class_shift, hook, stub) \
|
class_shift, hook, stub) \
|
||||||
void stub(struct pci_dev *dev); \
|
void __cficanonical stub(struct pci_dev *dev); \
|
||||||
void stub(struct pci_dev *dev) \
|
void __cficanonical stub(struct pci_dev *dev) \
|
||||||
{ \
|
{ \
|
||||||
hook(dev); \
|
hook(dev); \
|
||||||
} \
|
} \
|
||||||
|
|||||||
Reference in New Issue
Block a user