Skip to content

Commit b8e382a

Browse files
committed
Merge tag 'trace-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: - Fix memory leak on error path of process_system_preds() - Lock inversion fix with updating tgid recording option - Fix histogram compare function on big endian machines - Fix histogram trigger function on big endian machines - Make trace_printk() irq sync on init for kprobe selftest correctness * tag 'trace-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix endianness bug in histogram trigger samples/trace_printk: Wait for IRQ work to finish tracing: Fix lock inversion in trace_event_enable_tgid_record() tracing: Have the histogram compare functions convert to u64 first tracing: Avoid memory leak in process_system_preds()
2 parents 4746104 + fe6e096 commit b8e382a

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

kernel/trace/trace.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4685,6 +4685,10 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
46854685

46864686
int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
46874687
{
4688+
if ((mask == TRACE_ITER_RECORD_TGID) ||
4689+
(mask == TRACE_ITER_RECORD_CMD))
4690+
lockdep_assert_held(&event_mutex);
4691+
46884692
/* do nothing if flag is already set */
46894693
if (!!(tr->trace_flags & mask) == !!enabled)
46904694
return 0;
@@ -4752,6 +4756,7 @@ static int trace_set_options(struct trace_array *tr, char *option)
47524756

47534757
cmp += len;
47544758

4759+
mutex_lock(&event_mutex);
47554760
mutex_lock(&trace_types_lock);
47564761

47574762
ret = match_string(trace_options, -1, cmp);
@@ -4762,6 +4767,7 @@ static int trace_set_options(struct trace_array *tr, char *option)
47624767
ret = set_tracer_flag(tr, 1 << ret, !neg);
47634768

47644769
mutex_unlock(&trace_types_lock);
4770+
mutex_unlock(&event_mutex);
47654771

47664772
/*
47674773
* If the first trailing whitespace is replaced with '\0' by strstrip,
@@ -8076,9 +8082,11 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
80768082
if (val != 0 && val != 1)
80778083
return -EINVAL;
80788084

8085+
mutex_lock(&event_mutex);
80798086
mutex_lock(&trace_types_lock);
80808087
ret = set_tracer_flag(tr, 1 << index, val);
80818088
mutex_unlock(&trace_types_lock);
8089+
mutex_unlock(&event_mutex);
80828090

80838091
if (ret < 0)
80848092
return ret;

kernel/trace/trace_events.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ void trace_event_enable_cmd_record(bool enable)
320320
struct trace_event_file *file;
321321
struct trace_array *tr;
322322

323-
mutex_lock(&event_mutex);
323+
lockdep_assert_held(&event_mutex);
324+
324325
do_for_each_event_file(tr, file) {
325326

326327
if (!(file->flags & EVENT_FILE_FL_ENABLED))
@@ -334,15 +335,15 @@ void trace_event_enable_cmd_record(bool enable)
334335
clear_bit(EVENT_FILE_FL_RECORDED_CMD_BIT, &file->flags);
335336
}
336337
} while_for_each_event_file();
337-
mutex_unlock(&event_mutex);
338338
}
339339

340340
void trace_event_enable_tgid_record(bool enable)
341341
{
342342
struct trace_event_file *file;
343343
struct trace_array *tr;
344344

345-
mutex_lock(&event_mutex);
345+
lockdep_assert_held(&event_mutex);
346+
346347
do_for_each_event_file(tr, file) {
347348
if (!(file->flags & EVENT_FILE_FL_ENABLED))
348349
continue;
@@ -356,7 +357,6 @@ void trace_event_enable_tgid_record(bool enable)
356357
&file->flags);
357358
}
358359
} while_for_each_event_file();
359-
mutex_unlock(&event_mutex);
360360
}
361361

362362
static int __ftrace_event_enable_disable(struct trace_event_file *file,

kernel/trace/trace_events_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir,
16621662
parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0);
16631663
return -EINVAL;
16641664
fail_mem:
1665-
kfree(filter);
1665+
__free_filter(filter);
16661666
/* If any call succeeded, we still need to sync */
16671667
if (!fail)
16681668
tracepoint_synchronize_unregister();

kernel/trace/trace_events_hist.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data,
911911
strscpy(str_field, str_val, STR_VAR_LEN_MAX);
912912
n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
913913
} else {
914-
entry->fields[n_u64] = var_ref_vals[var_ref_idx + i];
914+
struct synth_field *field = event->fields[i];
915+
u64 val = var_ref_vals[var_ref_idx + i];
916+
917+
switch (field->size) {
918+
case 1:
919+
*(u8 *)&entry->fields[n_u64] = (u8)val;
920+
break;
921+
922+
case 2:
923+
*(u16 *)&entry->fields[n_u64] = (u16)val;
924+
break;
925+
926+
case 4:
927+
*(u32 *)&entry->fields[n_u64] = (u32)val;
928+
break;
929+
930+
default:
931+
entry->fields[n_u64] = val;
932+
break;
933+
}
915934
n_u64++;
916935
}
917936
}

kernel/trace/tracing_map.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ static int tracing_map_cmp_atomic64(void *val_a, void *val_b)
148148
#define DEFINE_TRACING_MAP_CMP_FN(type) \
149149
static int tracing_map_cmp_##type(void *val_a, void *val_b) \
150150
{ \
151-
type a = *(type *)val_a; \
152-
type b = *(type *)val_b; \
151+
type a = (type)(*(u64 *)val_a); \
152+
type b = (type)(*(u64 *)val_b); \
153153
\
154154
return (a > b) ? 1 : ((a < b) ? -1 : 0); \
155155
}

samples/trace_printk/trace-printk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static int __init trace_printk_init(void)
3636

3737
/* Kick off printing in irq context */
3838
irq_work_queue(&irqwork);
39+
irq_work_sync(&irqwork);
3940

4041
trace_printk("This is a %s that will use trace_bprintk()\n",
4142
"static string");

0 commit comments

Comments
 (0)