public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: openvswitch: release vport resources on failure
@ 2022-12-20 21:27 Aaron Conole
  2022-12-21  9:48 ` Eelco Chaudron
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Aaron Conole @ 2022-12-20 21:27 UTC (permalink / raw)
  To: netdev
  Cc: Pravin B Shelar, Jakub Kicinski, David S. Miller, Paolo Abeni,
	Eric Dumazet, Thomas Graf, dev, Eelco Chaudron, Ilya Maximets,
	wangchuanlei, linux-kernel

A recent commit introducing upcall packet accounting failed to properly
release the vport object when the per-cpu stats struct couldn't be
allocated.  This can cause dangling pointers to dp objects long after
they've been released.

Cc: Eelco Chaudron <echaudro@redhat.com>
Cc: wangchuanlei <wangchuanlei@inspur.com>
Fixes: 1933ea365aa7 ("net: openvswitch: Add support to count upcall packets")
Reported-by: syzbot+8f4e2dcfcb3209ac35f9@syzkaller.appspotmail.com
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 net/openvswitch/datapath.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 932bcf766d63..6774baf9e212 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1854,7 +1854,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
 	vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
 	if (!vport->upcall_stats) {
 		err = -ENOMEM;
-		goto err_destroy_portids;
+		goto err_destroy_vport;
 	}
 
 	err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
@@ -1869,6 +1869,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_vport:
+	ovs_dp_detach_port(vport);
 err_destroy_portids:
 	kfree(rcu_dereference_raw(dp->upcall_portids));
 err_unlock_and_destroy_meters:
@@ -2316,7 +2318,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
 	vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
 	if (!vport->upcall_stats) {
 		err = -ENOMEM;
-		goto exit_unlock_free;
+		goto exit_unlock_free_vport;
 	}
 
 	err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
@@ -2336,6 +2338,8 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
 	ovs_notify(&dp_vport_genl_family, reply, info);
 	return 0;
 
+exit_unlock_free_vport:
+	ovs_dp_detach_port(vport);
 exit_unlock_free:
 	ovs_unlock();
 	kfree_skb(reply);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: openvswitch: release vport resources on failure
  2022-12-20 21:27 [PATCH net] net: openvswitch: release vport resources on failure Aaron Conole
@ 2022-12-21  9:48 ` Eelco Chaudron
  2022-12-21 10:11 ` Michal Swiatkowski
  2022-12-22  1:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eelco Chaudron @ 2022-12-21  9:48 UTC (permalink / raw)
  To: Aaron Conole
  Cc: netdev, Pravin B Shelar, Jakub Kicinski, David S. Miller,
	Paolo Abeni, Eric Dumazet, Thomas Graf, dev, Ilya Maximets,
	wangchuanlei, linux-kernel



On 20 Dec 2022, at 22:27, Aaron Conole wrote:

> A recent commit introducing upcall packet accounting failed to properly
> release the vport object when the per-cpu stats struct couldn't be
> allocated.  This can cause dangling pointers to dp objects long after
> they've been released.
>
> Cc: Eelco Chaudron <echaudro@redhat.com>
> Cc: wangchuanlei <wangchuanlei@inspur.com>
> Fixes: 1933ea365aa7 ("net: openvswitch: Add support to count upcall packets")
> Reported-by: syzbot+8f4e2dcfcb3209ac35f9@syzkaller.appspotmail.com
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---

Thanks for finding and fixing this! The changes look good to me.

Acked-by: Eelco Chaudron <echaudro@redhat.com>


>  net/openvswitch/datapath.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index 932bcf766d63..6774baf9e212 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -1854,7 +1854,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
>  	vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
>  	if (!vport->upcall_stats) {
>  		err = -ENOMEM;
> -		goto err_destroy_portids;
> +		goto err_destroy_vport;
>  	}
>
>  	err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
> @@ -1869,6 +1869,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_vport:
> +	ovs_dp_detach_port(vport);
>  err_destroy_portids:
>  	kfree(rcu_dereference_raw(dp->upcall_portids));
>  err_unlock_and_destroy_meters:
> @@ -2316,7 +2318,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
>  	vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
>  	if (!vport->upcall_stats) {
>  		err = -ENOMEM;
> -		goto exit_unlock_free;
> +		goto exit_unlock_free_vport;
>  	}
>
>  	err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
> @@ -2336,6 +2338,8 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
>  	ovs_notify(&dp_vport_genl_family, reply, info);
>  	return 0;
>
> +exit_unlock_free_vport:
> +	ovs_dp_detach_port(vport);
>  exit_unlock_free:
>  	ovs_unlock();
>  	kfree_skb(reply);
> -- 
> 2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: openvswitch: release vport resources on failure
  2022-12-20 21:27 [PATCH net] net: openvswitch: release vport resources on failure Aaron Conole
  2022-12-21  9:48 ` Eelco Chaudron
@ 2022-12-21 10:11 ` Michal Swiatkowski
  2022-12-22  1:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Swiatkowski @ 2022-12-21 10:11 UTC (permalink / raw)
  To: Aaron Conole
  Cc: netdev, Pravin B Shelar, Jakub Kicinski, David S. Miller,
	Paolo Abeni, Eric Dumazet, Thomas Graf, dev, Eelco Chaudron,
	Ilya Maximets, wangchuanlei, linux-kernel

On Tue, Dec 20, 2022 at 04:27:17PM -0500, Aaron Conole wrote:
> A recent commit introducing upcall packet accounting failed to properly
> release the vport object when the per-cpu stats struct couldn't be
> allocated.  This can cause dangling pointers to dp objects long after
> they've been released.
> 
> Cc: Eelco Chaudron <echaudro@redhat.com>
> Cc: wangchuanlei <wangchuanlei@inspur.com>
> Fixes: 1933ea365aa7 ("net: openvswitch: Add support to count upcall packets")
> Reported-by: syzbot+8f4e2dcfcb3209ac35f9@syzkaller.appspotmail.com
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
Looks good, thanks

Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> -- 
> 2.31.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: openvswitch: release vport resources on failure
  2022-12-20 21:27 [PATCH net] net: openvswitch: release vport resources on failure Aaron Conole
  2022-12-21  9:48 ` Eelco Chaudron
  2022-12-21 10:11 ` Michal Swiatkowski
@ 2022-12-22  1:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-22  1:50 UTC (permalink / raw)
  To: Aaron Conole
  Cc: netdev, pshelar, kuba, davem, pabeni, edumazet, tgraf, dev,
	echaudro, i.maximets, wangchuanlei, linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 20 Dec 2022 16:27:17 -0500 you wrote:
> A recent commit introducing upcall packet accounting failed to properly
> release the vport object when the per-cpu stats struct couldn't be
> allocated.  This can cause dangling pointers to dp objects long after
> they've been released.
> 
> Cc: Eelco Chaudron <echaudro@redhat.com>
> Cc: wangchuanlei <wangchuanlei@inspur.com>
> Fixes: 1933ea365aa7 ("net: openvswitch: Add support to count upcall packets")
> Reported-by: syzbot+8f4e2dcfcb3209ac35f9@syzkaller.appspotmail.com
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> 
> [...]

Here is the summary with links:
  - [net] net: openvswitch: release vport resources on failure
    https://git.kernel.org/netdev/net/c/95637d91fefd

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] 4+ messages in thread

end of thread, other threads:[~2022-12-22  1:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-20 21:27 [PATCH net] net: openvswitch: release vport resources on failure Aaron Conole
2022-12-21  9:48 ` Eelco Chaudron
2022-12-21 10:11 ` Michal Swiatkowski
2022-12-22  1:50 ` 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