Skip to contentSkip to conversation

rtla: Fixes for v6.17

PATCH New Steven Rostedt 1 participant 3 messages Sep 27, 2025 Real-time Linux Analysis (rtla) tools

lore
Share & tools
lore
#0 lore raw

cover rtla: Fixes for v6.17

Two fixes for rtla in v6.17:

- Fix a buffer overflow in actions_parse()

The "trigger_c" variable did not account for the nul byte when determining its size.

- Fix a compare that had the values reversed

actions_destroy() is to reallocate when len is greater than the current size, but the compare was testing if size is greater than the new length.

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
tools/fixes

Head SHA1: 2227f273b7dc25a791ae6b152550098aa6934b2f

Ivan Pravdin (1):
rtla: Fix buffer overflow in actions_parse

Wander Lairson Costa (1):
rtla/actions: Fix condition for buffer reallocation

----

 tools/tracing/rtla/src/actions.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#1 lore raw

PATCH 1/2 rtla: Fix buffer overflow in actions_parse

From: Ivan Pravdin <[email protected]>

Currently, tests 3 and 13-22 in tests/timerlat.t fail with error:

*** buffer overflow detected ***: terminated
timeout: the monitored command dumped core

The result of running sudo make check is

    tests/timerlat.t (Wstat: 0 Tests: 22 Failed: 11)
      Failed tests:  3, 13-22
    Files=3, Tests=34, 140 wallclock secs ( 0.07 usr  0.01 sys + 27.63 cusr
    27.96 csys = 55.67 CPU)
    Result: FAIL

Fix buffer overflow in actions_parse to avoid this error. After this change, the tests results are

tests/hwnoise.t ... ok
tests/osnoise.t ... ok
tests/timerlat.t .. ok
All tests successful.
Files=3, Tests=34, 186 wallclock secs ( 0.06 usr 0.01 sys + 41.10 cusr 44.38 csys = 85.55 CPU)
Result: PASS

---
 tools/tracing/rtla/src/actions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/src/actions.c +1 -1
index aaf0808125d7..eab51c0c0ce2 100644
@@ -131,7 +131,7 @@ actions_parse(struct actions *self, const char *trigger)
 {
 	enum action_type type = ACTION_NONE;
 	char *token;
-	char trigger_c[strlen(trigger)];
+	char trigger_c[strlen(trigger) + 1];
 
 	/* For ACTION_SIGNAL */
 	int signal = 0, pid = 0;
Signature · 1 line
2.50.1
#2 lore raw

PATCH 2/2 rtla/actions: Fix condition for buffer reallocation

In reply to Steven Rostedt

From: Wander Lairson Costa <[email protected]>

The condition to check if the actions buffer needs to be resized was incorrect. The check self->size >= self->len would evaluate to true on almost every call to actions_new(), causing the buffer to be reallocated unnecessarily each time an action was added.

Fix the condition to self->len >= self.size, ensuring that the buffer is only resized when it is actually full.

Cc John Kacur <[email protected]>
Cc Luis Goncalves <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Chang Yin <[email protected]>
Cc Costa Shulyupin <[email protected]>
Cc Crystal Wood <[email protected]>
Cc Gabriele Monaco <[email protected]>
Fixes 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature")
---
 tools/tracing/rtla/src/actions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/src/actions.c +1 -1
index eab51c0c0ce2..13ff1934d47c 100644
@@ -49,7 +49,7 @@ actions_destroy(struct actions *self)
 static struct action *
 actions_new(struct actions *self)
 {
-	if (self->size >= self->len) {
+	if (self->len >= self->size) {
 		self->size *= 2;
 		self->list = realloc(self->list, self->size * sizeof(struct action));
 	}
Signature · 1 line
2.50.1