stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] perf tools: Fix segfault in cpu_cache_level__read()" failed to apply to 4.19-stable tree
@ 2019-10-08 17:20 gregkh
  2019-10-08 23:40 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2019-10-08 17:20 UTC (permalink / raw)
  To: jolsa, acme, alexander.shishkin, mpetlan, namhyung, peterz; +Cc: stable


The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 0216234c2eed1367a318daeb9f4a97d8217412a0 Mon Sep 17 00:00:00 2001
From: Jiri Olsa <jolsa@kernel.org>
Date: Thu, 12 Sep 2019 12:52:35 +0200
Subject: [PATCH] perf tools: Fix segfault in cpu_cache_level__read()

We release wrong pointer on error path in cpu_cache_level__read
function, leading to segfault:

  (gdb) r record ls
  Starting program: /root/perf/tools/perf/perf record ls
  ...
  [ perf record: Woken up 1 times to write data ]
  double free or corruption (out)

  Thread 1 "perf" received signal SIGABRT, Aborted.
  0x00007ffff7463798 in raise () from /lib64/power9/libc.so.6
  (gdb) bt
  #0  0x00007ffff7463798 in raise () from /lib64/power9/libc.so.6
  #1  0x00007ffff7443bac in abort () from /lib64/power9/libc.so.6
  #2  0x00007ffff74af8bc in __libc_message () from /lib64/power9/libc.so.6
  #3  0x00007ffff74b92b8 in malloc_printerr () from /lib64/power9/libc.so.6
  #4  0x00007ffff74bb874 in _int_free () from /lib64/power9/libc.so.6
  #5  0x0000000010271260 in __zfree (ptr=0x7fffffffa0b0) at ../../lib/zalloc..
  #6  0x0000000010139340 in cpu_cache_level__read (cache=0x7fffffffa090, cac..
  #7  0x0000000010143c90 in build_caches (cntp=0x7fffffffa118, size=<optimiz..
  ...

Releasing the proper pointer.

Fixes: 720e98b5faf1 ("perf tools: Add perf data cache feature")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org: # v4.6+
Link: http://lore.kernel.org/lkml/20190912105235.10689-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 5722ff717777..0167f9697172 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1073,7 +1073,7 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev
 
 	scnprintf(file, PATH_MAX, "%s/shared_cpu_list", path);
 	if (sysfs__read_str(file, &cache->map, &len)) {
-		zfree(&cache->map);
+		zfree(&cache->size);
 		zfree(&cache->type);
 		return -1;
 	}


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

* Re: FAILED: patch "[PATCH] perf tools: Fix segfault in cpu_cache_level__read()" failed to apply to 4.19-stable tree
  2019-10-08 17:20 FAILED: patch "[PATCH] perf tools: Fix segfault in cpu_cache_level__read()" failed to apply to 4.19-stable tree gregkh
@ 2019-10-08 23:40 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2019-10-08 23:40 UTC (permalink / raw)
  To: gregkh; +Cc: jolsa, acme, alexander.shishkin, mpetlan, namhyung, peterz,
	stable

On Tue, Oct 08, 2019 at 07:20:31PM +0200, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 4.19-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h
>
>------------------ original commit in Linus's tree ------------------
>
>From 0216234c2eed1367a318daeb9f4a97d8217412a0 Mon Sep 17 00:00:00 2001
>From: Jiri Olsa <jolsa@kernel.org>
>Date: Thu, 12 Sep 2019 12:52:35 +0200
>Subject: [PATCH] perf tools: Fix segfault in cpu_cache_level__read()
>
>We release wrong pointer on error path in cpu_cache_level__read
>function, leading to segfault:
>
>  (gdb) r record ls
>  Starting program: /root/perf/tools/perf/perf record ls
>  ...
>  [ perf record: Woken up 1 times to write data ]
>  double free or corruption (out)
>
>  Thread 1 "perf" received signal SIGABRT, Aborted.
>  0x00007ffff7463798 in raise () from /lib64/power9/libc.so.6
>  (gdb) bt
>  #0  0x00007ffff7463798 in raise () from /lib64/power9/libc.so.6
>  #1  0x00007ffff7443bac in abort () from /lib64/power9/libc.so.6
>  #2  0x00007ffff74af8bc in __libc_message () from /lib64/power9/libc.so.6
>  #3  0x00007ffff74b92b8 in malloc_printerr () from /lib64/power9/libc.so.6
>  #4  0x00007ffff74bb874 in _int_free () from /lib64/power9/libc.so.6
>  #5  0x0000000010271260 in __zfree (ptr=0x7fffffffa0b0) at ../../lib/zalloc..
>  #6  0x0000000010139340 in cpu_cache_level__read (cache=0x7fffffffa090, cac..
>  #7  0x0000000010143c90 in build_caches (cntp=0x7fffffffa118, size=<optimiz..
>  ...
>
>Releasing the proper pointer.
>
>Fixes: 720e98b5faf1 ("perf tools: Add perf data cache feature")
>Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>Cc: Michael Petlan <mpetlan@redhat.com>
>Cc: Namhyung Kim <namhyung@kernel.org>
>Cc: Peter Zijlstra <peterz@infradead.org>
>Cc: stable@vger.kernel.org: # v4.6+
>Link: http://lore.kernel.org/lkml/20190912105235.10689-1-jolsa@kernel.org
>Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Conflicts due to d8f9da240495b ("perf tools: Use zfree() where
applicable"). Fixed up and queued for 4.9+.

-- 
Thanks,
Sasha

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

end of thread, other threads:[~2019-10-08 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-08 17:20 FAILED: patch "[PATCH] perf tools: Fix segfault in cpu_cache_level__read()" failed to apply to 4.19-stable tree gregkh
2019-10-08 23:40 ` Sasha Levin

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