Merge branch 'irq-threaded-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / fs / proc / base.c
index 917f338..6f742f6 100644 (file)
@@ -234,21 +234,19 @@ static int check_mem_permission(struct task_struct *task)
 
 struct mm_struct *mm_for_maps(struct task_struct *task)
 {
-       struct mm_struct *mm = get_task_mm(task);
-       if (!mm)
+       struct mm_struct *mm;
+
+       if (mutex_lock_killable(&task->cred_guard_mutex))
                return NULL;
-       if (mm != current->mm) {
-               /*
-                * task->mm can be changed before security check,
-                * in that case we must notice the change after.
-                */
-               if (!ptrace_may_access(task, PTRACE_MODE_READ) ||
-                   mm != task->mm) {
-                       mmput(mm);
-                       return NULL;
-               }
+
+       mm = get_task_mm(task);
+       if (mm && mm != current->mm &&
+                       !ptrace_may_access(task, PTRACE_MODE_READ)) {
+               mmput(mm);
+               mm = NULL;
        }
-       down_read(&mm->mmap_sem);
+       mutex_unlock(&task->cred_guard_mutex);
+
        return mm;
 }
 
@@ -1005,12 +1003,7 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf,
 
        if (!task)
                return -ESRCH;
-       task_lock(task);
-       if (task->mm)
-               oom_adjust = task->mm->oom_adj;
-       else
-               oom_adjust = OOM_DISABLE;
-       task_unlock(task);
+       oom_adjust = task->oomkilladj;
        put_task_struct(task);
 
        len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust);
@@ -1039,19 +1032,11 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
        task = get_proc_task(file->f_path.dentry->d_inode);
        if (!task)
                return -ESRCH;
-       task_lock(task);
-       if (!task->mm) {
-               task_unlock(task);
-               put_task_struct(task);
-               return -EINVAL;
-       }
-       if (oom_adjust < task->mm->oom_adj && !capable(CAP_SYS_RESOURCE)) {
-               task_unlock(task);
+       if (oom_adjust < task->oomkilladj && !capable(CAP_SYS_RESOURCE)) {
                put_task_struct(task);
                return -EACCES;
        }
-       task->mm->oom_adj = oom_adjust;
-       task_unlock(task);
+       task->oomkilladj = oom_adjust;
        put_task_struct(task);
        if (end - buffer == 0)
                return -EIO;