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]
Message-ID: <20250407163538.176140-1-james.o.hunt@intel.com>
Date: Mon,  7 Apr 2025 17:35:38 +0100
From: "James O. D. Hunt" <james.o.hunt@...el.com>
To: linux-perf-users@...r.kernel.org,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Ian Rogers <irogers@...gle.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	"Liang, Kan" <kan.liang@...ux.intel.com>
Cc: linux-kernel@...r.kernel.org,
	"James O . D . Hunt" <james.o.hunt@...el.com>
Subject: [PATCH] perf: header: Check read return

Check the `readn()` return value in `read_attr()` if there are remaining
header bytes to read (previously, the return value was being ignored).

Fixes: 69996df486fc3 ("perf tools: Enable reading of perf.data files from different ABI rev")
Signed-off-by: James O. D. Hunt <james.o.hunt@...el.com>
---
 tools/perf/util/header.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index e3cdc3b7b4ab..09dfd95e350c 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -4161,6 +4161,11 @@ static int read_attr(int fd, struct perf_header *ph,
 		ptr += PERF_ATTR_SIZE_VER0;
 
 		ret = readn(fd, ptr, left);
+		if (ret <= 0) {
+			pr_debug("cannot read %zu remaining bytes of header attr\n",
+				 left);
+			return -1;
+		}
 	}
 	/* read perf_file_section, ids are read in caller */
 	ret = readn(fd, &f_attr->ids, sizeof(f_attr->ids));
-- 
2.49.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ