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>] [day] [month] [year] [list]
Date:	Fri, 22 Nov 2013 16:19:16 -0500
From:	Francis Giraldeau <francis.giraldeau@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	Francis Giraldeau <francis.giraldeau@...il.com>
Subject: [PATCH] Prevent infinite loop if unwind fails

Unwind may loop forever if sample is incomplete or bogus. Bound the number of
unw_step() that yield the same IP to prevent infinite loop.

Signed-off-by: Francis Giraldeau <francis.giraldeau@...il.com>
---
 tools/perf/util/unwind.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/unwind.c b/tools/perf/util/unwind.c
index 958723b..bf45b6b 100644
--- a/tools/perf/util/unwind.c
+++ b/tools/perf/util/unwind.c
@@ -520,7 +520,8 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
 {
 	unw_addr_space_t addr_space;
 	unw_cursor_t c;
-	int ret;
+	unw_word_t prev_ip = 0;
+	int ret, rec = 0;
 
 	addr_space = unw_create_addr_space(&accessors, 0);
 	if (!addr_space) {
@@ -537,6 +538,11 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
 
 		unw_get_reg(&c, UNW_REG_IP, &ip);
 		ret = entry(ip, ui->thread, ui->machine, cb, arg);
+		if (prev_ip != ip)
+			rec = 0;
+		if (++rec >= 100)
+			break;
+		prev_ip = ip;
 	}
 
 	unw_destroy_addr_space(addr_space);
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ