public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: sunliming <sunliming@kylinos.cn>,
	Beau Belgrave <beaub@linux.microsoft.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-trace-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.3 05/17] tracing/user_events: Fix the incorrect trace record for empty arguments events
Date: Thu, 29 Jun 2023 15:00:34 -0400	[thread overview]
Message-ID: <20230629190049.907558-5-sashal@kernel.org> (raw)
In-Reply-To: <20230629190049.907558-1-sashal@kernel.org>

From: sunliming <sunliming@kylinos.cn>

[ Upstream commit 6f05dcabe5c241d066ec472cf38ac8b84f8c9c6f ]

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.

Link: https://lkml.kernel.org/r/20230606062027.1008398-2-sunliming@kylinos.cn

Acked-by: Beau Belgrave <beaub@linux.microsoft.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: sunliming <sunliming@kylinos.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 ad64da21c34aa..49e114d250136 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -916,7 +916,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) &&
@@ -957,7 +957,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.39.2


  parent reply	other threads:[~2023-06-29 19:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 19:00 [PATCH AUTOSEL 6.3 01/17] arm64: dts: rockchip: fix USB regulator on ROCK64 Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 02/17] arm64: dts: rockchip: add missing cache properties Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 03/17] tracing/user_events: Prevent same name but different args event Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 04/17] tracing/user_events: Handle matching arguments that is null from dyn_events Sasha Levin
2023-06-29 19:00 ` Sasha Levin [this message]
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 06/17] x86/hyperv: Fix hyperv_pcpu_input_arg handling when CPUs go online/offline Sasha Levin
2023-06-29 22:17   ` Michael Kelley (LINUX)
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 07/17] arm64/hyperv: Use CPUHP_AP_HYPERV_ONLINE state to fix CPU online sequencing Sasha Levin
2023-06-29 22:18   ` Michael Kelley (LINUX)
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 08/17] ieee802154/adf7242: Add MODULE_FIRMWARE macro Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 09/17] nfc: fdp: Add MODULE_FIRMWARE macros Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 10/17] ALSA: hda/realtek: Add quirk for ASUS ROG G634Z Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 11/17] net: dpaa2-mac: add 25gbase-r support Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 12/17] drm: use mgr->dev in drm_dbg_kms in drm_dp_add_payload_part2 Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 13/17] netfilter: nf_tables: disallow timeout for anonymous sets Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 14/17] netfilter: nf_tables: drop module reference after updating chain Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 15/17] Revert "virtio-blk: support completion batching for the IRQ path" Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 16/17] ALSA: hda/realtek: Add quirk for ASUS ROG GV601V Sasha Levin
2023-06-29 19:00 ` [PATCH AUTOSEL 6.3 17/17] workqueue: clean up WORK_* constant types, clarify masking Sasha Levin

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=20230629190049.907558-5-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=beaub@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=sunliming@kylinos.cn \
    /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