public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [for-linus][PATCH 0/2] rtla: Fixes for v6.17
@ 2025-09-27 11:34 Steven Rostedt
  2025-09-27 11:34 ` [for-linus][PATCH 1/2] rtla: Fix buffer overflow in actions_parse Steven Rostedt
  2025-09-27 11:34 ` [for-linus][PATCH 2/2] rtla/actions: Fix condition for buffer reallocation Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-09-27 11:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tomas Glozar, John Kacur


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(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [for-linus][PATCH 1/2] rtla: Fix buffer overflow in actions_parse
  2025-09-27 11:34 [for-linus][PATCH 0/2] rtla: Fixes for v6.17 Steven Rostedt
@ 2025-09-27 11:34 ` Steven Rostedt
  2025-09-27 11:34 ` [for-linus][PATCH 2/2] rtla/actions: Fix condition for buffer reallocation Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-09-27 11:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tomas Glozar, John Kacur, Ivan Pravdin

From: Ivan Pravdin <ipravdin.official@gmail.com>

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

Link: https://lore.kernel.org/164ffc2ec8edacaf1295789dad82a07817b6263d.1757034919.git.ipravdin.official@gmail.com
Fixes: 6ea082b171e0 ("rtla/timerlat: Add action on threshold feature")
Signed-off-by: Ivan Pravdin <ipravdin.official@gmail.com>
Reviewed-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/tracing/rtla/src/actions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/actions.c
index aaf0808125d7..eab51c0c0ce2 100644
--- a/tools/tracing/rtla/src/actions.c
+++ b/tools/tracing/rtla/src/actions.c
@@ -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;
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [for-linus][PATCH 2/2] rtla/actions: Fix condition for buffer reallocation
  2025-09-27 11:34 [for-linus][PATCH 0/2] rtla: Fixes for v6.17 Steven Rostedt
  2025-09-27 11:34 ` [for-linus][PATCH 1/2] rtla: Fix buffer overflow in actions_parse Steven Rostedt
@ 2025-09-27 11:34 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-09-27 11:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Tomas Glozar, John Kacur, Luis Goncalves,
	Arnaldo Carvalho de Melo, Chang Yin, Costa Shulyupin,
	Crystal Wood, Gabriele Monaco, Wander Lairson Costa

From: Wander Lairson Costa <wander@redhat.com>

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 <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Chang Yin <cyin@redhat.com>
Cc: Costa Shulyupin <costa.shul@redhat.com>
Cc: Crystal Wood <crwood@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/20250915181101.52513-1-wander@redhat.com
Fixes: 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature")
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Reviewed-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/tracing/rtla/src/actions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/actions.c
index eab51c0c0ce2..13ff1934d47c 100644
--- a/tools/tracing/rtla/src/actions.c
+++ b/tools/tracing/rtla/src/actions.c
@@ -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));
 	}
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-27 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-27 11:34 [for-linus][PATCH 0/2] rtla: Fixes for v6.17 Steven Rostedt
2025-09-27 11:34 ` [for-linus][PATCH 1/2] rtla: Fix buffer overflow in actions_parse Steven Rostedt
2025-09-27 11:34 ` [for-linus][PATCH 2/2] rtla/actions: Fix condition for buffer reallocation Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox