Skip to content

Commit

Permalink
/proc/*/environ: wrong placing of ptrace_may_attach() check
Browse files Browse the repository at this point in the history
It's a bit dopey-looking and can permit a task to cause a pagefault in an mm
which it doesn't have permission to read from.

Signed-off-by: Alexey Dobriyan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and Linus Torvalds committed Jul 16, 2007
1 parent 7126dd0 commit da58a16
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,17 @@ static int proc_pid_environ(struct task_struct *task, char * buffer)
int res = 0;
struct mm_struct *mm = get_task_mm(task);
if (mm) {
unsigned int len = mm->env_end - mm->env_start;
unsigned int len;

res = -ESRCH;
if (!ptrace_may_attach(task))
goto out;

len = mm->env_end - mm->env_start;
if (len > PAGE_SIZE)
len = PAGE_SIZE;
res = access_process_vm(task, mm->env_start, buffer, len, 0);
if (!ptrace_may_attach(task))
res = -ESRCH;
out:
mmput(mm);
}
return res;
Expand Down

0 comments on commit da58a16

Please sign in to comment.