diff options
author | Rafael Mendonca <rafaelmendsr@gmail.com> | 2022-10-25 05:12:08 +0200 |
---|---|---|
committer | Masami Hiramatsu (Google) <mhiramat@kernel.org> | 2022-11-04 00:50:00 +0100 |
commit | d05ea35e7eea14d32f29fd688d3daeb9089de1a5 (patch) | |
tree | 06f1b787d0588ff6a658059eda3c77a56a5ad903 | |
parent | kprobe: reverse kp->flags when arm_kprobe failed (diff) | |
download | linux-d05ea35e7eea14d32f29fd688d3daeb9089de1a5.tar.xz linux-d05ea35e7eea14d32f29fd688d3daeb9089de1a5.zip |
fprobe: Check rethook_alloc() return in rethook initialization
Check if fp->rethook succeeded to be allocated. Otherwise, if
rethook_alloc() fails, then we end up dereferencing a NULL pointer in
rethook_add_node().
Link: https://lore.kernel.org/all/20221025031209.954836-1-rafaelmendsr@gmail.com/
Fixes: 5b0ab78998e3 ("fprobe: Add exit_handler support")
Cc: stable@vger.kernel.org
Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
-rw-r--r-- | kernel/trace/fprobe.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c index aac63ca9c3d1..71614b2a67ff 100644 --- a/kernel/trace/fprobe.c +++ b/kernel/trace/fprobe.c @@ -141,6 +141,8 @@ static int fprobe_init_rethook(struct fprobe *fp, int num) return -E2BIG; fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler); + if (!fp->rethook) + return -ENOMEM; for (i = 0; i < size; i++) { struct fprobe_rethook_node *node; |