mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiang Jiasheng <jiasheng@iscas.ac.cn>
To: rostedt@goodmis.org, mingo@redhat.com
Cc: linux-kernel@vger.kernel.org, Jiang Jiasheng <jiasheng@iscas.ac.cn>
Subject: [PATCH 2/2] tracing: Add trace_trigger_soft_disabled() in front of trace_event_buffer_reserve() in trace_inject_entry()
Date: Fri,  3 Sep 2021 03:30:34 +0000	[thread overview]
Message-ID: <1630639834-767471-1-git-send-email-jiasheng@iscas.ac.cn> (raw)

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


             reply	other threads:[~2021-09-03  3:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03  3:30 Jiang Jiasheng [this message]
2021-09-03  4:02 ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1630639834-767471-1-git-send-email-jiasheng@iscas.ac.cn \
    --to=jiasheng@iscas.ac.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®