Skip to content

Commit 278924c

Browse files
committed
Merge tag 'trace-v5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull workqueue tracing fix from Steven Rostedt: "Fix workqueue trace event unsafe string reference After adding a verifier to test all strings printed in trace events to make sure they either point to a string on the ring buffer, or to read only core kernel memory, it triggered on a workqueue trace event. The trace event workqueue_queue_work references the allocated name of the workqueue in the output. If the workqueue is freed before the trace is read, then the trace will dereference freed memory. Update the trace event to use the __string(), __assign_str(), and __get_str() helpers to handle such cases" * tag 'trace-v5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: workqueue/tracing: Copy workqueue name to buffer in trace event
2 parents ec85720 + 83b6268 commit 278924c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

include/trace/events/workqueue.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ TRACE_EVENT(workqueue_queue_work,
3030
TP_STRUCT__entry(
3131
__field( void *, work )
3232
__field( void *, function)
33-
__field( const char *, workqueue)
33+
__string( workqueue, pwq->wq->name)
3434
__field( unsigned int, req_cpu )
3535
__field( unsigned int, cpu )
3636
),
3737

3838
TP_fast_assign(
3939
__entry->work = work;
4040
__entry->function = work->func;
41-
__entry->workqueue = pwq->wq->name;
41+
__assign_str(workqueue, pwq->wq->name);
4242
__entry->req_cpu = req_cpu;
4343
__entry->cpu = pwq->pool->cpu;
4444
),
4545

4646
TP_printk("work struct=%p function=%ps workqueue=%s req_cpu=%u cpu=%u",
47-
__entry->work, __entry->function, __entry->workqueue,
47+
__entry->work, __entry->function, __get_str(workqueue),
4848
__entry->req_cpu, __entry->cpu)
4949
);
5050

0 commit comments

Comments
 (0)