[PATCH 1/3] hw breakpoints: Fix pid namespace bug

Matt Helsley matthltc at us.ibm.com
Mon Sep 13 13:01:18 PDT 2010

Hardware breakpoints can't be registered within pid namespaces
because tsk->pid is passed rather than the pid in the current

(See https://bugzilla.kernel.org/show_bug.cgi?id=17281 )

This is a quick fix demonstrating the problem but is not the
best method of solving the problem since passing pids internally
is not the best way to avoid pid namespace bugs. Subsequent patches
will show a better solution.

Much thanks to Frederic Weisbecker <fweisbec at gmail.com> for doing the
bulk of the work finding this bug.

Cc: Robin Green <greenrd at greenrd.org>
Cc: linux-kernel at vger.kernel.org
Cc: containers at lists.linux-foundation.org
Cc: Prasad <prasad at linux.vnet.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra at chello.nl>
Cc: Arnaldo Carvalho de Melo <acme at redhat.com>
Cc: Steven Rostedt <rostedt at goodmis.org>
Cc: Ingo Molnar <mingo at elte.hu>
Cc: Will Deacon <will.deacon at arm.com>
Cc: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>
Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
 kernel/hw_breakpoint.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
index 3b2aaff..6122f02 100644
--- a/kernel/hw_breakpoint.c
+++ b/kernel/hw_breakpoint.c
@@ -433,7 +433,8 @@ register_user_hw_breakpoint(struct perf_event_attr *attr,
 			    perf_overflow_handler_t triggered,
 			    struct task_struct *tsk)
-	return perf_event_create_kernel_counter(attr, -1, tsk->pid, triggered);
+	return perf_event_create_kernel_counter(attr, -1, task_pid_vnr(tsk),
+						triggered);

More information about the Containers mailing list