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.

tun: replace strcpy with strscpy for ifr_name

Replace the strcpy() calls that copy the device name into ifr->ifr_name
with strscpy() to avoid potential overflows and guarantee NULL termination.

Destination is ifr->ifr_name (size IFNAMSIZ).

Tested in QEMU (BusyBox rootfs):
- Created TUN devices via TUNSETIFF helper
- Set addresses and brought links up
- Verified long interface names are safely truncated (IFNAMSIZ-1)

Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250812082244.60240-1-miguelgarciaroman8@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Miguel García and committed by
Jakub Kicinski
a5738411 5e88777a

+2 -2
+2 -2
drivers/net/tun.c
··· 2823 2823 if (netif_running(tun->dev)) 2824 2824 netif_tx_wake_all_queues(tun->dev); 2825 2825 2826 - strcpy(ifr->ifr_name, tun->dev->name); 2826 + strscpy(ifr->ifr_name, tun->dev->name); 2827 2827 return 0; 2828 2828 } 2829 2829 2830 2830 static void tun_get_iff(struct tun_struct *tun, struct ifreq *ifr) 2831 2831 { 2832 - strcpy(ifr->ifr_name, tun->dev->name); 2832 + strscpy(ifr->ifr_name, tun->dev->name); 2833 2833 2834 2834 ifr->ifr_flags = tun_flags(tun); 2835 2835