All of lore.kernel.org
 help / color / mirror / Atom feed
From: sunliming <sunliming@kylinos.cn>
To: mhiramat@kernel.org, beaub@linux.microsoft.com,
	rostedt@goodmis.org, shuah@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com,
	sunliming <sunliming@kylinos.cn>
Subject: [PATCH v3 1/4] tracing/user_events: Fix the incorrect trace record for empty arguments events
Date: Tue,  6 Jun 2023 14:20:24 +0800	[thread overview]
Message-ID: <20230606062027.1008398-2-sunliming@kylinos.cn> (raw)
In-Reply-To: <20230606062027.1008398-1-sunliming@kylinos.cn>

The user_events support events that has empty arguments. But the trace event
is discarded and not really committed when the arguments is empty. Fix this
by not attempting to copy in zero-length data.

Signed-off-by: sunliming <sunliming@kylinos.cn>
---
 kernel/trace/trace_events_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 0d91dac206ff..698703a3d234 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1399,7 +1399,7 @@ static void user_event_ftrace(struct user_event *user, struct iov_iter *i,
 	if (unlikely(!entry))
 		return;
 
-	if (unlikely(!copy_nofault(entry + 1, i->count, i)))
+	if (unlikely(i->count != 0 && !copy_nofault(entry + 1, i->count, i)))
 		goto discard;
 
 	if (!list_empty(&user->validators) &&
@@ -1440,7 +1440,7 @@ static void user_event_perf(struct user_event *user, struct iov_iter *i,
 
 		perf_fetch_caller_regs(regs);
 
-		if (unlikely(!copy_nofault(perf_entry + 1, i->count, i)))
+		if (unlikely(i->count != 0 && !copy_nofault(perf_entry + 1, i->count, i)))
 			goto discard;
 
 		if (!list_empty(&user->validators) &&
-- 
2.25.1


  reply	other threads:[~2023-06-06  6:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06  6:20 [PATCH v3 0/4] tracing/user_events: Add empty arguments events sunliming
2023-06-06  6:20 ` sunliming [this message]
2023-06-06  6:20 ` [PATCH v3 2/4] selftests/user_events: Add ftrace self-test for " sunliming
2023-06-06  6:20 ` [PATCH v3 3/4] selftests/user_events: Clear the events after perf self-test sunliming
2023-06-06  6:20 ` [PATCH v3 4/4] selftests/user_events: Add perf self-test for empty arguments events sunliming
2023-06-06 18:53 ` [PATCH v3 0/4] tracing/user_events: Add " Beau Belgrave
2023-06-07 14:10 ` Masami Hiramatsu

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=20230606062027.1008398-2-sunliming@kylinos.cn \
    --to=sunliming@kylinos.cn \
    --cc=beaub@linux.microsoft.com \
    --cc=kelulanainsley@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.