Netdev List
 help / color / mirror / Atom feed
* [PATCH net] tun: flush uc and mc addresses in TUNSETLINK
@ 2026-11-18 12:54 Eric Dumazet
  2026-11-18 12:58 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2026-11-18 12:54 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Willem de Bruijn, Simon Horman, netdev, edumazet, Henry Martin,
	Willem de Bruijn, Jason Wang, Andrew Lunn

TUNSETLINK changes dev->type and dev->addr_len, but leaves
dev->uc and dev->mc untouched.

Entries added with the old addr_len stay in lists and rb-trees
that are now searched and dumped with the new addr_len.

When addr_len grows (eg ARPHRD_NONE -> ARPHRD_IP6GRE), dumps like
/proc/net/dev_mcast and RTM_GETMULTICAST expose bytes of
netdev_hw_addr that were never initialized.

bonding and team already call dev_uc_flush() and dev_mc_flush()
between NETDEV_PRE_TYPE_CHANGE and the type change. Do the same
in tun, but only when addr_len changes: if it does not, existing
entries are still valid and there is no reason to drop them.

Fixes: cca8ea3b05c9 ("net: tun: set tun->dev->addr_len during TUNSETLINK processing")
Link: https://lore.kernel.org/netdev/20261116024056.1274402-1-bsdhenrymartin@gmail.com/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
Cc: Henry Martin <bsdhenrymartin@gmail.com>
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Jason Wang <jasowangio@gmail.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
---
 drivers/net/tun.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d4870bdc156f..a2f56a4febb5 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -3379,6 +3379,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
 			   (unsigned short)arg == ARPHRD_MCTP) {
 			ret = -EINVAL;
 		} else {
+			unsigned char addr_len = tun_get_addr_len(arg);
+
 			ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE,
 						       tun->dev);
 			ret = notifier_to_errno(ret);
@@ -3387,8 +3389,13 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
 					   "Refused to change device type\n");
 				break;
 			}
+			/* Addresses were added with the old dev->addr_len. */
+			if (addr_len != tun->dev->addr_len) {
+				dev_uc_flush(tun->dev);
+				dev_mc_flush(tun->dev);
+			}
 			tun->dev->type = (int) arg;
-			tun->dev->addr_len = tun_get_addr_len(tun->dev->type);
+			tun->dev->addr_len = addr_len;
 			netif_info(tun, drv, tun->dev, "linktype set to %d\n",
 				   tun->dev->type);
 			call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE,
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] tun: flush uc and mc addresses in TUNSETLINK
  2026-11-18 12:54 [PATCH net] tun: flush uc and mc addresses in TUNSETLINK Eric Dumazet
@ 2026-11-18 12:58 ` netdev-bot+sinfo
  0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-11-18 12:58 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
	Simon Horman, netdev, Henry Martin, Willem de Bruijn, Jason Wang,
	Andrew Lunn

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18 12:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 12:54 [PATCH net] tun: flush uc and mc addresses in TUNSETLINK Eric Dumazet
2026-11-18 12:58 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox