Skip to contentSkip to conversation

Patch "net/mlx5e: Prevent possible races in VXLAN control flow" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Dec 31, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

net/mlx5e: Prevent possible races in VXLAN control flow

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
net-mlx5e-prevent-possible-races-in-vxlan-control-flow.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Sun Dec 31 11:13:15 CET 2017

From: Gal Pressman <[email protected]>
Date: Mon, 4 Dec 2017 09:57:43 +0200
Subject: net/mlx5e: Prevent possible races in VXLAN control flow

From: Gal Pressman <[email protected]>

[ Upstream commit 0c1cc8b2215f5122ca614b5adca60346018758c3 ]

When calling add/remove VXLAN port, a lock must be held in order to prevent race scenarios when more than one add/remove happens at the same time.
Fix by holding our state_lock (mutex) as done by all other parts of the driver.
Note that the spinlock protecting the radix-tree is still needed in order to synchronize radix-tree access from softirq context.

Fixes b3f63c3d5e2c ("net/mlx5e: Add netdev support for VXLAN tunneling")
---
 drivers/net/ethernet/mellanox/mlx5/core/vxlan.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/vxlan.c +4 -0
@@ -88,6 +88,7 @@ static void mlx5e_vxlan_add_port(struct
 	struct mlx5e_vxlan *vxlan;
 	int err;
 
+	mutex_lock(&priv->state_lock);
 	vxlan = mlx5e_vxlan_lookup_port(priv, port);
 	if (vxlan) {
 		atomic_inc(&vxlan->refcount);
@@ -117,6 +118,7 @@ err_free:
 err_delete_port:
 	mlx5e_vxlan_core_del_port_cmd(priv->mdev, port);
 free_work:
+	mutex_unlock(&priv->state_lock);
 	kfree(vxlan_work);
 }
 
@@ -130,6 +132,7 @@ static void mlx5e_vxlan_del_port(struct
 	struct mlx5e_vxlan *vxlan;
 	bool remove = false;
 
+	mutex_lock(&priv->state_lock);
 	spin_lock_bh(&vxlan_db->lock);
 	vxlan = radix_tree_lookup(&vxlan_db->tree, port);
 	if (!vxlan)
@@ -147,6 +150,7 @@ out_unlock:
 		mlx5e_vxlan_core_del_port_cmd(priv->mdev, port);
 		kfree(vxlan);
 	}
+	mutex_unlock(&priv->state_lock);
 	kfree(vxlan_work);
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/net-mlx5e-fix-possible-deadlock-of-vxlan-lock.patch queue-4.9/net-mlx5e-prevent-possible-races-in-vxlan-control-flow.patch queue-4.9/net-mlx5e-add-refcount-to-vxlan-structure.patch queue-4.9/net-mlx5e-fix-features-check-of-ipv6-traffic.patch