linux/net/bridge
Yang Yingliang 519133debc net: bridge: fix memleak in br_add_if()
I got a memleak report:

BUG: memory leak
unreferenced object 0x607ee521a658 (size 240):
comm "syz-executor.0", pid 955, jiffies 4294780569 (age 16.449s)
hex dump (first 32 bytes, cpu 1):
00 00 00 00 00 00 00 00 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:
[<00000000d830ea5a>] br_multicast_add_port+0x1c2/0x300 net/bridge/br_multicast.c:1693
[<00000000274d9a71>] new_nbp net/bridge/br_if.c:435 [inline]
[<00000000274d9a71>] br_add_if+0x670/0x1740 net/bridge/br_if.c:611
[<0000000012ce888e>] do_set_master net/core/rtnetlink.c:2513 [inline]
[<0000000012ce888e>] do_set_master+0x1aa/0x210 net/core/rtnetlink.c:2487
[<0000000099d1cafc>] __rtnl_newlink+0x1095/0x13e0 net/core/rtnetlink.c:3457
[<00000000a01facc0>] rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3488
[<00000000acc9186c>] rtnetlink_rcv_msg+0x369/0xa10 net/core/rtnetlink.c:5550
[<00000000d4aabb9c>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504
[<00000000bc2e12a3>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
[<00000000bc2e12a3>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340
[<00000000e4dc2d0e>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929
[<000000000d22c8b3>] sock_sendmsg_nosec net/socket.c:654 [inline]
[<000000000d22c8b3>] sock_sendmsg+0x139/0x170 net/socket.c:674
[<00000000e281417a>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350
[<00000000237aa2ab>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404
[<000000004f2dc381>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433
[<0000000005feca6c>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47
[<000000007304477d>] entry_SYSCALL_64_after_hwframe+0x44/0xae

On error path of br_add_if(), p->mcast_stats allocated in
new_nbp() need be freed, or it will be leaked.

Fixes: 1080ab95e3 ("net: bridge: add support for IGMP/MLD stats and export them via netlink")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Link: https://lore.kernel.org/r/20210809132023.978546-1-yangyingliang@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-08-10 13:25:14 -07:00
..
netfilter netfilter: nf_conntrack_bridge: Fix memory leak when error 2021-08-04 10:41:29 +02:00
br.c net: bridge: fix flags interpretation for extern learn fdb entries 2021-08-10 11:29:39 -07:00
br_arp_nd_proxy.c net: bridge: when suppression is enabled exclude RARP packets 2021-03-22 13:30:24 -07:00
br_cfm.c bridge: cfm: remove redundant return 2021-06-22 10:35:15 -07:00
br_cfm_netlink.c
br_device.c netfilter: flowtable: bridge vlan hardware offload and switchdev 2021-03-24 12:48:39 -07:00
br_fdb.c net: bridge: fix flags interpretation for extern learn fdb entries 2021-08-10 11:29:39 -07:00
br_forward.c net: bridge: mcast: add wrappers for router node retrieval 2021-05-13 14:04:31 -07:00
br_if.c net: bridge: fix memleak in br_add_if() 2021-08-10 13:25:14 -07:00
br_input.c net: bridge: mcast: prepare is-router function for mcast router split 2021-05-13 14:04:31 -07:00
br_ioctl.c
br_mdb.c net: bridge: allow the switchdev replay functions to be called for deletion 2021-06-28 14:09:03 -07:00
br_mrp.c net: bridge: mrp: Update the Test frames for MRA 2021-06-28 15:46:10 -07:00
br_mrp_netlink.c
br_mrp_switchdev.c bridge: mrp: Extend br_mrp_switchdev to detect better the errors 2021-02-16 14:47:46 -08:00
br_multicast.c net: bridge: multicast: fix MRD advertisement router port marking race 2021-07-11 12:11:06 -07:00
br_multicast_eht.c net: bridge: mcast: factor out common allow/block EHT handling 2021-03-16 11:57:57 -07:00
br_netfilter_hooks.c
br_netfilter_ipv6.c
br_netlink.c net: bridge: remove redundant assignment 2021-05-25 15:20:27 -07:00
br_netlink_tunnel.c
br_nf_core.c
br_private.h net: bridge: fix flags interpretation for extern learn fdb entries 2021-08-10 11:29:39 -07:00
br_private_cfm.h
br_private_mcast_eht.h
br_private_mrp.h net: bridge: mrp: Update the Test frames for MRA 2021-06-28 15:46:10 -07:00
br_private_stp.h
br_private_tunnel.h
br_stp.c net: bridge: constify variables in the replay helpers 2021-06-28 14:09:03 -07:00
br_stp_bpdu.c
br_stp_if.c
br_stp_timer.c
br_switchdev.c net: bridge: switchdev: send FDB notifications for host addresses 2021-06-29 10:46:23 -07:00
br_sysfs_br.c net: bridge: propagate error code and extack from br_mc_disabled_update 2021-04-14 14:32:05 -07:00
br_sysfs_if.c net: bridge: don't print in br_switchdev_set_port_flag 2021-02-12 17:08:04 -08:00
br_vlan.c net: bridge: allow the switchdev replay functions to be called for deletion 2021-06-28 14:09:03 -07:00
br_vlan_options.c
br_vlan_tunnel.c net: bridge: fix vlan tunnel dst refcnt when egressing 2021-06-10 14:06:43 -07:00
Kconfig
Makefile