metadata: return -EFAULT if get_task_mm(current) fails
authorDaniel Mack <zonque@gmail.com>
Sat, 9 Aug 2014 13:00:20 +0000 (15:00 +0200)
committerDaniel Mack <zonque@gmail.com>
Sun, 10 Aug 2014 19:44:01 +0000 (21:44 +0200)
kdbus.h
metadata.c

diff --git a/kdbus.h b/kdbus.h
index 97da18c322deaca4c55fa184b35962d2881aa5c0..b060330cb61fdd10c106855f8d2ebc021acec2ea 100644 (file)
--- 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
index facf70bb8b4c381dbba636a0577f56c44b809e9e..ff1d203fcb9933da6975ab8923e00ca2283354ea 100644 (file)
@@ -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;