From: sunliming <sunliming@kylinos.cn>
To: rostedt@goodmis.org, mhiramat@kernel.org, sunliming@kylinos.cn
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] racing/user_events: Prevent same address and bit per process
Date: Fri, 19 May 2023 16:10:35 +0800 [thread overview]
Message-ID: <20230519081035.228891-1-sunliming@kylinos.cn> (raw)
User processes register name_args for events. If the same name are registered
multiple times in the same process, it can cause undefined behavior. Because
the same name may be used for a diffrent event. If this event has the same
format as the original event, it is impossible to distinguish the trace output
of these two events. If the event has a different format from the original event,
the trace output of the new event is incorrect.
Return EADDRINUSE back to the user process if the same event has being registered
in the same process.
Signed-off-by: sunliming <sunliming@kylinos.cn>
---
kernel/trace/trace_events_user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index b1ecd7677642..4ef6bdb5c07c 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1996,7 +1996,7 @@ static int user_events_ref_add(struct user_event_file_info *info,
for (i = 0; i < count; ++i)
if (refs->events[i] == user)
- return i;
+ return -EADDRINUSE;
}
size = struct_size(refs, events, count + 1);
--
2.25.1
next reply other threads:[~2023-05-19 8:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 8:10 sunliming [this message]
2023-05-22 14:32 ` [PATCH] racing/user_events: Prevent same address and bit per process 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=20230519081035.228891-1-sunliming@kylinos.cn \
--to=sunliming@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--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