Skip to contentSkip to conversation

net: l2tp_eth: Replace deprecated strcpy with strscpy in l2tp_eth_create

PATCH Applied Thorsten Blum 3 participants 3 messages Feb 23 – Feb 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: l2tp_eth: Replace deprecated strcpy with strscpy in l2tp_eth_create

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 'cfg->ifname'.

---
 net/l2tp/l2tp_eth.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/l2tp/l2tp_eth.c +3 -2
index cf0b66f4fb29..a4956ef9574c 100644
@@ -14,6 +14,7 @@
 #include <linux/in.h>
 #include <linux/etherdevice.h>
 #include <linux/spinlock.h>
+#include <linux/string.h>
 #include <net/sock.h>
 #include <net/ip.h>
 #include <net/icmp.h>
@@ -235,10 +236,10 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
 	int rc;
 
 	if (cfg->ifname) {
-		strscpy(name, cfg->ifname, IFNAMSIZ);
+		strscpy(name, cfg->ifname);
 		name_assign_type = NET_NAME_USER;
 	} else {
-		strcpy(name, L2TP_ETH_DEV_NAME);
+		strscpy(name, L2TP_ETH_DEV_NAME);
 		name_assign_type = NET_NAME_ENUM;
 	}
 
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Thorsten Blum

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 'cfg->ifname'.

#2 lore raw
In reply to Thorsten Blum
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Mon, 23 Feb 2026 08:41:34 +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 safer strscpy(). Use the two-argument version of strscpy() to copy 'cfg->ifname'.

[...]

Here is the summary with links:
- [net-next] net: l2tp_eth: Replace deprecated strcpy with strscpy in l2tp_eth_create

    https://git.kernel.org/netdev/net-next/c/e5a80f5e67ce

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html