LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/2] tracing: Add trace_trigger_soft_disabled() in front of trace_event_buffer_reserve() in trace_inject_entry()
@ 2021-09-03  3:30 Jiang Jiasheng
  2021-09-03  4:02 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Jiang Jiasheng @ 2021-09-03  3:30 UTC (permalink / raw)
  To: rostedt, mingo; +Cc: linux-kernel, Jiang Jiasheng

Directly use trace_event_buffer_reserve() might be unsafe,
as we can see from the trace_trigger_soft_disabled() of
'include/linux/trace_events.h' that if the value of
file->flags is 256, the check in the trace_trigger_soft_disabled()
will be passed but actually shouldn't have.
Therefore, we suggest that trace_trigger_soft_disabled()
should be added in front of the trace_event_buffer_reserve()
in trace_inject_entry().

Signed-off-by: Jiang Jiasheng <jiasheng@iscas.ac.cn>
---
 kernel/trace/trace_events_inject.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/trace/trace_events_inject.c b/kernel/trace/trace_events_inject.c
index c188045..6dfd3cd 100644
--- a/kernel/trace/trace_events_inject.c
+++ b/kernel/trace/trace_events_inject.c
@@ -21,6 +21,8 @@ trace_inject_entry(struct trace_event_file *file, void *rec, int len)
 	void *entry;
 
 	rcu_read_lock_sched();
+	if (trace_trigger_soft_disabled(file))
+		return written;
 	entry = trace_event_buffer_reserve(&fbuffer, file, len);
 	if (entry) {
 		memcpy(entry, rec, len);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] tracing: Add trace_trigger_soft_disabled() in front of trace_event_buffer_reserve() in trace_inject_entry()
  2021-09-03  3:30 [PATCH 2/2] tracing: Add trace_trigger_soft_disabled() in front of trace_event_buffer_reserve() in trace_inject_entry() Jiang Jiasheng
@ 2021-09-03  4:02 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2021-09-03  4:02 UTC (permalink / raw)
  To: Jiang Jiasheng; +Cc: mingo, linux-kernel

On Fri,  3 Sep 2021 03:30:34 +0000
Jiang Jiasheng <jiasheng@iscas.ac.cn> wrote:

> Directly use trace_event_buffer_reserve() might be unsafe,

How can it be unsafe?

> as we can see from the trace_trigger_soft_disabled() of
> 'include/linux/trace_events.h' that if the value of
> file->flags is 256, the check in the trace_trigger_soft_disabled()
> will be passed but actually shouldn't have.
> Therefore, we suggest that trace_trigger_soft_disabled()
> should be added in front of the trace_event_buffer_reserve()
> in trace_inject_entry().

Do you understand what the trace_inject_entry() does?

I'm not sure it makes sense to "soft disable" it.

> 
> Signed-off-by: Jiang Jiasheng <jiasheng@iscas.ac.cn>
> ---
>  kernel/trace/trace_events_inject.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/trace/trace_events_inject.c b/kernel/trace/trace_events_inject.c
> index c188045..6dfd3cd 100644
> --- a/kernel/trace/trace_events_inject.c
> +++ b/kernel/trace/trace_events_inject.c
> @@ -21,6 +21,8 @@ trace_inject_entry(struct trace_event_file *file, void *rec, int len)
>  	void *entry;
>  
>  	rcu_read_lock_sched();
> +	if (trace_trigger_soft_disabled(file))
> +		return written;

NACK!

The above introduces a major bug. Bonus points if you can figure out
what that is yourself.

-- Steve

>  	entry = trace_event_buffer_reserve(&fbuffer, file, len);
>  	if (entry) {
>  		memcpy(entry, rec, len);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-03  4:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  3:30 [PATCH 2/2] tracing: Add trace_trigger_soft_disabled() in front of trace_event_buffer_reserve() in trace_inject_entry() Jiang Jiasheng
2021-09-03  4:02 ` 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).