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]
Date:   Mon, 17 Aug 2020 15:53:45 +0100
From:   Leo Yan <leo.yan@...aro.org>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        James Clark <james.clark@....com>,
        Will Deacon <will@...nel.org>, Al Grant <Al.Grant@....com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Wei Li <liwei391@...wei.com>, linux-kernel@...r.kernel.org,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Mike Leach <mike.leach@...aro.org>
Cc:     Leo Yan <leo.yan@...aro.org>
Subject: [PATCH RESEND v1 10/13] perf arm-spe: Detect failure for snprintf()

When any failure is returned from snprintf(), the event packet decoding
detects the failure and bail out with reporting failure code to up
layer.

Signed-off-by: Leo Yan <leo.yan@...aro.org>
---
 .../arm-spe-decoder/arm-spe-pkt-decoder.c     | 27 ++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
index 78250c8d74ca..121414e4ae23 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
@@ -262,68 +262,89 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
 
 		ret = 0;
 		ret = snprintf(buf, buf_len, "EV");
+		if (ret < 0)
+			return ret;
 		buf += ret;
 		blen -= ret;
 		if (payload & SPE_EVT_PKT_GEN_EXCEPTION) {
 			ret = snprintf(buf, buf_len, " EXCEPTION-GEN");
+			if (ret < 0)
+				return ret;
 			buf += ret;
 			blen -= ret;
 		}
 		if (payload & SPE_EVT_PKT_ARCH_RETIRED) {
 			ret = snprintf(buf, buf_len, " RETIRED");
+			if (ret < 0)
+				return ret;
 			buf += ret;
 			blen -= ret;
 		}
 		if (payload & SPE_EVT_PKT_L1D_ACCESS) {
 			ret = snprintf(buf, buf_len, " L1D-ACCESS");
+			if (ret < 0)
+				return ret;
 			buf += ret;
 			blen -= ret;
 		}
 		if (payload & SPE_EVT_PKT_L1D_REFILL) {
 			ret = snprintf(buf, buf_len, " L1D-REFILL");
+			if (ret < 0)
+				return ret;
 			buf += ret;
 			blen -= ret;
 		}
 		if (payload & SPE_EVT_PKT_TLB_ACCESS) {
 			ret = snprintf(buf, buf_len, " TLB-ACCESS");
+			if (ret < 0)
+				return ret;
 			buf += ret;
 			blen -= ret;
 		}
 		if (payload & SPE_EVT_PKT_TLB_WALK) {
 			ret = snprintf(buf, buf_len, " TLB-REFILL");
+			if (ret < 0)
+				return ret;
 			buf += ret;
 			blen -= ret;
 		}
 		if (payload & SPE_EVT_PKT_NOT_TAKEN) {
 			ret = snprintf(buf, buf_len, " NOT-TAKEN");
+			if (ret < 0)
+				return ret;
 			buf += ret;
 			blen -= ret;
 		}
 		if (payload & SPE_EVT_PKT_MISPREDICTED) {
 			ret = snprintf(buf, buf_len, " MISPRED");
+			if (ret < 0)
+				return ret;
 			buf += ret;
 			blen -= ret;
 		}
 		if (idx > 1) {
 			if (payload & SPE_EVT_PKT_LLC_ACCESS) {
 				ret = snprintf(buf, buf_len, " LLC-ACCESS");
+				if (ret < 0)
+					return ret;
 				buf += ret;
 				blen -= ret;
 			}
 			if (payload & SPE_EVT_PKT_LLC_MISS) {
 				ret = snprintf(buf, buf_len, " LLC-REFILL");
+				if (ret < 0)
+					return ret;
 				buf += ret;
 				blen -= ret;
 			}
 			if (payload & SPE_EVT_PKT_REMOTE_ACCESS) {
 				ret = snprintf(buf, buf_len, " REMOTE-ACCESS");
+				if (ret < 0)
+					return ret;
 				buf += ret;
 				blen -= ret;
 			}
 		}
-		if (ret < 0)
-			return ret;
-		blen -= ret;
 		return buf_len - blen;
 	}
 	case ARM_SPE_OP_TYPE:
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ