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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1427884395-241111-2-git-send-email-wangnan0@huawei.com>
Date:	Wed, 1 Apr 2015 10:33:12 +0000
From:	Wang Nan <wangnan0@...wei.com>
To:	<acme@...nel.org>, <jolsa@...nel.org>, <namhyung@...nel.org>
CC:	<mingo@...hat.com>, <lizefan@...wei.com>, <pi3orama@....com>,
	<linux-kernel@...r.kernel.org>
Subject: [PATCH 1/4] perf tools: unwind: ensure unwind hooks return negative errorno.

According to man pages of libunwind, unwind hooks should return
'negative value of one of the unw_error_t error-codes', they are
different from generic error code. In addition, access_dso_mem()
returns '!(size == sizeof(*data))', compiler never ensure it is
negative when failure, which causes libunwind get undesire value
when accessing //anon memory.

This patch fixes this problem by force returning negative value when
error, instead of returning 'ret' itself when it is non-zero.

Signed-off-by: Wang Nan <wangnan0@...wei.com>
---
 tools/perf/util/unwind-libunwind.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 7b09a44..78a32c7 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -422,7 +422,7 @@ static int access_dso_mem(struct unwind_info *ui, unw_word_t addr,
 	size = dso__data_read_addr(al.map->dso, al.map, ui->machine,
 				   addr, (u8 *) data, sizeof(*data));
 
-	return !(size == sizeof(*data));
+	return (size == sizeof(*data)) ? 0 : -UNW_EINVAL;
 }
 
 static int access_mem(unw_addr_space_t __maybe_unused as,
@@ -443,13 +443,13 @@ static int access_mem(unw_addr_space_t __maybe_unused as,
 
 	ret = perf_reg_value(&start, &ui->sample->user_regs, PERF_REG_SP);
 	if (ret)
-		return ret;
+		return -UNW_EBADREG;
 
 	end = start + stack->size;
 
 	/* Check overflow. */
 	if (addr + sizeof(unw_word_t) < addr)
-		return -EINVAL;
+		return -UNW_EINVAL;
 
 	if (addr < start || addr + sizeof(unw_word_t) >= end) {
 		ret = access_dso_mem(ui, addr, valp);
@@ -491,12 +491,12 @@ static int access_reg(unw_addr_space_t __maybe_unused as,
 
 	id = libunwind__arch_reg_id(regnum);
 	if (id < 0)
-		return -EINVAL;
+		return -UNW_EBADREG;
 
 	ret = perf_reg_value(&val, &ui->sample->user_regs, id);
 	if (ret) {
 		pr_err("unwind: can't read reg %d\n", regnum);
-		return ret;
+		return -UNW_EBADREG;
 	}
 
 	*valp = (unw_word_t) val;
-- 
1.8.3.4

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