ANDROID: ftrace: fix function type mismatches
This change fixes indirect call mismatches with function and function graph tracing, which trip Control-Flow Integrity (CFI) checking. Bug: 79510107 Bug: 67506682 Change-Id: I5de08c113fb970ffefedce93c58e0161f22c7ca2 Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
This commit is contained in:
parent
33395cc5bf
commit
1875563351
2 changed files with 19 additions and 6 deletions
|
@ -224,8 +224,16 @@ extern enum ftrace_tracing_type_t ftrace_tracing_type;
|
||||||
int register_ftrace_function(struct ftrace_ops *ops);
|
int register_ftrace_function(struct ftrace_ops *ops);
|
||||||
int unregister_ftrace_function(struct ftrace_ops *ops);
|
int unregister_ftrace_function(struct ftrace_ops *ops);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CFI_CLANG
|
||||||
|
/* Use a C stub with the correct type for CFI */
|
||||||
|
static inline void ftrace_stub(unsigned long a0, unsigned long a1,
|
||||||
|
struct ftrace_ops *op, struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#else
|
||||||
extern void ftrace_stub(unsigned long a0, unsigned long a1,
|
extern void ftrace_stub(unsigned long a0, unsigned long a1,
|
||||||
struct ftrace_ops *op, struct pt_regs *regs);
|
struct ftrace_ops *op, struct pt_regs *regs);
|
||||||
|
#endif
|
||||||
|
|
||||||
#else /* !CONFIG_FUNCTION_TRACER */
|
#else /* !CONFIG_FUNCTION_TRACER */
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -123,8 +123,9 @@ static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
|
||||||
struct ftrace_ops *op, struct pt_regs *regs);
|
struct ftrace_ops *op, struct pt_regs *regs);
|
||||||
#else
|
#else
|
||||||
/* See comment below, where ftrace_ops_list_func is defined */
|
/* See comment below, where ftrace_ops_list_func is defined */
|
||||||
static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip);
|
static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip,
|
||||||
#define ftrace_ops_list_func ((ftrace_func_t)ftrace_ops_no_ops)
|
struct ftrace_ops *op, struct pt_regs *regs);
|
||||||
|
#define ftrace_ops_list_func ftrace_ops_no_ops
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -6310,7 +6311,8 @@ static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
|
||||||
__ftrace_ops_list_func(ip, parent_ip, NULL, regs);
|
__ftrace_ops_list_func(ip, parent_ip, NULL, regs);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip)
|
static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip,
|
||||||
|
struct ftrace_ops *op, struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
__ftrace_ops_list_func(ip, parent_ip, NULL, NULL);
|
__ftrace_ops_list_func(ip, parent_ip, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@ -6771,14 +6773,17 @@ void ftrace_graph_graph_time_control(bool enable)
|
||||||
fgraph_graph_time = enable;
|
fgraph_graph_time = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ftrace_graph_return_stub(struct ftrace_graph_ret *trace)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
|
int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The callbacks that hook a function */
|
/* The callbacks that hook a function */
|
||||||
trace_func_graph_ret_t ftrace_graph_return =
|
trace_func_graph_ret_t ftrace_graph_return = ftrace_graph_return_stub;
|
||||||
(trace_func_graph_ret_t)ftrace_stub;
|
|
||||||
trace_func_graph_ent_t ftrace_graph_entry = ftrace_graph_entry_stub;
|
trace_func_graph_ent_t ftrace_graph_entry = ftrace_graph_entry_stub;
|
||||||
static trace_func_graph_ent_t __ftrace_graph_entry = ftrace_graph_entry_stub;
|
static trace_func_graph_ent_t __ftrace_graph_entry = ftrace_graph_entry_stub;
|
||||||
|
|
||||||
|
@ -7007,7 +7012,7 @@ void unregister_ftrace_graph(void)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ftrace_graph_active--;
|
ftrace_graph_active--;
|
||||||
ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub;
|
ftrace_graph_return = ftrace_graph_return_stub;
|
||||||
ftrace_graph_entry = ftrace_graph_entry_stub;
|
ftrace_graph_entry = ftrace_graph_entry_stub;
|
||||||
__ftrace_graph_entry = ftrace_graph_entry_stub;
|
__ftrace_graph_entry = ftrace_graph_entry_stub;
|
||||||
ftrace_shutdown(&graph_ops, FTRACE_STOP_FUNC_RET);
|
ftrace_shutdown(&graph_ops, FTRACE_STOP_FUNC_RET);
|
||||||
|
|
Loading…
Reference in a new issue