[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1399549669-25465-1-git-send-email-mathieu.desnoyers@efficios.com>
Date: Thu, 8 May 2014 07:47:49 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Sasha Levin <sasha.levin@...cle.com>,
Oleg Nesterov <oleg@...hat.com>, Dave Jones <davej@...hat.com>
Subject: [PATCH] Fix: tracepoint: use after rcu free
commit de7b2973903c6cc50b31ee5682a69b2219b9919d
Author: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Date: Tue Apr 8 17:26:21 2014 -0400
tracepoint: Use struct pointer instead of name hash for reg/unreg tracepoints
introduces a use after free by calling release_probes on the old struct
tracepoint array before the newly allocated array is published with
rcu_assign_pointer. There is a race window where tracepoints (RCU
readers) can perform a "use-after-grace-period-after-free", which shows
up as a GPF in stress-tests.
Link: https://lkml.org/lkml/2014/5/6/738
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
CC: Steven Rostedt <rostedt@...dmis.org>
CC: Sasha Levin <sasha.levin@...cle.com>
CC: Oleg Nesterov <oleg@...hat.com>
CC: Dave Jones <davej@...hat.com>
---
kernel/tracepoint.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index ac5b23c..6620e58 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -188,7 +188,6 @@ static int tracepoint_add_func(struct tracepoint *tp,
WARN_ON_ONCE(1);
return PTR_ERR(old);
}
- release_probes(old);
/*
* rcu_assign_pointer has a smp_wmb() which makes sure that the new
@@ -200,6 +199,7 @@ static int tracepoint_add_func(struct tracepoint *tp,
rcu_assign_pointer(tp->funcs, tp_funcs);
if (!static_key_enabled(&tp->key))
static_key_slow_inc(&tp->key);
+ release_probes(old);
return 0;
}
@@ -221,7 +221,6 @@ static int tracepoint_remove_func(struct tracepoint *tp,
WARN_ON_ONCE(1);
return PTR_ERR(old);
}
- release_probes(old);
if (!tp_funcs) {
/* Removed last function */
@@ -232,6 +231,7 @@ static int tracepoint_remove_func(struct tracepoint *tp,
static_key_slow_dec(&tp->key);
}
rcu_assign_pointer(tp->funcs, tp_funcs);
+ release_probes(old);
return 0;
}
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists