lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250501153956.GC3339421@horms.kernel.org>
Date: Thu, 1 May 2025 16:39:56 +0100
From: Simon Horman <horms@...nel.org>
To: Ruben Wauters <rubenru09@....com>
Cc: "David S. Miller" <davem@...emloft.net>,
	David Ahern <dsahern@...nel.org>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] ipv4: ip_tunnel: Replace strcpy use with strscpy

On Thu, May 01, 2025 at 02:23:00AM +0100, Ruben Wauters wrote:
> Use of strcpy is decpreated, replaces the use of strcpy with strscpy as
> recommended.
> 
> I am aware there is an explicit bounds check above, however using
> strscpy protects against buffer overflows in any future code, and there
> is no good reason I can see to not use it.

Thanks, I agree. This patch doesn't buy us safety. But it doesn't lose
us anything. And allows the code to move towards best practice.

One thing I notices is that this change is is inconsistent with the call to
the 3-argument variant of strscpy a few lines above - it should also be hte
2-argument version. Maybe that could be changed too. Maybe in a
separate patch.

It is customary when making such changes to add a note that
strscpy() was chosen because the code expects a NUL-terminated string
without zero-padding. (Which is the case due to the call to strcat().)
Perhaps you could add some text to the commit message of v2 of this patch?

> Signed-off-by: Ruben Wauters <rubenru09@....com>

Reviewed-by: Simon Horman <horms@...nel.org>

> ---
>  net/ipv4/ip_tunnel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
> index 3913ec89ad20..9724bbbd0e0a 100644
> --- a/net/ipv4/ip_tunnel.c
> +++ b/net/ipv4/ip_tunnel.c
> @@ -247,7 +247,7 @@ static struct net_device *__ip_tunnel_create(struct net *net,
>  	} else {
>  		if (strlen(ops->kind) > (IFNAMSIZ - 3))
>  			goto failed;
> -		strcpy(name, ops->kind);
> +		strscpy(name, ops->kind);
>  		strcat(name, "%d");
>  	}
>  
> -- 
> 2.48.1
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ