* [PATCH net v2] openvswitch: fix memory leak at failed datapath creation
@ 2022-08-25 2:03 Andrey Zhadchenko
2022-08-27 2:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Zhadchenko @ 2022-08-25 2:03 UTC (permalink / raw)
To: netdev
Cc: dev, pshelar, davem, edumazet, kuba, pabeni, aconole, mark.d.gray,
i.maximets
ovs_dp_cmd_new()->ovs_dp_change()->ovs_dp_set_upcall_portids()
allocates array via kmalloc.
If for some reason new_vport() fails during ovs_dp_cmd_new()
dp->upcall_portids must be freed.
Add missing kfree.
Kmemleak example:
unreferenced object 0xffff88800c382500 (size 64):
comm "dump_state", pid 323, jiffies 4294955418 (age 104.347s)
hex dump (first 32 bytes):
5e c2 79 e4 1f 7a 38 c7 09 21 38 0c 80 88 ff ff ^.y..z8..!8.....
03 00 00 00 0a 00 00 00 14 00 00 00 28 00 00 00 ............(...
backtrace:
[<0000000071bebc9f>] ovs_dp_set_upcall_portids+0x38/0xa0
[<000000000187d8bd>] ovs_dp_change+0x63/0xe0
[<000000002397e446>] ovs_dp_cmd_new+0x1f0/0x380
[<00000000aa06f36e>] genl_family_rcv_msg_doit+0xea/0x150
[<000000008f583bc4>] genl_rcv_msg+0xdc/0x1e0
[<00000000fa10e377>] netlink_rcv_skb+0x50/0x100
[<000000004959cece>] genl_rcv+0x24/0x40
[<000000004699ac7f>] netlink_unicast+0x23e/0x360
[<00000000c153573e>] netlink_sendmsg+0x24e/0x4b0
[<000000006f4aa380>] sock_sendmsg+0x62/0x70
[<00000000d0068654>] ____sys_sendmsg+0x230/0x270
[<0000000012dacf7d>] ___sys_sendmsg+0x88/0xd0
[<0000000011776020>] __sys_sendmsg+0x59/0xa0
[<000000002e8f2dc1>] do_syscall_64+0x3b/0x90
[<000000003243e7cb>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
Fixes: b83d23a2a38b ("openvswitch: Introduce per-cpu upcall dispatch")
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
---
v2:
Remove the unnecessary if(rcu_dereference_raw(dp->upcall_portids))
net/openvswitch/datapath.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 7e8a39a35627..7179d254b08b 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1802,7 +1802,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
ovs_dp_reset_user_features(skb, info);
}
- goto err_unlock_and_destroy_meters;
+ goto err_destroy_portids;
}
err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
@@ -1817,6 +1817,8 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
ovs_notify(&dp_datapath_genl_family, reply, info);
return 0;
+err_destroy_portids:
+ kfree(rcu_dereference_raw(dp->upcall_portids));
err_unlock_and_destroy_meters:
ovs_unlock();
ovs_meters_exit(dp);
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net v2] openvswitch: fix memory leak at failed datapath creation
2022-08-25 2:03 [PATCH net v2] openvswitch: fix memory leak at failed datapath creation Andrey Zhadchenko
@ 2022-08-27 2:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-27 2:40 UTC (permalink / raw)
To: Andrey Zhadchenko
Cc: netdev, dev, pshelar, davem, edumazet, kuba, pabeni, aconole,
mark.d.gray, i.maximets
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 25 Aug 2022 05:03:26 +0300 you wrote:
> ovs_dp_cmd_new()->ovs_dp_change()->ovs_dp_set_upcall_portids()
> allocates array via kmalloc.
> If for some reason new_vport() fails during ovs_dp_cmd_new()
> dp->upcall_portids must be freed.
> Add missing kfree.
>
> Kmemleak example:
> unreferenced object 0xffff88800c382500 (size 64):
> comm "dump_state", pid 323, jiffies 4294955418 (age 104.347s)
> hex dump (first 32 bytes):
> 5e c2 79 e4 1f 7a 38 c7 09 21 38 0c 80 88 ff ff ^.y..z8..!8.....
> 03 00 00 00 0a 00 00 00 14 00 00 00 28 00 00 00 ............(...
> backtrace:
> [<0000000071bebc9f>] ovs_dp_set_upcall_portids+0x38/0xa0
> [<000000000187d8bd>] ovs_dp_change+0x63/0xe0
> [<000000002397e446>] ovs_dp_cmd_new+0x1f0/0x380
> [<00000000aa06f36e>] genl_family_rcv_msg_doit+0xea/0x150
> [<000000008f583bc4>] genl_rcv_msg+0xdc/0x1e0
> [<00000000fa10e377>] netlink_rcv_skb+0x50/0x100
> [<000000004959cece>] genl_rcv+0x24/0x40
> [<000000004699ac7f>] netlink_unicast+0x23e/0x360
> [<00000000c153573e>] netlink_sendmsg+0x24e/0x4b0
> [<000000006f4aa380>] sock_sendmsg+0x62/0x70
> [<00000000d0068654>] ____sys_sendmsg+0x230/0x270
> [<0000000012dacf7d>] ___sys_sendmsg+0x88/0xd0
> [<0000000011776020>] __sys_sendmsg+0x59/0xa0
> [<000000002e8f2dc1>] do_syscall_64+0x3b/0x90
> [<000000003243e7cb>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
>
> [...]
Here is the summary with links:
- [net,v2] openvswitch: fix memory leak at failed datapath creation
https://git.kernel.org/netdev/net/c/a87406f4adee
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-27 2:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-25 2:03 [PATCH net v2] openvswitch: fix memory leak at failed datapath creation Andrey Zhadchenko
2022-08-27 2:40 ` patchwork-bot+netdevbpf
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).