Skip to content

Commit 95381de

Browse files
committed
Merge tag 'trace-v5.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Small fixes and minor cleanups for tracing: - Make exported ftrace function not static - Fix NULL pointer dereference in reading probes as they are created - Fix NULL pointer dereference in k/uprobe clean up path - Various documentation fixes" * tag 'trace-v5.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Correct kdoc formats ftrace/x86: Remove mcount() declaration tracing/probe: Fix null pointer dereference tracing: Make exported ftrace_set_clr_event non-static ftrace: Check for successful allocation of hash ftrace: Check for empty hash and comment the race with registering probes ftrace: Fix NULL pointer dereference in t_probe_next()
2 parents 7fb8670 + c68c9ec commit 95381de

File tree

6 files changed

+35
-15
lines changed

6 files changed

+35
-15
lines changed

arch/x86/include/asm/ftrace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
1717

1818
#ifndef __ASSEMBLY__
19-
extern void mcount(void);
2019
extern atomic_t modifying_ftrace_code;
2120
extern void __fentry__(void);
2221

include/linux/trace_events.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ extern int trace_event_get_offsets(struct trace_event_call *call);
548548

549549
#define is_signed_type(type) (((type)(-1)) < (type)1)
550550

551+
int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
551552
int trace_set_clr_event(const char *system, const char *event, int set);
552553

553554
/*

kernel/trace/ftrace.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,6 +3095,14 @@ t_probe_next(struct seq_file *m, loff_t *pos)
30953095
hnd = &iter->probe_entry->hlist;
30963096

30973097
hash = iter->probe->ops.func_hash->filter_hash;
3098+
3099+
/*
3100+
* A probe being registered may temporarily have an empty hash
3101+
* and it's at the end of the func_probes list.
3102+
*/
3103+
if (!hash || hash == EMPTY_HASH)
3104+
return NULL;
3105+
30983106
size = 1 << hash->size_bits;
30993107

31003108
retry:
@@ -4320,12 +4328,21 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
43204328

43214329
mutex_unlock(&ftrace_lock);
43224330

4331+
/*
4332+
* Note, there's a small window here that the func_hash->filter_hash
4333+
* may be NULL or empty. Need to be carefule when reading the loop.
4334+
*/
43234335
mutex_lock(&probe->ops.func_hash->regex_lock);
43244336

43254337
orig_hash = &probe->ops.func_hash->filter_hash;
43264338
old_hash = *orig_hash;
43274339
hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, old_hash);
43284340

4341+
if (!hash) {
4342+
ret = -ENOMEM;
4343+
goto out;
4344+
}
4345+
43294346
ret = ftrace_match_records(hash, glob, strlen(glob));
43304347

43314348
/* Nothing found? */

kernel/trace/trace.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,9 +1567,9 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu,
15671567

15681568
/**
15691569
* update_max_tr_single - only copy one trace over, and reset the rest
1570-
* @tr - tracer
1571-
* @tsk - task with the latency
1572-
* @cpu - the cpu of the buffer to copy.
1570+
* @tr: tracer
1571+
* @tsk: task with the latency
1572+
* @cpu: the cpu of the buffer to copy.
15731573
*
15741574
* Flip the trace of a single CPU buffer between the @tr and the max_tr.
15751575
*/
@@ -1767,7 +1767,7 @@ static void __init apply_trace_boot_options(void);
17671767

17681768
/**
17691769
* register_tracer - register a tracer with the ftrace system.
1770-
* @type - the plugin for the tracer
1770+
* @type: the plugin for the tracer
17711771
*
17721772
* Register a new plugin tracer.
17731773
*/
@@ -2230,9 +2230,9 @@ static bool tracing_record_taskinfo_skip(int flags)
22302230
/**
22312231
* tracing_record_taskinfo - record the task info of a task
22322232
*
2233-
* @task - task to record
2234-
* @flags - TRACE_RECORD_CMDLINE for recording comm
2235-
* - TRACE_RECORD_TGID for recording tgid
2233+
* @task: task to record
2234+
* @flags: TRACE_RECORD_CMDLINE for recording comm
2235+
* TRACE_RECORD_TGID for recording tgid
22362236
*/
22372237
void tracing_record_taskinfo(struct task_struct *task, int flags)
22382238
{
@@ -2258,10 +2258,10 @@ void tracing_record_taskinfo(struct task_struct *task, int flags)
22582258
/**
22592259
* tracing_record_taskinfo_sched_switch - record task info for sched_switch
22602260
*
2261-
* @prev - previous task during sched_switch
2262-
* @next - next task during sched_switch
2263-
* @flags - TRACE_RECORD_CMDLINE for recording comm
2264-
* TRACE_RECORD_TGID for recording tgid
2261+
* @prev: previous task during sched_switch
2262+
* @next: next task during sched_switch
2263+
* @flags: TRACE_RECORD_CMDLINE for recording comm
2264+
* TRACE_RECORD_TGID for recording tgid
22652265
*/
22662266
void tracing_record_taskinfo_sched_switch(struct task_struct *prev,
22672267
struct task_struct *next, int flags)
@@ -3072,7 +3072,9 @@ static void trace_printk_start_stop_comm(int enabled)
30723072

30733073
/**
30743074
* trace_vbprintk - write binary msg to tracing buffer
3075-
*
3075+
* @ip: The address of the caller
3076+
* @fmt: The string format to write to the buffer
3077+
* @args: Arguments for @fmt
30763078
*/
30773079
int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
30783080
{

kernel/trace/trace_events.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ static int __ftrace_set_clr_event(struct trace_array *tr, const char *match,
787787
return ret;
788788
}
789789

790-
static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
790+
int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
791791
{
792792
char *event = NULL, *sub = NULL, *match;
793793
int ret;

kernel/trace/trace_probe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,8 @@ void trace_probe_cleanup(struct trace_probe *tp)
895895
for (i = 0; i < tp->nr_args; i++)
896896
traceprobe_free_probe_arg(&tp->args[i]);
897897

898-
kfree(call->class->system);
898+
if (call->class)
899+
kfree(call->class->system);
899900
kfree(call->name);
900901
kfree(call->print_fmt);
901902
}

0 commit comments

Comments
 (0)