kernel/kdbus-use-rcu-to-access-exe-file-in-metadata.patch
2015-07-08 10:30:06 -04:00

45 lines
1.3 KiB
Diff

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);
}