Vlad Buslov
718cb09aaa
vlan: Fix VLAN 0 memory leak
The referenced commit intended to fix memleak of VLAN 0 that is implicitly
created on devices with NETIF_F_HW_VLAN_CTAG_FILTER feature. However, it
doesn't take into account that the feature can be re-set during the
netdevice lifetime which will cause memory leak if feature is disabled
during the device deletion as illustrated by [0]. Fix the leak by
unconditionally deleting VLAN 0 on NETDEV_DOWN event.
[0]:
> modprobe 8021q
> ip l set dev eth2 up
> ethtool -K eth2 rx-vlan-filter off
> modprobe -r mlx5_ib
> modprobe -r mlx5_core
> cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff888103dcd900 (size 256):
comm "ip", pid 1490, jiffies 4294907305 (age 325.364s)
hex dump (first 32 bytes):
00 80 5d 03 81 88 ff ff 00 00 00 00 00 00 00 00 ..].............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000899f3bb9>] kmalloc_trace+0x25/0x80
[<000000002889a7a2>] vlan_vid_add+0xa0/0x210
[<000000007177800e>] vlan_device_event+0x374/0x760 [8021q]
[<000000009a0716b1>] notifier_call_chain+0x35/0xb0
[<00000000bbf3d162>] __dev_notify_flags+0x58/0xf0
[<0000000053d2b05d>] dev_change_flags+0x4d/0x60
[<00000000982807e9>] do_setlink+0x28d/0x10a0
[<0000000058c1be00>] __rtnl_newlink+0x545/0x980
[<00000000e66c3bd9>] rtnl_newlink+0x44/0x70
[<00000000a2cc5970>] rtnetlink_rcv_msg+0x29c/0x390
[<00000000d307d1e4>] netlink_rcv_skb+0x54/0x100
[<00000000259d16f9>] netlink_unicast+0x1f6/0x2c0
[<000000007ce2afa1>] netlink_sendmsg+0x232/0x4a0
[<00000000f3f4bb39>] sock_sendmsg+0x38/0x60
[<000000002f9c0624>] ____sys_sendmsg+0x1e3/0x200
[<00000000d6ff5520>] ___sys_sendmsg+0x80/0xc0
unreferenced object 0xffff88813354fde0 (size 32):
comm "ip", pid 1490, jiffies 4294907305 (age 325.364s)
hex dump (first 32 bytes):
a0 d9 dc 03 81 88 ff ff a0 d9 dc 03 81 88 ff ff ................
81 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000899f3bb9>] kmalloc_trace+0x25/0x80
[<000000002da64724>] vlan_vid_add+0xdf/0x210
[<000000007177800e>] vlan_device_event+0x374/0x760 [8021q]
[<000000009a0716b1>] notifier_call_chain+0x35/0xb0
[<00000000bbf3d162>] __dev_notify_flags+0x58/0xf0
[<0000000053d2b05d>] dev_change_flags+0x4d/0x60
[<00000000982807e9>] do_setlink+0x28d/0x10a0
[<0000000058c1be00>] __rtnl_newlink+0x545/0x980
[<00000000e66c3bd9>] rtnl_newlink+0x44/0x70
[<00000000a2cc5970>] rtnetlink_rcv_msg+0x29c/0x390
[<00000000d307d1e4>] netlink_rcv_skb+0x54/0x100
[<00000000259d16f9>] netlink_unicast+0x1f6/0x2c0
[<000000007ce2afa1>] netlink_sendmsg+0x232/0x4a0
[<00000000f3f4bb39>] sock_sendmsg+0x38/0x60
[<000000002f9c0624>] ____sys_sendmsg+0x1e3/0x200
[<00000000d6ff5520>] ___sys_sendmsg+0x80/0xc0
Fixes: efc73f4bbc ("net: Fix memory leak - vlan_info struct")
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
Link: https://lore.kernel.org/r/20230808093521.1468929-1-vladbu@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-08-09 13:44:27 -07:00
..
2023-03-29 08:22:52 +01:00
2023-07-20 19:14:50 +00:00
2023-08-09 13:44:27 -07:00
2023-06-24 15:50:13 -07:00
2023-06-24 15:50:13 -07:00
2023-06-24 15:50:13 -07:00
2023-05-26 23:14:49 +02:00
2023-07-20 11:27:22 -07:00
2023-05-16 22:09:24 -07:00
2023-05-31 13:06:57 +02:00
2023-07-20 10:46:28 +02:00
2023-06-24 15:50:13 -07:00
2023-07-29 18:13:41 +01:00
2023-07-26 15:08:09 +02:00
2023-08-08 15:56:48 -07:00
2023-08-01 21:07:46 -07:00
2023-08-04 18:27:58 -07:00
2023-06-17 00:31:14 -07:00
2023-07-27 17:19:46 -07:00
2023-06-15 08:21:11 +01:00
2023-06-15 22:19:41 -07:00
2023-06-21 16:47:05 -07:00
2023-06-24 15:50:13 -07:00
2023-08-04 18:24:52 -07:00
2023-08-02 10:35:21 +01:00
2023-03-16 17:34:40 -07:00
2023-06-24 15:50:13 -07:00
2023-06-24 15:50:13 -07:00
2023-07-29 18:13:41 +01:00
2023-07-20 10:46:28 +02:00
2023-07-03 11:26:05 -07:00
2023-06-24 15:41:46 -07:00
2023-06-24 15:50:13 -07:00
2023-06-10 00:11:41 -07:00
2023-08-04 18:26:27 -07:00
2023-06-09 10:32:51 +01:00
2023-07-29 18:13:41 +01:00
2023-06-20 20:06:56 -07:00
2023-06-27 09:45:22 -07:00
2023-06-24 15:50:13 -07:00
2023-06-27 09:45:22 -07:00
2023-06-10 00:11:41 -07:00
2023-06-12 09:46:30 +01:00
2023-08-04 18:03:16 -07:00
2023-06-24 15:50:13 -07:00
2023-06-28 16:43:10 -07:00
2023-06-24 15:50:13 -07:00
2023-04-06 20:36:27 +02:00
2023-06-24 15:50:13 -07:00
2023-06-28 16:43:10 -07:00
2023-07-31 20:10:37 -07:00
2023-06-29 11:49:42 +02:00
2023-08-09 11:20:29 +01:00
2023-07-01 14:38:25 -07:00
2023-07-27 11:45:05 +02:00
2023-08-06 08:32:18 +01:00
2023-07-29 18:13:41 +01:00
2023-06-24 15:50:13 -07:00
2023-07-26 10:08:07 +03:00
2023-06-24 15:50:13 -07:00
2023-07-29 18:13:41 +01:00
2023-07-29 18:13:41 +01:00
2023-04-14 11:09:27 +01:00
2023-05-26 08:51:26 +01:00
2023-04-19 18:48:48 -07:00
2023-06-28 16:43:10 -07:00