Skip to content

Commit aa02c63

Browse files
rostedtpopcornmix
authored andcommitted
tracing: Do not add event files for modules that fail tracepoints
commit 45ab281 upstream. If a module fails to add its tracepoints due to module tainting, do not create the module event infrastructure in the debugfs directory. As the events will not work and worse yet, they will silently fail, making the user wonder why the events they enable do not display anything. Having a warning on module load and the events not visible to the users will make the cause of the problem much clearer. Link: http://lkml.kernel.org/r/20140227154923.265882695@goodmis.org Fixes: 6d72373 "tracing/events: add support for modules to TRACE_EVENT" Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 35d3bc4 commit aa02c63

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎include/linux/tracepoint.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ struct tp_module {
6060
unsigned int num_tracepoints;
6161
struct tracepoint * const *tracepoints_ptrs;
6262
};
63+
bool trace_module_has_bad_taint(struct module *mod);
64+
#else
65+
static inline bool trace_module_has_bad_taint(struct module *mod)
66+
{
67+
return false;
68+
}
6369
#endif /* CONFIG_MODULES */
6470

6571
struct tracepoint_iter {

‎kernel/trace/trace_events.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,16 @@ static void trace_module_add_events(struct module *mod)
18601860
struct ftrace_module_file_ops *file_ops = NULL;
18611861
struct ftrace_event_call **call, **start, **end;
18621862

1863+
if (!mod->num_trace_events)
1864+
return;
1865+
1866+
/* Don't add infrastructure for mods without tracepoints */
1867+
if (trace_module_has_bad_taint(mod)) {
1868+
pr_err("%s: module has bad taint, not creating trace events\n",
1869+
mod->name);
1870+
return;
1871+
}
1872+
18631873
start = mod->trace_events;
18641874
end = mod->trace_events + mod->num_trace_events;
18651875

‎kernel/tracepoint.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ void tracepoint_iter_reset(struct tracepoint_iter *iter)
631631
EXPORT_SYMBOL_GPL(tracepoint_iter_reset);
632632

633633
#ifdef CONFIG_MODULES
634+
bool trace_module_has_bad_taint(struct module *mod)
635+
{
636+
return mod->taints & ~((1 << TAINT_OOT_MODULE) | (1 << TAINT_CRAP));
637+
}
638+
634639
static int tracepoint_module_coming(struct module *mod)
635640
{
636641
struct tp_module *tp_mod, *iter;
@@ -641,7 +646,7 @@ static int tracepoint_module_coming(struct module *mod)
641646
* module headers (for forced load), to make sure we don't cause a crash.
642647
* Staging and out-of-tree GPL modules are fine.
643648
*/
644-
if (mod->taints & ~((1 << TAINT_OOT_MODULE) | (1 << TAINT_CRAP)))
649+
if (trace_module_has_bad_taint(mod))
645650
return 0;
646651
mutex_lock(&tracepoints_mutex);
647652
tp_mod = kmalloc(sizeof(struct tp_module), GFP_KERNEL);

0 commit comments

Comments
 (0)