Skip to content

Commit aed0af0

Browse files
committed
Merge tag 'trace-v7.0-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing fixes from Steven Rostedt: - Fix possible NULL pointer dereference in trace_data_alloc() On the trace_data_alloc() error path, it can call trigger_data_free() with a NULL pointer. This used to be a kfree() but was changed to trigger_data_free() to clean up any partial initialization. The issue is that trigger_data_free() does not expect a NULL pointer. Have trigger_data_free() return safely on NULL pointer. - Fix multiple events on the command line and bootconfig If multiple events are enabled on the command line separately and not grouped, only the last event gets enabled. That is: trace_event=sched_switch trace_event=sched_waking will only enable sched_waking whereas: trace_event=sched_switch,sched_waking will enable both. The bootconfig makes it even worse as the second way is the more common method. The issue is that a temporary buffer is used to store the events to enable later in boot. Each time the cmdline callback is called, it overwrites what was previously there. Have the callback append the next value (delimited by a comma) if the temporary buffer already has content. - Fix command line trace_buffer_size if >= 2G The logic to allocate the trace buffer uses "int" for the size parameter in the command line code causing overflow issues if more that 2G is specified. * tag 'trace-v7.0-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: Fix trace_buf_size= cmdline parameter with sizes >= 2G tracing: Fix enabling multiple events on the kernel command line and bootconfig tracing: Add NULL pointer check to trigger_data_free()
2 parents 7b6e48d + d008ba8 commit aed0af0

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

kernel/trace/trace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9350,7 +9350,7 @@ static void setup_trace_scratch(struct trace_array *tr,
93509350
}
93519351

93529352
static int
9353-
allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, int size)
9353+
allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, unsigned long size)
93549354
{
93559355
enum ring_buffer_flags rb_flags;
93569356
struct trace_scratch *tscratch;
@@ -9405,7 +9405,7 @@ static void free_trace_buffer(struct array_buffer *buf)
94059405
}
94069406
}
94079407

9408-
static int allocate_trace_buffers(struct trace_array *tr, int size)
9408+
static int allocate_trace_buffers(struct trace_array *tr, unsigned long size)
94099409
{
94109410
int ret;
94119411

@@ -10769,7 +10769,7 @@ __init static void enable_instances(void)
1076910769

1077010770
__init static int tracer_alloc_buffers(void)
1077110771
{
10772-
int ring_buf_size;
10772+
unsigned long ring_buf_size;
1077310773
int ret = -ENOMEM;
1077410774

1077510775

kernel/trace/trace_events.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4493,7 +4493,11 @@ static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;
44934493

44944494
static __init int setup_trace_event(char *str)
44954495
{
4496-
strscpy(bootup_event_buf, str, COMMAND_LINE_SIZE);
4496+
if (bootup_event_buf[0] != '\0')
4497+
strlcat(bootup_event_buf, ",", COMMAND_LINE_SIZE);
4498+
4499+
strlcat(bootup_event_buf, str, COMMAND_LINE_SIZE);
4500+
44974501
trace_set_ring_buffer_expanded(NULL);
44984502
disable_tracing_selftest("running event tracing");
44994503

kernel/trace/trace_events_trigger.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ static int trigger_kthread_fn(void *ignore)
5050

5151
void trigger_data_free(struct event_trigger_data *data)
5252
{
53+
if (!data)
54+
return;
55+
5356
if (data->cmd_ops->set_filter)
5457
data->cmd_ops->set_filter(NULL, data, NULL);
5558

0 commit comments

Comments
 (0)