[PATCH] include: trace: Use string helpers in msg_dump trace events

Cristian Marussi posted 1 patch 1 month, 3 weeks ago
include/trace/events/scmi.h | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH] include: trace: Use string helpers in msg_dump trace events
Posted by Cristian Marussi 1 month, 3 weeks ago
Use proper available ftrace macros to handle tag strings of variable size,
to avoid wasting space using statically oversized arrays while risking to
expose stale stack data when such array is not properly padded when filled.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
 include/trace/events/scmi.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/include/trace/events/scmi.h b/include/trace/events/scmi.h
index 703b7bb68e44..b421c253df00 100644
--- a/include/trace/events/scmi.h
+++ b/include/trace/events/scmi.h
@@ -7,8 +7,6 @@
 
 #include <linux/tracepoint.h>
 
-#define TRACE_SCMI_MAX_TAG_LEN	6
-
 TRACE_EVENT(scmi_fc_call,
 	TP_PROTO(u8 protocol_id, u8 msg_id, u32 res_id, u32 val1, u32 val2),
 	TP_ARGS(protocol_id, msg_id, res_id, val1, val2),
@@ -156,7 +154,7 @@ TRACE_EVENT(scmi_msg_dump,
 		__field(u8, channel_id)
 		__field(u8, protocol_id)
 		__field(u8, msg_id)
-		__array(char, tag, TRACE_SCMI_MAX_TAG_LEN)
+		__string(tag, tag)
 		__field(u16, seq)
 		__field(int, status)
 		__field(size_t, len)
@@ -168,7 +166,7 @@ TRACE_EVENT(scmi_msg_dump,
 		__entry->channel_id = channel_id;
 		__entry->protocol_id = protocol_id;
 		__entry->msg_id = msg_id;
-		strscpy(__entry->tag, tag, TRACE_SCMI_MAX_TAG_LEN);
+		__assign_str(tag);
 		__entry->seq = seq;
 		__entry->status = status;
 		__entry->len = len;
@@ -177,7 +175,7 @@ TRACE_EVENT(scmi_msg_dump,
 
 	TP_printk("id=%d ch=%02X pt=%02X t=%s msg_id=%02X seq=%04X s=%d pyld=%s",
 		  __entry->id, __entry->channel_id, __entry->protocol_id,
-		  __entry->tag, __entry->msg_id, __entry->seq, __entry->status,
+		  __get_str(tag), __entry->msg_id, __entry->seq, __entry->status,
 		__print_hex_str(__get_dynamic_array(cmd), __entry->len))
 );
 #endif /* _TRACE_SCMI_H */
-- 
2.54.0
Re: [PATCH] include: trace: Use string helpers in msg_dump trace events
Posted by Sudeep Holla 1 week, 6 days ago
On Sat, 08 Aug 2026 20:12:34 +0100, Cristian Marussi wrote:
> Use proper available ftrace macros to handle tag strings of variable size,
> to avoid wasting space using statically oversized arrays while risking to
> expose stale stack data when such array is not properly padded when filled.

Applied to sudeep.holla/linux (for-next/scmi/updates), thanks!

[1/1] include: trace: Use string helpers in msg_dump trace events
      https://git.kernel.org/sudeep.holla/c/7d5b79cd7d59
-- 
Regards,
Sudeep