mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 07:38:10 +00:00
kprobes: Prohibit probing on CFI preamble symbol
[ Upstream commit de02f2ac5d
]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
654e3d2779
commit
0111b7bb51
1 changed files with 13 additions and 1 deletions
|
@ -1628,6 +1628,17 @@ int __weak arch_check_ftrace_location(struct kprobe *p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool is_cfi_preamble_symbol(unsigned long addr)
|
||||
{
|
||||
char symbuf[KSYM_NAME_LEN];
|
||||
|
||||
if (lookup_symbol_name(addr, symbuf))
|
||||
return false;
|
||||
|
||||
return str_has_prefix("__cfi_", symbuf) ||
|
||||
str_has_prefix("__pfx_", symbuf);
|
||||
}
|
||||
|
||||
static int check_kprobe_address_safe(struct kprobe *p,
|
||||
struct module **probed_mod)
|
||||
{
|
||||
|
@ -1646,7 +1657,8 @@ static int check_kprobe_address_safe(struct kprobe *p,
|
|||
within_kprobe_blacklist((unsigned long) p->addr) ||
|
||||
jump_label_text_reserved(p->addr, p->addr) ||
|
||||
static_call_text_reserved(p->addr, p->addr) ||
|
||||
find_bug((unsigned long)p->addr)) {
|
||||
find_bug((unsigned long)p->addr) ||
|
||||
is_cfi_preamble_symbol((unsigned long)p->addr)) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue