proc: Fix ptrace-based permission checks for accessing task maps
authorCorey Wright <undefined@pobox.com>
Sun, 28 Feb 2016 08:42:39 +0000 (02:42 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Mar 2016 23:06:19 +0000 (15:06 -0800)
Modify mm_access() calls in fs/proc/task_mmu.c and fs/proc/task_nommu.c to
have the mode include PTRACE_MODE_FSCREDS so accessing /proc/pid/maps and
/proc/pid/pagemap is not denied to all users.

In backporting upstream commit caaee623 to pre-3.18 kernel versions it was
overlooked that mm_access() is used in fs/proc/task_*mmu.c as those calls
were removed in 3.18 (by upstream commit 29a40ace) and did not exist at the
time of the original commit.

Signed-off-by: Corey Wright <undefined@pobox.com>
Acked-by: Jann Horn <jann@thejh.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/proc/task_mmu.c
fs/proc/task_nommu.c

index 9f285fb9bab392e1342a4e0c45333a80ded284ea..b86db1236c7c9c5e1d5506225f6ba65b42c58a62 100644 (file)
@@ -170,7 +170,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
        if (!priv->task)
                return ERR_PTR(-ESRCH);
 
-       mm = mm_access(priv->task, PTRACE_MODE_READ);
+       mm = mm_access(priv->task, PTRACE_MODE_READ_FSCREDS);
        if (!mm || IS_ERR(mm))
                return mm;
        down_read(&mm->mmap_sem);
@@ -1044,7 +1044,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
        if (!pm.buffer)
                goto out_task;
 
-       mm = mm_access(task, PTRACE_MODE_READ);
+       mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
        ret = PTR_ERR(mm);
        if (!mm || IS_ERR(mm))
                goto out_free;
index 56123a6f462e7d9d84275d88f093c0926bf88576..123c19890b14e7a182b965c561274ef80b4dc293 100644 (file)
@@ -223,7 +223,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
        if (!priv->task)
                return ERR_PTR(-ESRCH);
 
-       mm = mm_access(priv->task, PTRACE_MODE_READ);
+       mm = mm_access(priv->task, PTRACE_MODE_READ_FSCREDS);
        if (!mm || IS_ERR(mm)) {
                put_task_struct(priv->task);
                priv->task = NULL;