Thread (2 messages) 2 messages, 2 authors, 2025-05-14
STALE407d

[PATCH] tracing: Replace deprecated strncpy() with strscpy() for string keys in hist triggers

From: Devaansh Kumar <hidden>
Date: 2025-05-14 20:20:08
Also in: linux-kernel-mentees, lkml
Subsystem: the rest, tracing · Maintainers: Linus Torvalds, Steven Rostedt, Masami Hiramatsu

strncpy() is deprecated for NUL-terminated destination buffers and must
be replaced by strscpy().

See issue: https://github.com/KSPP/linux/issues/90

Signed-off-by: Devaansh Kumar <redacted>
---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 1260c23cfa5f..90a4e486fba8 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -5225,7 +5225,7 @@ static inline void add_to_key(char *compound_key, void *key,
 		if (size > key_field->size - 1)
 			size = key_field->size - 1;
 
-		strncpy(compound_key + key_field->offset, (char *)key, size);
+		strscpy(compound_key + key_field->offset, (char *)key, size);
 	} else
 		memcpy(compound_key + key_field->offset, key, size);
 }
-- 
2.49.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help