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-prev] [day] [month] [year] [list]
Message-ID: <tip-30ba5b0e66c872faa416a458d32cc3956ecb548a@git.kernel.org>
Date:   Sat, 18 May 2019 01:59:26 -0700
From:   tip-bot for Donald Yandt <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     alexander.shishkin@...ux.intel.com, mingo@...nel.org,
        linux-kernel@...r.kernel.org, peterz@...radead.org, hpa@...or.com,
        yanmin_zhang@...ux.intel.com, acme@...hat.com, jolsa@...hat.com,
        tglx@...utronix.de, donald.yandt@...il.com, avi@...lladb.com
Subject: [tip:perf/core] perf machine: Null-terminate version char array
 upon fgets(/proc/version) error

Commit-ID:  30ba5b0e66c872faa416a458d32cc3956ecb548a
Gitweb:     https://git.kernel.org/tip/30ba5b0e66c872faa416a458d32cc3956ecb548a
Author:     Donald Yandt <donald.yandt@...il.com>
AuthorDate: Tue, 14 May 2019 07:01:00 -0400
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Wed, 15 May 2019 16:36:47 -0300

perf machine: Null-terminate version char array upon fgets(/proc/version) error

If fgets() fails due to any other error besides end-of-file, the version
char array may not even be null-terminated.

Signed-off-by: Donald Yandt <donald.yandt@...il.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Avi Kivity <avi@...lladb.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Yanmin Zhang <yanmin_zhang@...ux.intel.com>
Fixes: a1645ce12adb ("perf: 'perf kvm' tool for monitoring guest performance from host")
Link: http://lkml.kernel.org/r/20190514110100.22019-1-donald.yandt@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 3c520baa198c..28a9541c4835 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1234,8 +1234,9 @@ static char *get_kernel_version(const char *root_dir)
 	if (!file)
 		return NULL;
 
-	version[0] = '\0';
 	tmp = fgets(version, sizeof(version), file);
+	if (!tmp)
+		*version = '\0';
 	fclose(file);
 
 	name = strstr(version, prefix);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ