summaryrefslogtreecommitdiffstats
path: root/kdbus-use-rcu-to-access-exe-file-in-metadata.patch
blob: 19678786a441323556ac1c5d4949f7328c2d6ecd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From: Daniel Mack <daniel@zonque.org>
Date: Sat, 18 Apr 2015 12:04:36 +0200
Subject: [PATCH] kdbus: use rcu to access exe file in metadata

Commit 90f31d0ea888 ("mm: rcu-protected get_mm_exe_file()") removed
mm->mmap_sem from mm->exe_file read side. Follow that change in the
kdbus metadata code.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 ipc/kdbus/metadata.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ipc/kdbus/metadata.c b/ipc/kdbus/metadata.c
index 7949c8d3ed64..a85eac34a5c4 100644
--- a/ipc/kdbus/metadata.c
+++ b/ipc/kdbus/metadata.c
@@ -283,19 +283,21 @@ static void kdbus_meta_proc_collect_pid_comm(struct kdbus_meta_proc *mp)
 static void kdbus_meta_proc_collect_exe(struct kdbus_meta_proc *mp)
 {
 	struct mm_struct *mm;
+	struct file *exe_file;
 
 	mm = get_task_mm(current);
 	if (!mm)
 		return;
 
-	down_read(&mm->mmap_sem);
-	if (mm->exe_file) {
-		mp->exe_path = mm->exe_file->f_path;
+	rcu_read_lock();
+	exe_file = rcu_dereference(mm->exe_file);
+	if (exe_file) {
+		mp->exe_path = exe_file->f_path;
 		path_get(&mp->exe_path);
 		get_fs_root(current->fs, &mp->root_path);
 		mp->valid |= KDBUS_ATTACH_EXE;
 	}
-	up_read(&mm->mmap_sem);
+	rcu_read_unlock();
 
 	mmput(mm);
 }