lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240721031944.62913-1-cachen@purestorage.com>
Date: Sat, 20 Jul 2024 21:19:44 -0600
From: Casey Chen <cachen@...estorage.com>
To: linux-perf-users@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	namhyung@...nel.org
Cc: yzhong@...estorage.com,
	Casey Chen <cachen@...estorage.com>
Subject: [PATCHv3] perf tool: fix dereferencing NULL al->maps

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 maps__machine().
---
 tools/perf/util/maps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c
index 432399cbe5dd..d243cb794a99 100644
--- a/tools/perf/util/maps.c
+++ b/tools/perf/util/maps.c
@@ -169,7 +169,7 @@ static void maps__set_maps_by_name_sorted(struct maps *maps, bool value)
 
 struct machine *maps__machine(const struct maps *maps)
 {
-	return RC_CHK_ACCESS(maps)->machine;
+	return maps ? RC_CHK_ACCESS(maps)->machine : NULL;
 }
 
 unsigned int maps__nr_maps(const struct maps *maps)
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ