From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] libtracefs/utest: Fix crashing of synth test when synths exist
Date: Tue, 30 May 2023 02:56:27 -0400 [thread overview]
Message-ID: <20230530025627.19df3714@rorschach.local.home> (raw)
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
If a synthetic event already exists when running the synthetic event test,
it does a SEGFAULT. This is because the sevents passed into
test_synth_compare() is dependent on the devents size. If there's
already a synthetic event, devents will be bigger than sevents, and the
sevents will read out of bounds. Check for devents to be the same size as
sevents before calling test_synth_compare()
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
utest/tracefs-utest.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index 0f4075679ec4..3d88d927e320 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -1047,6 +1047,12 @@ static void test_instance_synthetic(struct tracefs_instance *instance)
devents = get_dynevents_check(TRACEFS_DYNEVENT_SYNTH, sevents_count);
CU_TEST(devents != NULL);
+ if (!devents)
+ goto out;
+ CU_TEST(devents[sevents_count] == NULL);
+ if (devents[sevents_count])
+ goto out;
+
test_synth_compare(sevents, devents);
tracefs_dynevent_list_free(devents);
@@ -1057,6 +1063,7 @@ static void test_instance_synthetic(struct tracefs_instance *instance)
get_dynevents_check(TRACEFS_DYNEVENT_SYNTH, 0);
+ out:
for (i = 0; i < sevents_count; i++)
tracefs_synth_free(synth[i]);
--
2.39.2
reply other threads:[~2023-05-30 6:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230530025627.19df3714@rorschach.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.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 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).