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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Matt Helsley
Date: Monday, September 13, 2010 - 1:01 pm

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

(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@gmail.com> for doing the
bulk of the work finding this bug.

Cc: Robin Green <greenrd@greenrd.org>
Cc: linux-kernel@vger.kernel.org
Cc: containers@lists.linux-foundation.org
Cc: Prasad <prasad@linux.vnet.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Matt Helsley <matthltc@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);
 }
 EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
 
-- 
1.6.3.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/3] hw breakpoints: Fix pid namespace bug, Matt Helsley, (Mon Sep 13, 1:01 pm)
[PATCH 3/3] perf events: Cleanup pid passing, Matt Helsley, (Mon Sep 13, 1:01 pm)
Re: [PATCH 3/3] perf events: Cleanup pid passing, Peter Zijlstra, (Wed Sep 15, 1:18 am)
[tip:perf/core] hw breakpoints: Fix pid namespace bug, tip-bot for Matt Helsley, (Wed Sep 15, 3:03 am)
[tip:perf/core] perf events: Split out task search into helper, tip-bot for Matt Helsley, (Wed Sep 15, 3:03 am)
[tip:perf/core] perf events: Clean up pid passing, tip-bot for Matt Helsley, (Wed Sep 15, 3:03 am)
Re: [tip:perf/core] hw breakpoints: Fix pid namespace bug, Frederic Weisbecker, (Wed Sep 15, 4:41 am)
[tip:perf/urgent] hw breakpoints: Fix pid namespace bug, tip-bot for Matt Helsley, (Fri Sep 17, 1:28 am)
Re: [tip:perf/core] perf events: Clean up pid passing, Peter Zijlstra, (Wed Sep 22, 5:22 am)