Casey Chen 99bdfbb868 perf tool: fix dereferencing NULL al->maps
[ Upstream commit 4c17736689ccfc44ec7dcc472577f25c34cf8724 ]

With 0dd5041c9a0e ("perf addr_location: Add init/exit/copy functions"),
when cpumode is 3 (macro PERF_RECORD_MISC_HYPERVISOR),
thread__find_map() could return with al->maps being NULL.

The path below could add a callchain_cursor_node with NULL ms.maps.

add_callchain_ip()
  thread__find_symbol(.., &al)
    thread__find_map(.., &al)   // al->maps becomes NULL
  ms.maps = maps__get(al.maps)
  callchain_cursor_append(..., &ms, ...)
    node->ms.maps = maps__get(ms->maps)

Then the path below would dereference NULL maps and get segfault.

fill_callchain_info()
  maps__machine(node->ms.maps);

Fix it by checking if maps is NULL in fill_callchain_info().

Fixes: 0dd5041c9a0e ("perf addr_location: Add init/exit/copy functions")
Signed-off-by: Casey Chen <cachen@purestorage.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: yzhong@purestorage.com
Link: https://lore.kernel.org/r/20240722211548.61455-1-cachen@purestorage.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-11 12:57:48 +02:00
..
2022-01-12 17:01:38 -08:00
2023-10-25 13:38:33 -07:00
2023-09-12 17:50:36 -03:00
2022-06-28 12:05:25 -03:00
2024-05-10 10:52:46 -03:00
2023-03-14 08:29:46 -03:00
2024-07-07 22:26:27 -07:00
2022-10-04 08:55:21 -03:00
2024-08-03 09:00:05 +02:00
2021-04-29 10:30:58 -03:00
2024-03-21 10:41:28 -03:00
2024-03-21 10:41:28 -03:00
2024-08-03 09:00:05 +02:00
2021-08-11 09:35:44 -03:00
2023-01-23 10:00:47 -03:00
2021-02-03 13:10:44 -03:00
2023-10-12 10:01:56 -07:00
2024-03-21 10:41:28 -03:00
2024-02-12 12:35:41 -08:00
2023-04-06 21:40:28 -03:00
2023-09-12 17:47:00 -03:00
2023-11-09 13:47:50 -03:00
2020-10-14 13:34:26 -03:00
2024-08-03 09:00:05 +02:00
2022-06-23 11:54:22 -03:00
2023-04-10 19:20:53 -03:00