ipv6: sit: Replace deprecated strcpy with strscpy
Subsystems (2)
PATCH 1/1 ipv6: sit: Replace deprecated strcpy with strscpy
strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Replace it with the safer strscpy(). Use the two-argument version of strscpy() to copy 'parms->name' in ipip6_tunnel_locate().
--- net/ipv6/sit.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/ipv6/sit.c +6 -5
@@ -21,6 +21,7 @@#include <linux/types.h> #include <linux/socket.h> #include <linux/sockios.h> +#include <linux/string.h> #include <linux/net.h> #include <linux/in6.h> #include <linux/netdevice.h>
@@ -256,9 +257,9 @@ static struct ip_tunnel *ipip6_tunnel_locate(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 { -strcpy (name,"sit%d" ); +strscpy (name,"sit%d" ); } dev =alloc_netdev (sizeof (*t), name,NET_NAME_UNKNOWN , ipip6_tunnel_setup);
@@ -275,7 +276,7 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net, goto failed_free;if (!parms->name[0 ]) -strcpy (parms->name, dev->name); +strscpy (parms->name, dev->name);return nt;
@@ -1442,7 +1443,7 @@ static int ipip6_tunnel_init(struct net_device *dev)int err; tunnel->dev = dev; -strcpy (tunnel->parms.name, dev->name); +strscpy (tunnel->parms.name, dev->name);ipip6_tunnel_bind_dev (dev);
@@ -1863,7 +1864,7 @@ static int __net_init sit_init_net(struct net *net)ipip6_tunnel_clone_6rd (sitn->fb_tunnel_dev, sitn);ipip6_fb_tunnel_init (sitn->fb_tunnel_dev); -strcpy (t->parms.name, sitn->fb_tunnel_dev->name); +strscpy (t->parms.name, sitn->fb_tunnel_dev->name);return 0 ; err_reg_dev:
Signature · 2 lines
Thorsten Blum <[email protected]> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 27 Feb 2026 01:45:42 +0100 you wrote:
strcpy()has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Replace it with the saferstrscpy(). Use the two-argument version ofstrscpy()to copy 'parms->name' inipip6_tunnel_locate().Signed-off-by Thorsten Blum <[email protected]>[...]
Here is the summary with links:
- [net-next] ipv6: sit: Replace deprecated strcpy with strscpy
https://git.kernel.org/netdev/net-next/c/ded4a02e7d04
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html