Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipv6: ip6_gre: replace strcpy with strscpy for tunnel name

Replace the strcpy() call that copies the device name into
tunnel->parms.name with strscpy(), to avoid potential overflow
and guarantee NULL termination. This uses the two-argument
form of strscpy(), where the destination size is inferred
from the array type.

Destination is tunnel->parms.name (size IFNAMSIZ).

Tested in QEMU (Alpine rootfs):
- Created IPv6 GRE tunnels over loopback
- Assigned overlay IPv6 addresses
- Verified bidirectional ping through the tunnel
- Changed tunnel parameters at runtime (`ip -6 tunnel change`)

Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>
Link: https://patch.msgid.link/20250818220203.899338-1-miguelgarciaroman8@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Miguel García and committed by
Jakub Kicinski
09bde6fd 9efd5152

+5 -5
+5 -5
net/ipv6/ip6_gre.c
··· 329 329 if (parms->name[0]) { 330 330 if (!dev_valid_name(parms->name)) 331 331 return NULL; 332 - strscpy(name, parms->name, IFNAMSIZ); 332 + strscpy(name, parms->name); 333 333 } else { 334 - strcpy(name, "ip6gre%d"); 334 + strscpy(name, "ip6gre%d"); 335 335 } 336 336 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, 337 337 ip6gre_tunnel_setup); ··· 1469 1469 tunnel = netdev_priv(dev); 1470 1470 1471 1471 tunnel->dev = dev; 1472 - strcpy(tunnel->parms.name, dev->name); 1472 + strscpy(tunnel->parms.name, dev->name); 1473 1473 1474 1474 ret = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL); 1475 1475 if (ret) ··· 1529 1529 1530 1530 tunnel->dev = dev; 1531 1531 tunnel->net = dev_net(dev); 1532 - strcpy(tunnel->parms.name, dev->name); 1532 + strscpy(tunnel->parms.name, dev->name); 1533 1533 1534 1534 tunnel->hlen = sizeof(struct ipv6hdr) + 4; 1535 1535 } ··· 1842 1842 tunnel = netdev_priv(dev); 1843 1843 1844 1844 tunnel->dev = dev; 1845 - strcpy(tunnel->parms.name, dev->name); 1845 + strscpy(tunnel->parms.name, dev->name); 1846 1846 1847 1847 ret = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL); 1848 1848 if (ret)