Skip to content

Commit e75a43c

Browse files
committed
Merge tag 'trace-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing fixes from Steven Rostedt: - Fix inverted check of registering the stats for branch tracing When calling register_stat_tracer() which returns zero on success and negative on error, the callers were checking the return of zero as an error and printing a warning message. Because this was just a normal printk() message and not a WARN(), it wasn't caught in any testing. Fix the check to print the warning message when an error actually happens. - Fix a typo in a comment in tracepoint.h - Limit the size of event probes to 3K in size It is possible to create a dynamic event probe via the tracefs system that is greater than the max size of an event that the ring buffer can hold. This basically causes the event to become useless. Limit the size of an event probe to be 3K as that should be large enough to handle any dynamic events being created, and fits within the PAGE_SIZE sub-buffers of the ring buffer. * tag 'trace-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing/probes: Limit size of event probe to 3K tracepoint: Fix typo in tracepoint.h comment tracing: branch: Fix inverted check on stat tracer registration
2 parents 57b8e2d + b2aa3b4 commit e75a43c

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

include/linux/tracepoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
202202
#define TP_CONDITION(args...) args
203203

204204
/*
205-
* Individual subsystem my have a separate configuration to
205+
* Individual subsystem may have a separate configuration to
206206
* enable their tracepoints. By default, this file will create
207207
* the tracepoints if CONFIG_TRACEPOINTS is defined. If a subsystem
208208
* wants to be able to disable its tracepoints from being created

kernel/trace/trace_branch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ __init static int init_annotated_branch_stats(void)
373373
int ret;
374374

375375
ret = register_stat_tracer(&annotated_branch_stats);
376-
if (!ret) {
376+
if (ret) {
377377
printk(KERN_WARNING "Warning: could not register "
378378
"annotated branches stats\n");
379-
return 1;
379+
return ret;
380380
}
381381
return 0;
382382
}
@@ -438,10 +438,10 @@ __init static int all_annotated_branch_stats(void)
438438
int ret;
439439

440440
ret = register_stat_tracer(&all_branch_stats);
441-
if (!ret) {
441+
if (ret) {
442442
printk(KERN_WARNING "Warning: could not register "
443443
"all branches stats\n");
444-
return 1;
444+
return ret;
445445
}
446446
return 0;
447447
}

kernel/trace/trace_probe.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,12 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
15231523
parg->offset = *size;
15241524
*size += parg->type->size * (parg->count ?: 1);
15251525

1526+
if (*size > MAX_PROBE_EVENT_SIZE) {
1527+
ret = -E2BIG;
1528+
trace_probe_log_err(ctx->offset, EVENT_TOO_BIG);
1529+
goto fail;
1530+
}
1531+
15261532
if (parg->count) {
15271533
len = strlen(parg->type->fmttype) + 6;
15281534
parg->fmt = kmalloc(len, GFP_KERNEL);

kernel/trace/trace_probe.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#define MAX_BTF_ARGS_LEN 128
3939
#define MAX_DENTRY_ARGS_LEN 256
4040
#define MAX_STRING_SIZE PATH_MAX
41+
#define MAX_PROBE_EVENT_SIZE 3072
4142

4243
/* Reserved field names */
4344
#define FIELD_STRING_IP "__probe_ip"
@@ -561,7 +562,8 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
561562
C(BAD_TYPE4STR, "This type does not fit for string."),\
562563
C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"),\
563564
C(TOO_MANY_ARGS, "Too many arguments are specified"), \
564-
C(TOO_MANY_EARGS, "Too many entry arguments specified"),
565+
C(TOO_MANY_EARGS, "Too many entry arguments specified"), \
566+
C(EVENT_TOO_BIG, "Event too big (too many fields?)"),
565567

566568
#undef C
567569
#define C(a, b) TP_ERR_##a

0 commit comments

Comments
 (0)