blob: b583ef6087472f1c79a203a80ea5065eb3d7b9db (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Under kCFI an indirect call checks a type hash before jumping, and traps on a
# mismatch. Two things belong to the calling function and must come with it
# into a patch:
#
# - the __cfi_<func> prefix symbol holding the hash. Lose it and the patched
# function has no type identity, so indirect calls to it trap.
# - its .kcfi_traps entry. Lose that and the trap is not recognised as a
# CFI failure, so what should be a clean report becomes an oops.
#
# Neither shows up at build time.
. "$(dirname "$0")/../lib.sh"
clang_only "kCFI is a Clang feature"
setup
# Declared above that this is Clang's; a given Clang may still be too old.
cc_supports -fsanitize=kcfi ||
probe_skip "this clang does not support -fsanitize=kcfi"
build_pair kcfi.c -fsanitize=kcfi
assert_input_section .kcfi_traps
assert_input_symbol __cfi_target
run_diff
assert_patched target
# The prefix symbol comes with its function ...
assert_symbol __cfi_target
# ... and so does the trap entry.
assert_section .kcfi_traps
pass "kCFI prefix symbol and trap entry carried with the patched function"
|