diff options
author | Oleg Nesterov <oleg@redhat.com> | 2010-05-26 17:42:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:44 -0400 |
commit | e0129ef91ed758c06b6557c36124acfb2e1c7305 (patch) | |
tree | e47392371ed106f2241d18ac6339bedd6c699c9b | |
parent | 9c1a125921d146f22cf28ff366ff69fd602a0e9b (diff) |
ptrace: PTRACE_GETFDPIC: fix the unsafe usage of child->mm
Now that Mike Frysinger unified the FDPIC ptrace code, we can fix the
unsafe usage of child->mm in ptrace_request(PTRACE_GETFDPIC).
We have the reference to task_struct, and ptrace_check_attach() verified
the tracee is stopped. But nothing can protect from SIGKILL after that,
we must not assume child->mm != NULL.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Mike Frysinger <vapier.adi@gmail.com>
Acked-by: David Howells <dhowells@redhat.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Greg Ungerer <gerg@snapgear.com>
Acked-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/ptrace.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 4b4f72084d1b..74a3d693c196 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -596,18 +596,24 @@ int ptrace_request(struct task_struct *child, long request, | |||
596 | 596 | ||
597 | #ifdef CONFIG_BINFMT_ELF_FDPIC | 597 | #ifdef CONFIG_BINFMT_ELF_FDPIC |
598 | case PTRACE_GETFDPIC: { | 598 | case PTRACE_GETFDPIC: { |
599 | struct mm_struct *mm = get_task_mm(child); | ||
599 | unsigned long tmp = 0; | 600 | unsigned long tmp = 0; |
600 | 601 | ||
602 | ret = -ESRCH; | ||
603 | if (!mm) | ||
604 | break; | ||
605 | |||
601 | switch (addr) { | 606 | switch (addr) { |
602 | case PTRACE_GETFDPIC_EXEC: | 607 | case PTRACE_GETFDPIC_EXEC: |
603 | tmp = child->mm->context.exec_fdpic_loadmap; | 608 | tmp = mm->context.exec_fdpic_loadmap; |
604 | break; | 609 | break; |
605 | case PTRACE_GETFDPIC_INTERP: | 610 | case PTRACE_GETFDPIC_INTERP: |
606 | tmp = child->mm->context.interp_fdpic_loadmap; | 611 | tmp = mm->context.interp_fdpic_loadmap; |
607 | break; | 612 | break; |
608 | default: | 613 | default: |
609 | break; | 614 | break; |
610 | } | 615 | } |
616 | mmput(mm); | ||
611 | 617 | ||
612 | ret = put_user(tmp, (unsigned long __user *) data); | 618 | ret = put_user(tmp, (unsigned long __user *) data); |
613 | break; | 619 | break; |