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:   Sat, 30 May 2020 06:15:35 +0000
From:   Cheng Jian <cj.chengjian@...wei.com>
To:     <linux-kernel@...r.kernel.org>, <linux-perf-users@...r.kernel.org>
CC:     <cj.chengjian@...wei.com>, <bobo.shaobowang@...wei.com>,
        <huawei.libin@...wei.com>, <acme@...nel.org>
Subject: [PATCH] perf/evsel: Fix missing close fd when ignore_missing_thread

While monitoring a multithread process with pid option, if any of the
threads exit before we open the event fd, we can ignore the missing
thread.

We use perf_evsel__remove_fd() to remove the FD of the missing thread,
but we missed to close these fds. This patch explicitly closes the fd
before remove it.

Fixes: ca8000684ec4 ("perf evsel: Enable ignore_missing_thread for pid option")
Signed-off-by: Cheng Jian <cj.chengjian@...wei.com>
---
 tools/perf/util/evsel.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index eb880efbce16..cbb04a18839c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1489,9 +1489,13 @@ static void perf_evsel__remove_fd(struct evsel *pos,
 				  int nr_cpus, int nr_threads,
 				  int thread_idx)
 {
-	for (int cpu = 0; cpu < nr_cpus; cpu++)
-		for (int thread = thread_idx; thread < nr_threads - 1; thread++)
+	for (int cpu = 0; cpu < nr_cpus; cpu++) {
+		for (int thread = thread_idx;
+		     thread < nr_threads - 1; thread++) {
+			close(FD(pos, cpu, thread));
 			FD(pos, cpu, thread) = FD(pos, cpu, thread + 1);
+		}
+	}
 }
 
 static int update_fds(struct evsel *evsel,
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ