Skip to content

Commit bf0b8f4

Browse files
committed
arm, hw_breakpoints: Fix racy access to ptrace breakpoints
While the tracer accesses ptrace breakpoints, the child task may concurrently exit due to a SIGKILL and thus release its breakpoints at the same time. We can then dereference some freed pointers. To fix this, hold a reference on the child breakpoints before manipulating them. Reported-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Will Deacon <will.deacon@arm.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Prasad <prasad@linux.vnet.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Link: http://lkml.kernel.org/r/1302284067-7860-5-git-send-email-fweisbec@gmail.com
1 parent 07fa7a0 commit bf0b8f4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎arch/arm/kernel/ptrace.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,12 +767,20 @@ long arch_ptrace(struct task_struct *child, long request,
767767

768768
#ifdef CONFIG_HAVE_HW_BREAKPOINT
769769
case PTRACE_GETHBPREGS:
770+
if (ptrace_get_breakpoints(child) < 0)
771+
return -ESRCH;
772+
770773
ret = ptrace_gethbpregs(child, addr,
771774
(unsigned long __user *)data);
775+
ptrace_put_breakpoints(child);
772776
break;
773777
case PTRACE_SETHBPREGS:
778+
if (ptrace_get_breakpoints(child) < 0)
779+
return -ESRCH;
780+
774781
ret = ptrace_sethbpregs(child, addr,
775782
(unsigned long __user *)data);
783+
ptrace_put_breakpoints(child);
776784
break;
777785
#endif
778786

0 commit comments

Comments
 (0)