Package: release.debian.org
User: release.debian....@packages.debian.org
Usertags: pu
Tags: stretch
Severity: normal

trace-cmd in Stretch segfaults on certain traces in newer kernels. I
would prefer to update to 2.6.1 but that diff is isn't small [0].
I was able to locate one patch in 2.6.1 which handles the error
condition and so avoids the segfault. I propose this patch as a stable
update.

[0] 
https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=867440;filename=trace-cmd-2.6.1-0.1-nmu.diff;msg=10
    59 files changed, 4625 insertions(+), 1482 deletions(-)

Sebastian
diff -Nru trace-cmd-2.6/debian/changelog trace-cmd-2.6/debian/changelog
--- trace-cmd-2.6/debian/changelog      2016-07-17 12:40:56.000000000 +0000
+++ trace-cmd-2.6/debian/changelog      2017-09-20 19:51:23.000000000 +0000
@@ -1,3 +1,10 @@
+trace-cmd (2.6-0.1+deb9u1) stretch; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix segfault while processing certain trace files (Closes: #867440).
+
+ -- Sebastian Andrzej Siewior <sebast...@breakpoint.cc>  Wed, 20 Sep 2017 
21:51:23 +0200
+
 trace-cmd (2.6-0.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff -Nru 
trace-cmd-2.6/debian/patches/0002-tools-lib-traceevent-Add-checks-for-returned-EVENT_E.patch
 
trace-cmd-2.6/debian/patches/0002-tools-lib-traceevent-Add-checks-for-returned-EVENT_E.patch
--- 
trace-cmd-2.6/debian/patches/0002-tools-lib-traceevent-Add-checks-for-returned-EVENT_E.patch
        1970-01-01 00:00:00.000000000 +0000
+++ 
trace-cmd-2.6/debian/patches/0002-tools-lib-traceevent-Add-checks-for-returned-EVENT_E.patch
        2017-09-20 19:50:33.000000000 +0000
@@ -0,0 +1,64 @@
+From 02e85fa19d4aed68d6a3a0cd21b9d4ce1f55025a Mon Sep 17 00:00:00 2001
+From: Dean Nelson <dnel...@redhat.com>
+Date: Thu, 20 Aug 2015 11:16:32 -0400
+Subject: [PATCH] tools lib traceevent: Add checks for returned EVENT_ERROR
+ type
+
+Running the following perf-stat command on an arm64 system produces the
+following result...
+
+  [root@aarch64 ~]# perf stat -e kmem:mm_page_alloc -a sleep 1
+    Warning: [kmem:mm_page_alloc] function sizeof not defined
+    Warning: Error: expected type 4 but read 0
+  Segmentation fault
+  [root@aarch64 ~]#
+
+The second warning was a result of the first warning not stopping
+processing after it detected the issue.
+
+That is, code that found the issue reported the first problem, but
+because it did not exit out of the functions smoothly, it caused the
+other warning to appear and not only that, it later caused the SIGSEGV.
+
+Signed-off-by: Dean Nelson <dnel...@redhat.com>
+Reviewed-by: Steven Rostedt <rost...@goodmis.org>
+Acked-by: Namhyung Kim <namhy...@kernel.org>
+Cc: Jiri Olsa <jo...@kernel.org>
+Cc: Peter Zijlstra <a.p.zijls...@chello.nl>
+Link: 
http://lkml.kernel.org/r/20150820151632.13927.13791.email-sent-by-dnelson@teal
+Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
+Signed-off-by: Steven Rostedt <rost...@goodmis.org>
+---
+ event-parse.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/event-parse.c b/event-parse.c
+index e3b026a3d7fc..a4aed20f071c 100644
+--- a/event-parse.c
++++ b/event-parse.c
+@@ -1746,6 +1746,9 @@ process_cond(struct event_format *event, struct 
print_arg *top, char **tok)
+       type = process_arg(event, left, &token);
+ 
+  again:
++      if (type == EVENT_ERROR)
++              goto out_free;
++
+       /* Handle other operations in the arguments */
+       if (type == EVENT_OP && strcmp(token, ":") != 0) {
+               type = process_op(event, left, &token);
+@@ -2005,6 +2008,12 @@ process_op(struct event_format *event, struct print_arg 
*arg, char **tok)
+                       goto out_warn_free;
+ 
+               type = process_arg_token(event, right, tok, type);
++              if (type == EVENT_ERROR) {
++                      free_arg(right);
++                      /* token was freed in process_arg_token() via *tok */
++                      token = NULL;
++                      goto out_free;
++              }
+ 
+               if (right->type == PRINT_OP &&
+                   get_op_prio(arg->op.op) < get_op_prio(right->op.op)) {
+-- 
+2.14.1
+
diff -Nru trace-cmd-2.6/debian/patches/series 
trace-cmd-2.6/debian/patches/series
--- trace-cmd-2.6/debian/patches/series 2016-07-17 12:40:56.000000000 +0000
+++ trace-cmd-2.6/debian/patches/series 2017-09-20 19:51:11.000000000 +0000
@@ -1 +1,2 @@
 0001-trace-cmd-Use-python2.7-for-executable-name.patch
+0002-tools-lib-traceevent-Add-checks-for-returned-EVENT_E.patch

Reply via email to