* [PATCH] fprobe: Check rethook_alloc() return in rethook initialization
@ 2022-10-25 3:12 Rafael Mendonca
2022-10-25 8:03 ` Masami Hiramatsu
0 siblings, 1 reply; 3+ messages in thread
From: Rafael Mendonca @ 2022-10-25 3:12 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu, Alexei Starovoitov
Cc: Rafael Mendonca, linux-kernel
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().
Fixes: 5b0ab78998e3 ("fprobe: Add exit_handler support")
Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
---
kernel/trace/fprobe.c | 2 ++
1 file changed, 2 insertions(+)
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;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fprobe: Check rethook_alloc() return in rethook initialization
2022-10-25 3:12 [PATCH] fprobe: Check rethook_alloc() return in rethook initialization Rafael Mendonca
@ 2022-10-25 8:03 ` Masami Hiramatsu
2022-10-25 11:47 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2022-10-25 8:03 UTC (permalink / raw)
To: Rafael Mendonca; +Cc: Steven Rostedt, Alexei Starovoitov, linux-kernel
On Tue, 25 Oct 2022 00:12:08 -0300
Rafael Mendonca <rafaelmendsr@gmail.com> wrote:
> 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().
Good catch!
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thank you!
>
> Fixes: 5b0ab78998e3 ("fprobe: Add exit_handler support")
> Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
> ---
> kernel/trace/fprobe.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> 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;
>
> --
> 2.34.1
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fprobe: Check rethook_alloc() return in rethook initialization
2022-10-25 8:03 ` Masami Hiramatsu
@ 2022-10-25 11:47 ` Steven Rostedt
0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2022-10-25 11:47 UTC (permalink / raw)
To: Masami Hiramatsu (Google)
Cc: Rafael Mendonca, Alexei Starovoitov, linux-kernel
On Tue, 25 Oct 2022 17:03:46 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> On Tue, 25 Oct 2022 00:12:08 -0300
> Rafael Mendonca <rafaelmendsr@gmail.com> wrote:
>
> > 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().
>
> Good catch!
>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Masami, feel free to pull this in.
-- Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-25 11:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 3:12 [PATCH] fprobe: Check rethook_alloc() return in rethook initialization Rafael Mendonca
2022-10-25 8:03 ` Masami Hiramatsu
2022-10-25 11:47 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).