team: Fix reference count leak when changing port netns
Status from this message: This series was applied to netdev/net.git (main)
Get series with b4
b4 am [email protected]Versions newest first
Changes in v3 from the cover letter
- Add a selftest.
v2: https://lore.kernel.org/netdev/[email protected]/
- Add Fixes tag.
- Add MODULE_IMPORT_NS().
v1: https://lore.kernel.org/all/[email protected]/
Patches in v3 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | team: avoid NETDEV_CHANGEMTU event when unregistering slavedrivers/ | +21 | 0 replies | Applied |
| 2/2 | selftests: team: Add a reference count leak testtools/ tools/ | +18 | 1 reply | Applied |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Jiri Pirko | Stanislav Fomichev |
|---|---|---|
| Series | A-b | |
| 1/2 | R-b | |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net v3 0/2] team: Fix reference count leak when changing port netns
Patch #1 fixes a reference count leak that was reported by syzkaller. The leak happens when a net device that is member in a team is changing netns. The fix is to align the team driver with the bond driver and have it suppress NETDEV_CHANGEMTU events for a net device that is being unregistered.
Without this change, the NETDEV_CHANGEMTU event causes inetdev_event() to recreate an inet device for this net device in its original netns, after it was previously destroyed upon NETDEV_UNREGISTER. Later on, when inetdev_event() receives a NETDEV_REGISTER event for this net device in the new nents, it simply leaks the reference:
case NETDEV_REGISTER:
pr_debug("%s: bug\n", __func__);
RCU_INIT_POINTER(dev->ip_ptr, NULL);
break;addrconf_notify() handles this differently and reuses the existing inet6 device if one exists when a NETDEV_REGISTER event is received. This creates a different problem where it is possible for a net device to reference an inet6 device that was created in a previous netns.
A more generic fix that we can try in net-next is to revert the changes in the bond and team drivers and instead have IPv4 and IPv6 destroy and recreate an inet device if one already exists upon NETDEV_REGISTER.
Patch #2 adds a selftest that passes with the fix and hangs without it.
v3:
- Add a selftest.
v2: https://lore.kernel.org/netdev/[email protected]/
- Add Fixes tag.
- Add MODULE_IMPORT_NS().
v1: https://lore.kernel.org/all/[email protected]/
Ido Schimmel (1):
selftests: team: Add a reference count leak test
Tetsuo Handa (1):
team: avoid NETDEV_CHANGEMTU event when unregistering slave
drivers/net/team/team_core.c | 26 +++++++++++++++---- .../selftests/drivers/net/team/Makefile | 1 + .../selftests/drivers/net/team/refleak.sh | 17 ++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/team/refleak.sh
Signature · 1 line
2.53.0