From: Beau Belgrave <beaub@linux.microsoft.com>
To: sunliming@kylinos.cn
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
mhiramat@kernel.org, rostedt@goodmis.org
Subject: Re: [PATCH RESEND] tracing/user_events: Prevent same name event per process
Date: Fri, 19 May 2023 16:38:04 -0700 [thread overview]
Message-ID: <20230519233804.863-1-beaub@linux.microsoft.com> (raw)
In-Reply-To: <20230519083740.232401-1-sunliming@kylinos.cn>
> 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>
> ---
Thank you for the patch, a few comments.
> 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;
The ABI currently allows this to allow for shared libraries to share a common write
FD. Do you feel strongly that this should not be allowed?
If you and others feel this should not be allowed, I'd kindly ask you to also update
the self-tests at tools/testing/selftests/user_events/ in the tree and ensure they
pass fully.
For example, see ftrace_test.c at the above tree location:
...
TEST_F(user, register_events) {
...
/* Multiple registers to the same addr + bit should fail */
ASSERT_EQ(-1, ioctl(self->data_fd, DIAG_IOCSREG, ®));
ASSERT_EQ(EADDRINUSE, errno);
/* Multiple registers to same name should result in same index */
reg.enable_bit = 30;
ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®));
ASSERT_EQ(0, reg.write_index);
...
Thanks,
-Beau
> }
>
> size = struct_size(refs, events, count + 1);
> --
> 2.25.1
prev parent reply other threads:[~2023-05-19 23:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 8:37 [PATCH RESEND] tracing/user_events: Prevent same name event per process sunliming
2023-05-19 23:38 ` Beau Belgrave [this message]
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=20230519233804.863-1-beaub@linux.microsoft.com \
--to=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=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;
as well as URLs for NNTP newsgroup(s).