diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-02-15 22:22:54 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-23 16:36:50 -0400 |
commit | ec6fd8a4355cda81cd9f06bebc048e83eb514ac7 (patch) | |
tree | 828c3f2e1b474cc0ec9768d5dc19cfa2c086898f /fs/proc | |
parent | ca6b0bf0e086513b9ee5efc0aa5770ecb57778af (diff) |
report errors in /proc/*/*map* sanely
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/base.c | 8 | ||||
-rw-r--r-- | fs/proc/task_mmu.c | 10 | ||||
-rw-r--r-- | fs/proc/task_nommu.c | 6 |
3 files changed, 13 insertions, 11 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index df73573e12c9..c28281102082 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -225,15 +225,17 @@ static int check_mem_permission(struct task_struct *task) | |||
225 | struct mm_struct *mm_for_maps(struct task_struct *task) | 225 | struct mm_struct *mm_for_maps(struct task_struct *task) |
226 | { | 226 | { |
227 | struct mm_struct *mm; | 227 | struct mm_struct *mm; |
228 | int err; | ||
228 | 229 | ||
229 | if (mutex_lock_killable(&task->signal->cred_guard_mutex)) | 230 | err = mutex_lock_killable(&task->signal->cred_guard_mutex); |
230 | return NULL; | 231 | if (err) |
232 | return ERR_PTR(err); | ||
231 | 233 | ||
232 | mm = get_task_mm(task); | 234 | mm = get_task_mm(task); |
233 | if (mm && mm != current->mm && | 235 | if (mm && mm != current->mm && |
234 | !ptrace_may_access(task, PTRACE_MODE_READ)) { | 236 | !ptrace_may_access(task, PTRACE_MODE_READ)) { |
235 | mmput(mm); | 237 | mmput(mm); |
236 | mm = NULL; | 238 | mm = ERR_PTR(-EACCES); |
237 | } | 239 | } |
238 | mutex_unlock(&task->signal->cred_guard_mutex); | 240 | mutex_unlock(&task->signal->cred_guard_mutex); |
239 | 241 | ||
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index c966413c139b..8fed0f88fbf7 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -119,11 +119,11 @@ static void *m_start(struct seq_file *m, loff_t *pos) | |||
119 | 119 | ||
120 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); | 120 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); |
121 | if (!priv->task) | 121 | if (!priv->task) |
122 | return NULL; | 122 | return ERR_PTR(-ESRCH); |
123 | 123 | ||
124 | mm = mm_for_maps(priv->task); | 124 | mm = mm_for_maps(priv->task); |
125 | if (!mm) | 125 | if (!mm || IS_ERR(mm)) |
126 | return NULL; | 126 | return mm; |
127 | down_read(&mm->mmap_sem); | 127 | down_read(&mm->mmap_sem); |
128 | 128 | ||
129 | tail_vma = get_gate_vma(priv->task); | 129 | tail_vma = get_gate_vma(priv->task); |
@@ -728,9 +728,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
728 | if (!task) | 728 | if (!task) |
729 | goto out; | 729 | goto out; |
730 | 730 | ||
731 | ret = -EACCES; | ||
732 | mm = mm_for_maps(task); | 731 | mm = mm_for_maps(task); |
733 | if (!mm) | 732 | ret = PTR_ERR(mm); |
733 | if (!mm || IS_ERR(mm)) | ||
734 | goto out_task; | 734 | goto out_task; |
735 | 735 | ||
736 | ret = -EINVAL; | 736 | ret = -EINVAL; |
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index b535d3e5d5f1..980de547c070 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -199,13 +199,13 @@ static void *m_start(struct seq_file *m, loff_t *pos) | |||
199 | /* pin the task and mm whilst we play with them */ | 199 | /* pin the task and mm whilst we play with them */ |
200 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); | 200 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); |
201 | if (!priv->task) | 201 | if (!priv->task) |
202 | return NULL; | 202 | return ERR_PTR(-ESRCH); |
203 | 203 | ||
204 | mm = mm_for_maps(priv->task); | 204 | mm = mm_for_maps(priv->task); |
205 | if (!mm) { | 205 | if (!mm || IS_ERR(mm)) { |
206 | put_task_struct(priv->task); | 206 | put_task_struct(priv->task); |
207 | priv->task = NULL; | 207 | priv->task = NULL; |
208 | return NULL; | 208 | return mm; |
209 | } | 209 | } |
210 | down_read(&mm->mmap_sem); | 210 | down_read(&mm->mmap_sem); |
211 | 211 | ||