aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2015-04-16 15:49:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-17 09:04:11 -0400
commitd4144ea6e7cc307e84cd9ca227df7b04a54a2365 (patch)
treea12d8c0df4e50b5b307cc2d77d5f870ed7042dba /security
parentfd89a65f155fa890c0130139dfb91684d6da4cfb (diff)
tomoyo: reduce mmap_sem hold for mm->exe_file
The mm->exe_file is currently serialized with mmap_sem (shared) in order to both safely (1) read the file and (2) compute the realpath by calling tomoyo_realpath_from_path, making it an absolute overkill. Good users will, on the other hand, make use of the more standard get_mm_exe_file(), requiring only holding the mmap_sem to read the value, and relying on reference [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Acked-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: James Morris <jmorris@namei.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'security')
-rw-r--r--security/tomoyo/util.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/security/tomoyo/util.c b/security/tomoyo/util.c
index 2952ba576fb9..b974a6997d7f 100644
--- a/security/tomoyo/util.c
+++ b/security/tomoyo/util.c
@@ -948,15 +948,18 @@ bool tomoyo_path_matches_pattern(const struct tomoyo_path_info *filename,
948 */ 948 */
949const char *tomoyo_get_exe(void) 949const char *tomoyo_get_exe(void)
950{ 950{
951 struct file *exe_file;
952 const char *cp;
951 struct mm_struct *mm = current->mm; 953 struct mm_struct *mm = current->mm;
952 const char *cp = NULL;
953 954
954 if (!mm) 955 if (!mm)
955 return NULL; 956 return NULL;
956 down_read(&mm->mmap_sem); 957 exe_file = get_mm_exe_file(mm);
957 if (mm->exe_file) 958 if (!exe_file)
958 cp = tomoyo_realpath_from_path(&mm->exe_file->f_path); 959 return NULL;
959 up_read(&mm->mmap_sem); 960
961 cp = tomoyo_realpath_from_path(&exe_file->f_path);
962 fput(exe_file);
960 return cp; 963 return cp;
961} 964}
962 965