public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net-next] ipv4: ip_tunnel: Replace strcpy use with strscpy
       [not found] <20250501202935.46318-1-rubenru09.ref@aol.com>
@ 2025-05-01 20:23 ` Ruben Wauters
  2025-05-06  1:40   ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Ruben Wauters @ 2025-05-01 20:23 UTC (permalink / raw)
  To: David S. Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman
  Cc: Ruben Wauters, netdev, linux-kernel

Use of strcpy is decpreated, replaces the use of strcpy with strscpy as
recommended.

strscpy was chosen as it requires a NUL terminated non-padded string,
which is the case here.

I am aware there is an explicit bounds check above the second instance,
however using strscpy protects against buffer overflows in any future
code, and there is no good reason I can see to not use it.

I have also replaced the scrscpy above that had 3 params with the
version using 2 params. These are functionally equivalent, but it is
cleaner to have both using 2 params.

Signed-off-by: Ruben Wauters <rubenru09@aol.com>
Reviewed-by: Simon Horman <horms@kernel.org>
---
Changes since v1:
Replace existing 3 parameter strscpy with 2 parameter scrscpy
Edit commit message adding justification for scrscpy and for added
changes
---
 net/ipv4/ip_tunnel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 3913ec89ad20..678b8f96e3e9 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -243,11 +243,11 @@ static struct net_device *__ip_tunnel_create(struct net *net,
 	if (parms->name[0]) {
 		if (!dev_valid_name(parms->name))
 			goto failed;
-		strscpy(name, parms->name, IFNAMSIZ);
+		strscpy(name, parms->name);
 	} else {
 		if (strlen(ops->kind) > (IFNAMSIZ - 3))
 			goto failed;
-		strcpy(name, ops->kind);
+		strscpy(name, ops->kind);
 		strcat(name, "%d");
 	}
 
-- 
2.48.1


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

* Re: [PATCH v2 net-next] ipv4: ip_tunnel: Replace strcpy use with strscpy
  2025-05-01 20:23 ` [PATCH v2 net-next] ipv4: ip_tunnel: Replace strcpy use with strscpy Ruben Wauters
@ 2025-05-06  1:40   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-06  1:40 UTC (permalink / raw)
  To: Ruben Wauters
  Cc: davem, dsahern, edumazet, kuba, pabeni, horms, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  1 May 2025 21:23:55 +0100 you wrote:
> Use of strcpy is decpreated, replaces the use of strcpy with strscpy as
> recommended.
> 
> strscpy was chosen as it requires a NUL terminated non-padded string,
> which is the case here.
> 
> I am aware there is an explicit bounds check above the second instance,
> however using strscpy protects against buffer overflows in any future
> code, and there is no good reason I can see to not use it.
> 
> [...]

Here is the summary with links:
  - [v2,net-next] ipv4: ip_tunnel: Replace strcpy use with strscpy
    https://git.kernel.org/netdev/net-next/c/c2dbda07662e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-05-06  1:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250501202935.46318-1-rubenru09.ref@aol.com>
2025-05-01 20:23 ` [PATCH v2 net-next] ipv4: ip_tunnel: Replace strcpy use with strscpy Ruben Wauters
2025-05-06  1:40   ` patchwork-bot+netdevbpf

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