Skip to content

Commit de02f2a

Browse files
committed
kprobes: Prohibit probing on CFI preamble symbol
Do not allow to probe on "__cfi_" or "__pfx_" started symbol, because those are used for CFI and not executed. Probing it will break the CFI. Link: https://lore.kernel.org/all/168904024679.116016.18089228029322008512.stgit@devnote2/ Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 02ab723 commit de02f2a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

kernel/kprobes.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,17 @@ static int check_ftrace_location(struct kprobe *p)
15451545
return 0;
15461546
}
15471547

1548+
static bool is_cfi_preamble_symbol(unsigned long addr)
1549+
{
1550+
char symbuf[KSYM_NAME_LEN];
1551+
1552+
if (lookup_symbol_name(addr, symbuf))
1553+
return false;
1554+
1555+
return str_has_prefix("__cfi_", symbuf) ||
1556+
str_has_prefix("__pfx_", symbuf);
1557+
}
1558+
15481559
static int check_kprobe_address_safe(struct kprobe *p,
15491560
struct module **probed_mod)
15501561
{
@@ -1563,7 +1574,8 @@ static int check_kprobe_address_safe(struct kprobe *p,
15631574
within_kprobe_blacklist((unsigned long) p->addr) ||
15641575
jump_label_text_reserved(p->addr, p->addr) ||
15651576
static_call_text_reserved(p->addr, p->addr) ||
1566-
find_bug((unsigned long)p->addr)) {
1577+
find_bug((unsigned long)p->addr) ||
1578+
is_cfi_preamble_symbol((unsigned long)p->addr)) {
15671579
ret = -EINVAL;
15681580
goto out;
15691581
}

0 commit comments

Comments
 (0)