LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Hulk Robot <hulkci@huawei.com>, Yang Yingliang <yangyingliang@huawei.com>, "David S. Miller" <davem@davemloft.net>, Sasha Levin <sashal@kernel.org> Subject: [PATCH 4.9 06/32] net/802/mrp: fix memleak in mrp_request_join() Date: Mon, 2 Aug 2021 15:44:26 +0200 [thread overview] Message-ID: <20210802134333.129599408@linuxfoundation.org> (raw) In-Reply-To: <20210802134332.931915241@linuxfoundation.org> From: Yang Yingliang <yangyingliang@huawei.com> [ Upstream commit 996af62167d0e0ec69b938a3561e96f84ffff1aa ] I got kmemleak report when doing fuzz test: BUG: memory leak unreferenced object 0xffff88810c239500 (size 64): comm "syz-executor940", pid 882, jiffies 4294712870 (age 14.631s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 01 00 00 00 01 02 00 04 ................ backtrace: [<00000000a323afa4>] slab_alloc_node mm/slub.c:2972 [inline] [<00000000a323afa4>] slab_alloc mm/slub.c:2980 [inline] [<00000000a323afa4>] __kmalloc+0x167/0x340 mm/slub.c:4130 [<000000005034ca11>] kmalloc include/linux/slab.h:595 [inline] [<000000005034ca11>] mrp_attr_create net/802/mrp.c:276 [inline] [<000000005034ca11>] mrp_request_join+0x265/0x550 net/802/mrp.c:530 [<00000000fcfd81f3>] vlan_mvrp_request_join+0x145/0x170 net/8021q/vlan_mvrp.c:40 [<000000009258546e>] vlan_dev_open+0x477/0x890 net/8021q/vlan_dev.c:292 [<0000000059acd82b>] __dev_open+0x281/0x410 net/core/dev.c:1609 [<000000004e6dc695>] __dev_change_flags+0x424/0x560 net/core/dev.c:8767 [<00000000471a09af>] rtnl_configure_link+0xd9/0x210 net/core/rtnetlink.c:3122 [<0000000037a4672b>] __rtnl_newlink+0xe08/0x13e0 net/core/rtnetlink.c:3448 [<000000008d5d0fda>] rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3488 [<000000004882fe39>] rtnetlink_rcv_msg+0x369/0xa10 net/core/rtnetlink.c:5552 [<00000000907e6c54>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504 [<00000000e7d7a8c4>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] [<00000000e7d7a8c4>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340 [<00000000e0645d50>] netlink_sendmsg+0x78e/0xc90 net/netlink/af_netlink.c:1929 [<00000000c24559b7>] sock_sendmsg_nosec net/socket.c:654 [inline] [<00000000c24559b7>] sock_sendmsg+0x139/0x170 net/socket.c:674 [<00000000fc210bc2>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350 [<00000000be4577b5>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404 Calling mrp_request_leave() after mrp_request_join(), the attr->state is set to MRP_APPLICANT_VO, mrp_attr_destroy() won't be called in last TX event in mrp_uninit_applicant(), the attr of applicant will be leaked. To fix this leak, iterate and free each attr of applicant before rerturning from mrp_uninit_applicant(). Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org> --- net/802/mrp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/802/mrp.c b/net/802/mrp.c index 72db2785ef2c..4ee3af3d400b 100644 --- a/net/802/mrp.c +++ b/net/802/mrp.c @@ -295,6 +295,19 @@ static void mrp_attr_destroy(struct mrp_applicant *app, struct mrp_attr *attr) kfree(attr); } +static void mrp_attr_destroy_all(struct mrp_applicant *app) +{ + struct rb_node *node, *next; + struct mrp_attr *attr; + + for (node = rb_first(&app->mad); + next = node ? rb_next(node) : NULL, node != NULL; + node = next) { + attr = rb_entry(node, struct mrp_attr, node); + mrp_attr_destroy(app, attr); + } +} + static int mrp_pdu_init(struct mrp_applicant *app) { struct sk_buff *skb; @@ -900,6 +913,7 @@ void mrp_uninit_applicant(struct net_device *dev, struct mrp_application *appl) spin_lock_bh(&app->lock); mrp_mad_event(app, MRP_EVENT_TX); + mrp_attr_destroy_all(app); mrp_pdu_queue(app); spin_unlock_bh(&app->lock); -- 2.30.2
next prev parent reply other threads:[~2021-08-02 13:48 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-02 13:44 [PATCH 4.9 00/32] 4.9.278-rc1 review Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 01/32] iommu/amd: Fix backport of 140456f994195b568ecd7fc2287a34eadffef3ca Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 02/32] tipc: Fix backport of b77413446408fdd256599daf00d5be72b5f3e7c6 Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 03/32] net: split out functions related to registering inflight socket files Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 04/32] af_unix: fix garbage collect vs MSG_PEEK Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 05/32] workqueue: fix UAF in pwq_unbound_release_workfn() Greg Kroah-Hartman 2021-08-02 13:44 ` Greg Kroah-Hartman [this message] 2021-08-02 13:44 ` [PATCH 4.9 07/32] net/802/garp: fix memleak in garp_request_join() Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 08/32] sctp: move 198 addresses from unusable to private scope Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 09/32] hfs: add missing clean-up in hfs_fill_super Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 10/32] hfs: fix high memory mapping in hfs_bnode_read Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 11/32] hfs: add lock nesting notation to hfs_find_init Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 12/32] ARM: dts: versatile: Fix up interrupt controller node names Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 13/32] lib/string.c: add multibyte memset functions Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 14/32] ARM: ensure the signal page contains defined contents Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 15/32] x86/kvm: fix vcpu-id indexed array sizes Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 16/32] ocfs2: fix zero out valid data Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 17/32] ocfs2: issue zeroout to EOF blocks Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 18/32] can: usb_8dev: fix memory leak Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 19/32] can: ems_usb: " Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 20/32] can: esd_usb2: " Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 21/32] NIU: fix incorrect error return, missed in previous revert Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 22/32] nfc: nfcsim: fix use after free during module unload Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 23/32] x86/asm: Ensure asm/proto.h can be included stand-alone Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 24/32] cfg80211: Fix possible memory leak in function cfg80211_bss_update Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 25/32] netfilter: conntrack: adjust stop timestamp to real expiry value Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 26/32] netfilter: nft_nat: allow to specify layer 4 protocol NAT only Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 27/32] tipc: fix sleeping in tipc accept routine Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 28/32] mlx4: Fix missing error code in mlx4_load_one() Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 29/32] net: llc: fix skb_over_panic Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 30/32] net/mlx5: Fix flow table chaining Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 31/32] tulip: windbond-840: Fix missing pci_disable_device() in probe and remove Greg Kroah-Hartman 2021-08-02 13:44 ` [PATCH 4.9 32/32] sis900: " Greg Kroah-Hartman 2021-08-03 13:45 ` [PATCH 4.9 00/32] 4.9.278-rc1 review Naresh Kamboju 2021-08-03 19:14 ` Guenter Roeck
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210802134333.129599408@linuxfoundation.org \ --to=gregkh@linuxfoundation.org \ --cc=davem@davemloft.net \ --cc=hulkci@huawei.com \ --cc=linux-kernel@vger.kernel.org \ --cc=sashal@kernel.org \ --cc=stable@vger.kernel.org \ --cc=yangyingliang@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).