Patch "net/mlx5e: Check netdev pointer before checking its net ns" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

    net/mlx5e: Check netdev pointer before checking its net ns

to the 6.6-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-check-netdev-pointer-before-checking-its-n.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2312b6ae40d5f24501806cad35104b9ed9a8ce17
Author: Gavin Li <gavinl@xxxxxxxxxx>
Date:   Thu Aug 31 05:47:09 2023 +0300

    net/mlx5e: Check netdev pointer before checking its net ns
    
    [ Upstream commit 7aaf975238c47b710fcc4eca0da1e7902a53abe2 ]
    
    Previously, when comparing the net namespaces, the case where the netdev
    doesn't exist wasn't taken into account, and therefore can cause a crash.
    In such a case, the comparing function should return false, as there is no
    netdev->net to compare the devlink->net to.
    
    Furthermore, this will result in an attempt to enter switchdev mode
    without a netdev to fail, and which is the desired result as there is no
    meaning in switchdev mode without a net device.
    
    Fixes: 662404b24a4c ("net/mlx5e: Block entering switchdev mode with ns inconsistency")
    Signed-off-by: Gavin Li <gavinl@xxxxxxxxxx>
    Reviewed-by: Gavi Teitz <gavi@xxxxxxxxxx>
    Signed-off-by: Saeed Mahameed <saeedm@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index bf78eeca401be..bb8bcb448ae90 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -3653,14 +3653,18 @@ static int esw_inline_mode_to_devlink(u8 mlx5_mode, u8 *mode)
 
 static bool esw_offloads_devlink_ns_eq_netdev_ns(struct devlink *devlink)
 {
+	struct mlx5_core_dev *dev = devlink_priv(devlink);
 	struct net *devl_net, *netdev_net;
-	struct mlx5_eswitch *esw;
-
-	esw = mlx5_devlink_eswitch_nocheck_get(devlink);
-	netdev_net = dev_net(esw->dev->mlx5e_res.uplink_netdev);
-	devl_net = devlink_net(devlink);
+	bool ret = false;
 
-	return net_eq(devl_net, netdev_net);
+	mutex_lock(&dev->mlx5e_res.uplink_netdev_lock);
+	if (dev->mlx5e_res.uplink_netdev) {
+		netdev_net = dev_net(dev->mlx5e_res.uplink_netdev);
+		devl_net = devlink_net(devlink);
+		ret = net_eq(devl_net, netdev_net);
+	}
+	mutex_unlock(&dev->mlx5e_res.uplink_netdev_lock);
+	return ret;
 }
 
 int mlx5_eswitch_block_mode(struct mlx5_core_dev *dev)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux