aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/base.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r--fs/proc/base.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 1539e630c47d..175db258942f 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
235struct mm_struct *mm_for_maps(struct task_struct *task) 235struct 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;
249out:
250 task_unlock(task);
251 up_read(&mm->mmap_sem);
252 mmput(mm);
253 return NULL;
254} 251}
255 252
256static int proc_pid_cmdline(struct task_struct *task, char * buffer) 253static int proc_pid_cmdline(struct task_struct *task, char * buffer)
@@ -1006,7 +1003,12 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf,
1006 1003
1007 if (!task) 1004 if (!task)
1008 return -ESRCH; 1005 return -ESRCH;
1009 oom_adjust = task->oomkilladj; 1006 task_lock(task);
1007 if (task->mm)
1008 oom_adjust = task->mm->oom_adj;
1009 else
1010 oom_adjust = OOM_DISABLE;
1011 task_unlock(task);
1010 put_task_struct(task); 1012 put_task_struct(task);
1011 1013
1012 len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust); 1014 len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust);
@@ -1035,11 +1037,19 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
1035 task = get_proc_task(file->f_path.dentry->d_inode); 1037 task = get_proc_task(file->f_path.dentry->d_inode);
1036 if (!task) 1038 if (!task)
1037 return -ESRCH; 1039 return -ESRCH;
1038 if (oom_adjust < task->oomkilladj && !capable(CAP_SYS_RESOURCE)) { 1040 task_lock(task);
1041 if (!task->mm) {
1042 task_unlock(task);
1043 put_task_struct(task);
1044 return -EINVAL;
1045 }
1046 if (oom_adjust < task->mm->oom_adj && !capable(CAP_SYS_RESOURCE)) {
1047 task_unlock(task);
1039 put_task_struct(task); 1048 put_task_struct(task);
1040 return -EACCES; 1049 return -EACCES;
1041 } 1050 }
1042 task->oomkilladj = oom_adjust; 1051 task->mm->oom_adj = oom_adjust;
1052 task_unlock(task);
1043 put_task_struct(task); 1053 put_task_struct(task);
1044 if (end - buffer == 0) 1054 if (end - buffer == 0)
1045 return -EIO; 1055 return -EIO;