linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: Prevent buffer overflow in update_pid_filters()
@ 2024-10-29  8:47 Jerome Marchand
  0 siblings, 0 replies; only message in thread
From: Jerome Marchand @ 2024-10-29  8:47 UTC (permalink / raw)
  To: Linux Trace Devel; +Cc: Steven Rostedt, Jerome Marchand

The buffer in which the updated filter is written in
update_pid_filters() is missing one byte to store the null character.

It fixes the following error:
$ trace-cmd start -e irq:* -e sched:* -P 1
*** buffer overflow detected ***: terminated
Aborted (core dumped)

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
 tracecmd/trace-record.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index a008cdfd..8726f9f4 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -2851,7 +2851,7 @@ static void update_pid_filters(struct buffer_instance *instance)
 	if (fd < 0)
 		die("Failed to access set_event_pid");
 
-	len = instance->len_filter_pids + instance->nr_filter_pids;
+	len = instance->len_filter_pids + instance->nr_filter_pids + 1;
 	filter = malloc(len);
 	if (!filter)
 		die("Failed to allocate pid filter");
-- 
2.47.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-10-29  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29  8:47 [PATCH] trace-cmd: Prevent buffer overflow in update_pid_filters() Jerome Marchand

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