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] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-6584140ba9e6762dd7ec73795243289b914f31f9@git.kernel.org>
Date:   Tue, 28 May 2019 14:27:37 -0700
From:   tip-bot for Namhyung Kim <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     hbathini@...ux.vnet.ibm.com, mingo@...nel.org, namhyung@...nel.org,
        acme@...hat.com, linux-kernel@...r.kernel.org,
        kjlx@...pleofstupid.com, jolsa@...hat.com, tglx@...utronix.de,
        hpa@...or.com
Subject: [tip:perf/urgent] perf namespace: Protect reading thread's
 namespace

Commit-ID:  6584140ba9e6762dd7ec73795243289b914f31f9
Gitweb:     https://git.kernel.org/tip/6584140ba9e6762dd7ec73795243289b914f31f9
Author:     Namhyung Kim <namhyung@...nel.org>
AuthorDate: Wed, 22 May 2019 14:32:48 +0900
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Tue, 28 May 2019 09:52:23 -0300

perf namespace: Protect reading thread's namespace

It seems that the current code lacks holding the namespace lock in
thread__namespaces().  Otherwise it can see inconsistent results.

Signed-off-by: Namhyung Kim <namhyung@...nel.org>
Cc: Hari Bathini <hbathini@...ux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Krister Johansen <kjlx@...pleofstupid.com>
Link: http://lkml.kernel.org/r/20190522053250.207156-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/thread.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 403045a2bbea..b413ba5b9835 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -133,7 +133,7 @@ void thread__put(struct thread *thread)
 	}
 }
 
-struct namespaces *thread__namespaces(const struct thread *thread)
+static struct namespaces *__thread__namespaces(const struct thread *thread)
 {
 	if (list_empty(&thread->namespaces_list))
 		return NULL;
@@ -141,10 +141,21 @@ struct namespaces *thread__namespaces(const struct thread *thread)
 	return list_first_entry(&thread->namespaces_list, struct namespaces, list);
 }
 
+struct namespaces *thread__namespaces(const struct thread *thread)
+{
+	struct namespaces *ns;
+
+	down_read((struct rw_semaphore *)&thread->namespaces_lock);
+	ns = __thread__namespaces(thread);
+	up_read((struct rw_semaphore *)&thread->namespaces_lock);
+
+	return ns;
+}
+
 static int __thread__set_namespaces(struct thread *thread, u64 timestamp,
 				    struct namespaces_event *event)
 {
-	struct namespaces *new, *curr = thread__namespaces(thread);
+	struct namespaces *new, *curr = __thread__namespaces(thread);
 
 	new = namespaces__new(event);
 	if (!new)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ