]> git.karo-electronics.de Git - linux-beck.git/commitdiff
report errors in /proc/*/*map* sanely
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 16 Feb 2011 03:22:54 +0000 (22:22 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 23 Mar 2011 20:36:50 +0000 (16:36 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/proc/base.c
fs/proc/task_mmu.c
fs/proc/task_nommu.c

index df73573e12c906e0427f50a77a57dd0ef50707a1..c282811020826d7c7553e197fdce11c8b45b6da6 100644 (file)
@@ -225,15 +225,17 @@ static int check_mem_permission(struct task_struct *task)
 struct mm_struct *mm_for_maps(struct task_struct *task)
 {
        struct mm_struct *mm;
+       int err;
 
-       if (mutex_lock_killable(&task->signal->cred_guard_mutex))
-               return NULL;
+       err =  mutex_lock_killable(&task->signal->cred_guard_mutex);
+       if (err)
+               return ERR_PTR(err);
 
        mm = get_task_mm(task);
        if (mm && mm != current->mm &&
                        !ptrace_may_access(task, PTRACE_MODE_READ)) {
                mmput(mm);
-               mm = NULL;
+               mm = ERR_PTR(-EACCES);
        }
        mutex_unlock(&task->signal->cred_guard_mutex);
 
index c966413c139ba1aee918fca7d67b006c6bbbfea1..8fed0f88fbf7b66ceda9a453ad6417e3831fa3bd 100644 (file)
@@ -119,11 +119,11 @@ static void *m_start(struct seq_file *m, loff_t *pos)
 
        priv->task = get_pid_task(priv->pid, PIDTYPE_PID);
        if (!priv->task)
-               return NULL;
+               return ERR_PTR(-ESRCH);
 
        mm = mm_for_maps(priv->task);
-       if (!mm)
-               return NULL;
+       if (!mm || IS_ERR(mm))
+               return mm;
        down_read(&mm->mmap_sem);
 
        tail_vma = get_gate_vma(priv->task);
@@ -728,9 +728,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
        if (!task)
                goto out;
 
-       ret = -EACCES;
        mm = mm_for_maps(task);
-       if (!mm)
+       ret = PTR_ERR(mm);
+       if (!mm || IS_ERR(mm))
                goto out_task;
 
        ret = -EINVAL;
index b535d3e5d5f19ede72090e9d06b8f1dcf0e09cd3..980de547c0709b758307dce07a6e81ea9a9c59bd 100644 (file)
@@ -199,13 +199,13 @@ static void *m_start(struct seq_file *m, loff_t *pos)
        /* pin the task and mm whilst we play with them */
        priv->task = get_pid_task(priv->pid, PIDTYPE_PID);
        if (!priv->task)
-               return NULL;
+               return ERR_PTR(-ESRCH);
 
        mm = mm_for_maps(priv->task);
-       if (!mm) {
+       if (!mm || IS_ERR(mm)) {
                put_task_struct(priv->task);
                priv->task = NULL;
-               return NULL;
+               return mm;
        }
        down_read(&mm->mmap_sem);