]> 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)
committerIngo Molnar <mingo@kernel.org>
Tue, 2 Aug 2022 09:47:29 +0000 (11:47 +0200)
commitf10812102a0d296d72036cd82456386ce6db09f0
tree5d8aea752d27e43075fb186acf1651cfa18d7c9f
parentaa316e1d0c70ff75f4ddc0f96c3a5d9857098d95
kprobes: Forbid probing on trampoline and BPF code areas

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: 83b8b035c5dc ("kprobes, extable: Identify kprobes trampolines as kernel text area")
Fixes: c2d5f4374f26 ("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
kernel/kprobes.c