* [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name
@ 2025-08-12 8:22 Miguel García
2025-08-13 13:06 ` Willem de Bruijn
2025-08-14 0:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 6+ messages in thread
From: Miguel García @ 2025-08-12 8:22 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, willemdebruijn.kernel, jasowang, andrew+netdev,
davem, edumazet, kuba, pabeni, skhan, Miguel García
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>
---
v2:
- Dropped third argument from strscpy(), inferred from field size.
v1: https://lore.kernel.org/netdev/20250811112207.97371-1-miguelgarciaroman8@gmail.com/
drivers/net/tun.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index f8c5e2fd04df..ad33b16224e2 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2800,13 +2800,13 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
if (netif_running(tun->dev))
netif_tx_wake_all_queues(tun->dev);
- strcpy(ifr->ifr_name, tun->dev->name);
+ strscpy(ifr->ifr_name, tun->dev->name);
return 0;
}
static void tun_get_iff(struct tun_struct *tun, struct ifreq *ifr)
{
- strcpy(ifr->ifr_name, tun->dev->name);
+ strscpy(ifr->ifr_name, tun->dev->name);
ifr->ifr_flags = tun_flags(tun);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name
2025-08-12 8:22 [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name Miguel García
@ 2025-08-13 13:06 ` Willem de Bruijn
2025-08-13 13:58 ` Miguel García Román
2025-08-14 0:30 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 6+ messages in thread
From: Willem de Bruijn @ 2025-08-13 13:06 UTC (permalink / raw)
To: Miguel García, netdev
Cc: linux-kernel, willemdebruijn.kernel, jasowang, andrew+netdev,
davem, edumazet, kuba, pabeni, skhan, Miguel García
Miguel García wrote:
> 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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name
2025-08-13 13:06 ` Willem de Bruijn
@ 2025-08-13 13:58 ` Miguel García Román
2025-08-13 14:08 ` Willem de Bruijn
0 siblings, 1 reply; 6+ messages in thread
From: Miguel García Román @ 2025-08-13 13:58 UTC (permalink / raw)
To: Willem de Bruijn
Cc: netdev, linux-kernel, jasowang, andrew+netdev, davem, edumazet,
kuba, pabeni, skhan
Thanks Willem. Should I resend with your Reviewed-by tag or will it be
picked up when applied?
El mié, 13 ago 2025 a las 15:06, Willem de Bruijn
(<willemdebruijn.kernel@gmail.com>) escribió:
>
> Miguel García wrote:
> > 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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name
2025-08-13 13:58 ` Miguel García Román
@ 2025-08-13 14:08 ` Willem de Bruijn
0 siblings, 0 replies; 6+ messages in thread
From: Willem de Bruijn @ 2025-08-13 14:08 UTC (permalink / raw)
To: Miguel García Román, Willem de Bruijn
Cc: netdev, linux-kernel, jasowang, andrew+netdev, davem, edumazet,
kuba, pabeni, skhan
Miguel García Román wrote:
> Thanks Willem. Should I resend with your Reviewed-by tag or will it be
> picked up when applied?
No need. Also see other patches under review, and especially read
https://www.kernel.org/doc/html/next/process/submitting-patches.html
Note the comment on top posting.
> El mié, 13 ago 2025 a las 15:06, Willem de Bruijn
> (<willemdebruijn.kernel@gmail.com>) escribió:
> >
> > Miguel García wrote:
> > > 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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name
2025-08-12 8:22 [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name Miguel García
2025-08-13 13:06 ` Willem de Bruijn
@ 2025-08-14 0:30 ` patchwork-bot+netdevbpf
2025-08-14 10:32 ` Miguel García Román
1 sibling, 1 reply; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-14 0:30 UTC (permalink / raw)
To: =?utf-8?q?Miguel_Garc=C3=ADa_Rom=C3=A1n_=3Cmiguelgarciaroman8=40gmail=2Ecom?=,
=?utf-8?q?=3E?=
Cc: netdev, linux-kernel, willemdebruijn.kernel, jasowang,
andrew+netdev, davem, edumazet, kuba, pabeni, skhan
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 12 Aug 2025 10:22:44 +0200 you wrote:
> 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)
>
> [...]
Here is the summary with links:
- [net-next,v2] tun: replace strcpy with strscpy for ifr_name
https://git.kernel.org/netdev/net-next/c/a57384110dc6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name
2025-08-14 0:30 ` patchwork-bot+netdevbpf
@ 2025-08-14 10:32 ` Miguel García Román
0 siblings, 0 replies; 6+ messages in thread
From: Miguel García Román @ 2025-08-14 10:32 UTC (permalink / raw)
To: patchwork-bot+netdevbpf
Cc: netdev, linux-kernel, willemdebruijn.kernel, jasowang,
andrew+netdev, davem, edumazet, kuba, pabeni, skhan
El jue, 14 ago 2025 a las 2:29, <patchwork-bot+netdevbpf@kernel.org> escribió:
>
> Hello:
>
> This patch was applied to netdev/net-next.git (main)
> by Jakub Kicinski <kuba@kernel.org>:
Perfect, thanks!
>
> On Tue, 12 Aug 2025 10:22:44 +0200 you wrote:
> > 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)
> >
> > [...]
>
> Here is the summary with links:
> - [net-next,v2] tun: replace strcpy with strscpy for ifr_name
> https://git.kernel.org/netdev/net-next/c/a57384110dc6
>
> You are awesome, thank you!
> --
> Deet-doot-dot, I am a bot.
> https://korg.docs.kernel.org/patchwork/pwbot.html
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-08-14 10:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 8:22 [PATCH net-next v2] tun: replace strcpy with strscpy for ifr_name Miguel García
2025-08-13 13:06 ` Willem de Bruijn
2025-08-13 13:58 ` Miguel García Román
2025-08-13 14:08 ` Willem de Bruijn
2025-08-14 0:30 ` patchwork-bot+netdevbpf
2025-08-14 10:32 ` Miguel García Román
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).