public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] tracing: Replace deprecated strncpy() with strscpy() for string keys in hist triggers
@ 2025-05-14 20:19 Devaansh Kumar
  2025-05-14 20:28 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Devaansh Kumar @ 2025-05-14 20:19 UTC (permalink / raw)
  To: rostedt, mhiramat, mathieu.desnoyers
  Cc: Devaansh Kumar, linux-trace-kernel, linux-kernel, skhan,
	linux-kernel-mentees

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 <devaanshk840@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tracing: Replace deprecated strncpy() with strscpy() for string keys in hist triggers
  2025-05-14 20:19 [PATCH] tracing: Replace deprecated strncpy() with strscpy() for string keys in hist triggers Devaansh Kumar
@ 2025-05-14 20:28 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2025-05-14 20:28 UTC (permalink / raw)
  To: Devaansh Kumar
  Cc: mhiramat, mathieu.desnoyers, linux-trace-kernel, linux-kernel,
	skhan, linux-kernel-mentees

On Thu, 15 May 2025 01:49:55 +0530
Devaansh Kumar <devaanshk840@gmail.com> wrote:

> 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 <devaanshk840@gmail.com>
> ---
>  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);
>  }

Incorrect, and this is already fixed in next (at least it's in my ftrace/for-next branch).

  https://lore.kernel.org/20250403210637.1c477d4a@gandalf.local.home

-- Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-14 20:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-14 20:19 [PATCH] tracing: Replace deprecated strncpy() with strscpy() for string keys in hist triggers Devaansh Kumar
2025-05-14 20:28 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox