* [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry
@ 2023-01-28 16:23 Pietro Borrello
2023-01-30 15:19 ` Steven Rostedt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pietro Borrello @ 2023-01-28 16:23 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu
Cc: Cristiano Giuffrida, Bos, H.J.,
Jakob Koschel, linux-kernel, linux-trace-kernel, Pietro Borrello
All callers of trace_probe_primary_from_call() check the return
value to be non NULL. However, the function returns
list_first_entry(&tpe->probes, ...) which can never be NULL.
Additionally, it does not check for the list being possibly empty,
possibly causing a type confusion on empty lists.
Use list_first_entry_or_null() which solves both problems.
Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe")
Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
---
kernel/trace/trace_probe.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index 23acfd1c3812..f6b565dced56 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -307,7 +307,7 @@ trace_probe_primary_from_call(struct trace_event_call *call)
{
struct trace_probe_event *tpe = trace_probe_event_from_call(call);
- return list_first_entry(&tpe->probes, struct trace_probe, list);
+ return list_first_entry_or_null(&tpe->probes, struct trace_probe, list);
}
static inline struct list_head *trace_probe_probe_list(struct trace_probe *tp)
---
base-commit: 2241ab53cbb5cdb08a6b2d4688feb13971058f65
change-id: 20230128-list-entry-null-check-37778efda18c
Best regards,
--
Pietro Borrello <borrello@diag.uniroma1.it>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry
2023-01-28 16:23 [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry Pietro Borrello
@ 2023-01-30 15:19 ` Steven Rostedt
2023-02-17 1:30 ` Masami Hiramatsu
2023-02-17 13:42 ` Mukesh Ojha
2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2023-01-30 15:19 UTC (permalink / raw)
To: Pietro Borrello
Cc: Masami Hiramatsu, Cristiano Giuffrida, Bos, H.J.,
Jakob Koschel, linux-kernel, linux-trace-kernel
On Sat, 28 Jan 2023 16:23:41 +0000
Pietro Borrello <borrello@diag.uniroma1.it> wrote:
> All callers of trace_probe_primary_from_call() check the return
> value to be non NULL. However, the function returns
> list_first_entry(&tpe->probes, ...) which can never be NULL.
> Additionally, it does not check for the list being possibly empty,
> possibly causing a type confusion on empty lists.
> Use list_first_entry_or_null() which solves both problems.
>
> Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe")
> Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
> ---
> kernel/trace/trace_probe.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index 23acfd1c3812..f6b565dced56 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -307,7 +307,7 @@ trace_probe_primary_from_call(struct trace_event_call *call)
> {
> struct trace_probe_event *tpe = trace_probe_event_from_call(call);
>
> - return list_first_entry(&tpe->probes, struct trace_probe, list);
> + return list_first_entry_or_null(&tpe->probes, struct trace_probe, list);
> }
>
> static inline struct list_head *trace_probe_probe_list(struct trace_probe *tp)
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-- Steve
>
> ---
> base-commit: 2241ab53cbb5cdb08a6b2d4688feb13971058f65
> change-id: 20230128-list-entry-null-check-37778efda18c
>
> Best regards,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry
2023-01-28 16:23 [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry Pietro Borrello
2023-01-30 15:19 ` Steven Rostedt
@ 2023-02-17 1:30 ` Masami Hiramatsu
2023-02-17 13:42 ` Mukesh Ojha
2 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2023-02-17 1:30 UTC (permalink / raw)
To: Pietro Borrello
Cc: Steven Rostedt, Cristiano Giuffrida, Bos, H.J.,
Jakob Koschel, linux-kernel, linux-trace-kernel
On Sat, 28 Jan 2023 16:23:41 +0000
Pietro Borrello <borrello@diag.uniroma1.it> wrote:
> All callers of trace_probe_primary_from_call() check the return
> value to be non NULL. However, the function returns
> list_first_entry(&tpe->probes, ...) which can never be NULL.
> Additionally, it does not check for the list being possibly empty,
> possibly causing a type confusion on empty lists.
> Use list_first_entry_or_null() which solves both problems.
>
> Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe")
> Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
And
Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe")
Cc: stable@vger.kernel.org
Thank you!
> ---
> kernel/trace/trace_probe.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index 23acfd1c3812..f6b565dced56 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -307,7 +307,7 @@ trace_probe_primary_from_call(struct trace_event_call *call)
> {
> struct trace_probe_event *tpe = trace_probe_event_from_call(call);
>
> - return list_first_entry(&tpe->probes, struct trace_probe, list);
> + return list_first_entry_or_null(&tpe->probes, struct trace_probe, list);
> }
>
> static inline struct list_head *trace_probe_probe_list(struct trace_probe *tp)
>
> ---
> base-commit: 2241ab53cbb5cdb08a6b2d4688feb13971058f65
> change-id: 20230128-list-entry-null-check-37778efda18c
>
> Best regards,
> --
> Pietro Borrello <borrello@diag.uniroma1.it>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry
2023-01-28 16:23 [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry Pietro Borrello
2023-01-30 15:19 ` Steven Rostedt
2023-02-17 1:30 ` Masami Hiramatsu
@ 2023-02-17 13:42 ` Mukesh Ojha
2 siblings, 0 replies; 4+ messages in thread
From: Mukesh Ojha @ 2023-02-17 13:42 UTC (permalink / raw)
To: borrello
Cc: c.giuffrida, h.j.bos, jkl820.git, linux-kernel,
linux-trace-kernel, mhiramat, rostedt
>All callers of trace_probe_primary_from_call() check the return
>value to be non NULL. However, the function returns
>list_first_entry(&tpe->probes, ...) which can never be NULL.
>Additionally, it does not check for the list being possibly empty,
>possibly causing a type confusion on empty lists.
>Use list_first_entry_or_null() which solves both problems.
>
>Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe")
>Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
>---
> kernel/trace/trace_probe.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
>index 23acfd1c3812..f6b565dced56 100644
>--- a/kernel/trace/trace_probe.h
>+++ b/kernel/trace/trace_probe.h
>@@ -307,7 +307,7 @@ trace_probe_primary_from_call(struct trace_event_call *call)
> {
> struct trace_probe_event *tpe = trace_probe_event_from_call(call);
>
>- return list_first_entry(&tpe->probes, struct trace_probe, list);
>+ return list_first_entry_or_null(&tpe->probes, struct trace_probe, list);
> }
Nice catch !!
Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>
-Mukesh
>
> static inline struct list_head *trace_probe_probe_list(struct trace_probe *tp)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-17 13:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-28 16:23 [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry Pietro Borrello
2023-01-30 15:19 ` Steven Rostedt
2023-02-17 1:30 ` Masami Hiramatsu
2023-02-17 13:42 ` Mukesh Ojha
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).