ftrace: Do not hold references of ftrace_graph_{notrace_}hash out of graph_lock
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 3 Feb 2017 01:16:29 +0000 (20:16 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 3 Feb 2017 15:59:42 +0000 (10:59 -0500)
commit649b988b12ddb9aed16047a3d9bb4d7bfdb47221
tree00dd85ce86d799d9deeb26987c77fb6542f0e38a
parent0e684b6578ee463ecb5c9a1cd0c20069f063d9f0
ftrace: Do not hold references of ftrace_graph_{notrace_}hash out of graph_lock

The hashs ftrace_graph_hash and ftrace_graph_notrace_hash are modified
within the graph_lock being held. Holding a pointer to them and passing them
along can lead to a use of a stale pointer (fgd->hash). Move assigning the
pointer and its use to within the holding of the lock. Note, it's an
rcu_sched protected data, and other instances of referencing them are done
with preemption disabled. But the file manipuation code must be protected by
the lock.

The fgd->hash pointer is set to NULL when the lock is being released.

Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/ftrace.c