]> git.baikalelectronics.ru Git - kernel.git/commit
kprobes: Forbid probing on trampoline and BPF code areas
authorChen Zhongjin <chenzhongjin@huawei.com>
Mon, 1 Aug 2022 03:37:19 +0000 (11:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:18:07 +0000 (11:18 +0200)
commit7f24892b68b8afbe6a6a4149c78d6ccf4deecd68
treeff586838af940abc75dec4c217b846fb939d03c3
parent886018bc681cd42b4b00c273d87edb0894b1fffc
kprobes: Forbid probing on trampoline and BPF code areas

[ Upstream commit 31d5759ce06e6a7fb9a9f6eb353d6e3f44d21f65 ]

kernel_text_address() treats ftrace_trampoline, kprobe_insn_slot
and bpf_text_address as valid kprobe addresses - which is not ideal.

These text areas are removable and changeable without any notification
to kprobes, and probing on them can trigger unexpected behavior:

  https://lkml.org/lkml/2022/7/26/1148

Considering that jump_label and static_call text are already
forbiden to probe, kernel_text_address() should be replaced with
core_kernel_text() and is_module_text_address() to check other text
areas which are unsafe to kprobe.

[ mingo: Rewrote the changelog. ]

Fixes: bf6a01b7b2ab ("kprobes, extable: Identify kprobes trampolines as kernel text area")
Fixes: 487a429673a4 ("bpf: make jited programs visible in traces")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20220801033719.228248-1-chenzhongjin@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/kprobes.c