diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 3326bbf9ab95..6f742f6658a9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -234,23 +234,20 @@ static int check_mem_permission(struct task_struct *task) | |||
234 | 234 | ||
235 | struct mm_struct *mm_for_maps(struct task_struct *task) | 235 | struct mm_struct *mm_for_maps(struct task_struct *task) |
236 | { | 236 | { |
237 | struct mm_struct *mm = get_task_mm(task); | 237 | struct mm_struct *mm; |
238 | if (!mm) | 238 | |
239 | if (mutex_lock_killable(&task->cred_guard_mutex)) | ||
239 | return NULL; | 240 | return NULL; |
240 | down_read(&mm->mmap_sem); | 241 | |
241 | task_lock(task); | 242 | mm = get_task_mm(task); |
242 | if (task->mm != mm) | 243 | if (mm && mm != current->mm && |
243 | goto out; | 244 | !ptrace_may_access(task, PTRACE_MODE_READ)) { |
244 | if (task->mm != current->mm && | 245 | mmput(mm); |
245 | __ptrace_may_access(task, PTRACE_MODE_READ) < 0) | 246 | mm = NULL; |
246 | goto out; | 247 | } |
247 | task_unlock(task); | 248 | mutex_unlock(&task->cred_guard_mutex); |
249 | |||
248 | return mm; | 250 | return mm; |
249 | out: | ||
250 | task_unlock(task); | ||
251 | up_read(&mm->mmap_sem); | ||
252 | mmput(mm); | ||
253 | return NULL; | ||
254 | } | 251 | } |
255 | 252 | ||
256 | static int proc_pid_cmdline(struct task_struct *task, char * buffer) | 253 | static int proc_pid_cmdline(struct task_struct *task, char * buffer) |
@@ -2128,9 +2125,15 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf, | |||
2128 | if (copy_from_user(page, buf, count)) | 2125 | if (copy_from_user(page, buf, count)) |
2129 | goto out_free; | 2126 | goto out_free; |
2130 | 2127 | ||
2128 | /* Guard against adverse ptrace interaction */ | ||
2129 | length = mutex_lock_interruptible(&task->cred_guard_mutex); | ||
2130 | if (length < 0) | ||
2131 | goto out_free; | ||
2132 | |||
2131 | length = security_setprocattr(task, | 2133 | length = security_setprocattr(task, |
2132 | (char*)file->f_path.dentry->d_name.name, | 2134 | (char*)file->f_path.dentry->d_name.name, |
2133 | (void*)page, count); | 2135 | (void*)page, count); |
2136 | mutex_unlock(&task->cred_guard_mutex); | ||
2134 | out_free: | 2137 | out_free: |
2135 | free_page((unsigned long) page); | 2138 | free_page((unsigned long) page); |
2136 | out: | 2139 | out: |