From 932de7a48e7a6219f21de48e378c44dd2b433774 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Sat, 9 Aug 2014 15:00:20 +0200 Subject: [PATCH] metadata: return -EFAULT if get_task_mm(current) fails --- kdbus.h | 5 +++-- metadata.c | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/kdbus.h b/kdbus.h index 97da18c..b060330 100644 --- a/kdbus.h +++ b/kdbus.h @@ -903,8 +903,9 @@ enum kdbus_ioctl_type { * @EEXIST: A requested domain, bus or endpoint with the same * name already exists. A specific data type, which is * only expected once, is provided multiple times. - * @EFAULT: The supplied memory could not be accessed, or the data - * is not properly aligned. + * @EFAULT: The supplied memory could not be accessed, the data + * is not properly aligned, or the current task's memory + * is inaccessible. * @EINVAL: The provided data does not match its type or other * expectations, like a string which is not NUL terminated, * or a string length that points behind the first diff --git a/metadata.c b/metadata.c index facf70b..ff1d203 100644 --- a/metadata.c +++ b/metadata.c @@ -262,14 +262,15 @@ static int kdbus_meta_append_exe(struct kdbus_meta *meta) size_t len; char *tmp; - if (mm) { - down_read(&mm->mmap_sem); - if (mm->exe_file) { - path_get(&mm->exe_file->f_path); - exe_path = &mm->exe_file->f_path; - } - up_read(&mm->mmap_sem); + if (!mm) + return -EFAULT; + + down_read(&mm->mmap_sem); + if (mm->exe_file) { + path_get(&mm->exe_file->f_path); + exe_path = &mm->exe_file->f_path; } + up_read(&mm->mmap_sem); if (!exe_path) goto exit_mmput; @@ -313,8 +314,10 @@ static int kdbus_meta_append_cmdline(struct kdbus_meta *meta) return -ENOMEM; mm = get_task_mm(current); - if (!mm) + if (!mm) { + ret = -EFAULT; goto exit_free_page; + } if (!mm->arg_end) goto exit_mmput; -- 2.34.1