linux/net/hsr
Eric Dumazet dcf15eaf56 net: hsr: fix memory leak on slave unregistration by removing synced VLANs
When an HSR master device is brought UP, it auto-adds VLAN 0 via
vlan_vid0_add(), which propagates VID 0 to its slave devices (slave A and B).

If a slave device is later unregistered while HSR is active (e.g., during
netns cleanup or interface destruction), hsr_del_port() is called to
detach the slave port from the HSR master. However, hsr_del_port() currently
does not delete the VLAN IDs that were synced to the slave device by HSR.

As a result, the slave device retains a refcount on VID 0 (and any other
synced VLANs). When the slave device is destroyed, its vlan_info /
vlan_vid_info structure remains allocated, leading to a memory leak.

Fix this by calling vlan_vids_del_by_dev(port->dev, master->dev) in
hsr_del_port() before unlinking slave A or slave B ports, matching the
propagation logic in hsr_ndo_vlan_rx_add_vid() / hsr_ndo_vlan_rx_kill_vid()
and the cleanup behavior in bonding and team drivers.

Fixes: 1a8a63a530 ("net: hsr: Add VLAN CTAG filter support")
Reported-by: syzbot+456957213f32970c0762@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6a4cb6ca.57639fcc.86d58.000b.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Reviewed-by: Felix Maurer <fmaurer@redhat.com>
Link: https://patch.msgid.link/20260721101240.995597-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-22 10:24:44 -07:00
..
hsr_debugfs.c saner replacement for debugfs_rename() 2025-01-15 13:14:37 +01:00
hsr_device.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-04-02 11:03:13 -07:00
hsr_device.h net: hsr: Provide RedBox support (HSR-SAN) 2024-04-26 12:04:43 +02:00
hsr_forward.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-05-28 14:02:21 -07:00
hsr_forward.h
hsr_framereg.c net: hsr: simplify fill_last_seq_nrs() 2026-06-12 16:20:28 -07:00
hsr_framereg.h hsr: Implement more robust duplicate discard for HSR 2026-02-10 12:02:29 +01:00
hsr_main.c net/hsr: update outdated comments 2026-02-27 17:24:58 -08:00
hsr_main.h net: hsr: constify hsr_ops and prp_ops protocol operation structures 2026-03-29 14:37:50 -07:00
hsr_netlink.c hsr: broadcast netlink notifications in the device's net namespace 2026-06-05 18:23:12 -07:00
hsr_netlink.h net/hsr: Remove unused function declarations 2023-07-31 20:11:47 -07:00
hsr_slave.c net: hsr: fix memory leak on slave unregistration by removing synced VLANs 2026-07-22 10:24:44 -07:00
hsr_slave.h
Kconfig net: hsr: Add KUnit test for PRP 2025-03-13 10:04:22 +01:00
Makefile net: hsr: Add KUnit test for PRP 2025-03-13 10:04:22 +01:00
prp_dup_discard_test.c hsr: Implement more robust duplicate discard for HSR 2026-02-10 12:02:29 +01:00