]> git.baikalelectronics.ru Git - kernel.git/commit
kprobes: Fix KRETPROBES when CONFIG_KRETPROBE_ON_RETHOOK is set
authorAdam Zabrocki <pi3@pi3.com.pl>
Fri, 22 Apr 2022 16:40:27 +0000 (18:40 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 26 Apr 2022 14:09:36 +0000 (16:09 +0200)
commita4f16c14039d0bf1edf7a0daa59e6da5c660b464
treef126c3bcc98255dfed064c1ac7a95fc58e771613
parentdcc72a421f802c7cee606dd59a9f01b6f9b93c90
kprobes: Fix KRETPROBES when CONFIG_KRETPROBE_ON_RETHOOK is set

The recent kernel change in 7df43f83baa8 ("kprobes: Use rethook for kretprobe
if possible"), introduced a potential NULL pointer dereference bug in the
KRETPROBE mechanism. The official Kprobes documentation defines that "Any or
all handlers can be NULL". Unfortunately, there is a missing return handler
verification to fulfill these requirements and can result in a NULL pointer
dereference bug.

This patch adds such verification in kretprobe_rethook_handler() function.

Fixes: 7df43f83baa8 ("kprobes: Use rethook for kretprobe if possible")
Signed-off-by: Adam Zabrocki <pi3@pi3.com.pl>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
Cc: Anil S. Keshavamurthy <anil.s.keshavamurthy@intel.com>
Link: https://lore.kernel.org/bpf/20220422164027.GA7862@pi3.com.pl
kernel/kprobes.c