diff mbox series

[bionic] net/mlx5e: Don't attempt to dereference the ppriv struct if not being eswitch manager

Message ID 1540126366-11805-1-git-send-email-talatb@mellanox.com
State New
Headers show
Series [bionic] net/mlx5e: Don't attempt to dereference the ppriv struct if not being eswitch manager | expand

Commit Message

Talat Batheesh Oct. 21, 2018, 12:53 p.m. UTC
From: Or Gerlitz <ogerlitz@mellanox.com>

BugLink:  http://bugs.launchpad.net/bugs/1799049

The check for cpu hit statistics was not returning immediate false for
any non vport rep netdev and hence we crashed (say on mlx5 probed VFs) if
user-space tool was calling into any possible netdev in the system.

Fix that by doing a proper check before dereferencing.

Fixes: 1d447a39142e ('net/mlx5e: Extendable vport representor netdev private data')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Eli Cohen <eli@melloanox.com>
Reviewed-by: Eli Cohen <eli@melloanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
(cherry picked from commit 8ffd569aaa818f2624ca821d9a246342fa8b8c50)
Signed-off-by: Talat Batheesh <talatb@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Stefan Bader Nov. 5, 2018, 1:48 p.m. UTC | #1
On 21.10.18 14:53, Talat Batheesh wrote:
> From: Or Gerlitz <ogerlitz@mellanox.com>
> 
> BugLink:  http://bugs.launchpad.net/bugs/1799049
> 
> The check for cpu hit statistics was not returning immediate false for
> any non vport rep netdev and hence we crashed (say on mlx5 probed VFs) if
> user-space tool was calling into any possible netdev in the system.
> 
> Fix that by doing a proper check before dereferencing.
> 
> Fixes: 1d447a39142e ('net/mlx5e: Extendable vport representor netdev private data')
> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
> Reported-by: Eli Cohen <eli@melloanox.com>
> Reviewed-by: Eli Cohen <eli@melloanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> (cherry picked from commit 8ffd569aaa818f2624ca821d9a246342fa8b8c50)
> Signed-off-by: Talat Batheesh <talatb@mellanox.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> index f72abdeb6d08..9ebe78ec99f0 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> @@ -750,8 +750,12 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
>  static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
>  {
>  	struct mlx5e_rep_priv *rpriv = priv->ppriv;
> -	struct mlx5_eswitch_rep *rep = rpriv->rep;
> +	struct mlx5_eswitch_rep *rep;
>  
> +	if (!MLX5_CAP_GEN(priv->mdev, eswitch_flow_table))
> +		return false;
> +
> +	rep = rpriv->rep;
>  	if (rep && rep->vport != FDB_UPLINK_VPORT)
>  		return true;
>  
>
Kleber Sacilotto de Souza Nov. 6, 2018, 2:56 p.m. UTC | #2
On 10/21/18 14:53, Talat Batheesh wrote:
> From: Or Gerlitz <ogerlitz@mellanox.com>
>
> BugLink:  http://bugs.launchpad.net/bugs/1799049
>
> The check for cpu hit statistics was not returning immediate false for
> any non vport rep netdev and hence we crashed (say on mlx5 probed VFs) if
> user-space tool was calling into any possible netdev in the system.
>
> Fix that by doing a proper check before dereferencing.
>
> Fixes: 1d447a39142e ('net/mlx5e: Extendable vport representor netdev private data')
> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
> Reported-by: Eli Cohen <eli@melloanox.com>
> Reviewed-by: Eli Cohen <eli@melloanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> (cherry picked from commit 8ffd569aaa818f2624ca821d9a246342fa8b8c50)
> Signed-off-by: Talat Batheesh <talatb@mellanox.com>

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> index f72abdeb6d08..9ebe78ec99f0 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> @@ -750,8 +750,12 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
>  static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
>  {
>  	struct mlx5e_rep_priv *rpriv = priv->ppriv;
> -	struct mlx5_eswitch_rep *rep = rpriv->rep;
> +	struct mlx5_eswitch_rep *rep;
>  
> +	if (!MLX5_CAP_GEN(priv->mdev, eswitch_flow_table))
> +		return false;
> +
> +	rep = rpriv->rep;
>  	if (rep && rep->vport != FDB_UPLINK_VPORT)
>  		return true;
>
Khalid Elmously Nov. 8, 2018, 7:14 a.m. UTC | #3
On 2018-10-21 12:53:00 , Talat Batheesh wrote:
> From: Or Gerlitz <ogerlitz@mellanox.com>
> 
> BugLink:  http://bugs.launchpad.net/bugs/1799049
> 
> The check for cpu hit statistics was not returning immediate false for
> any non vport rep netdev and hence we crashed (say on mlx5 probed VFs) if
> user-space tool was calling into any possible netdev in the system.
> 
> Fix that by doing a proper check before dereferencing.
> 
> Fixes: 1d447a39142e ('net/mlx5e: Extendable vport representor netdev private data')
> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
> Reported-by: Eli Cohen <eli@melloanox.com>
> Reviewed-by: Eli Cohen <eli@melloanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> (cherry picked from commit 8ffd569aaa818f2624ca821d9a246342fa8b8c50)
> Signed-off-by: Talat Batheesh <talatb@mellanox.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> index f72abdeb6d08..9ebe78ec99f0 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> @@ -750,8 +750,12 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
>  static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
>  {
>  	struct mlx5e_rep_priv *rpriv = priv->ppriv;
> -	struct mlx5_eswitch_rep *rep = rpriv->rep;
> +	struct mlx5_eswitch_rep *rep;
>  
> +	if (!MLX5_CAP_GEN(priv->mdev, eswitch_flow_table))
> +		return false;
> +
> +	rep = rpriv->rep;
>  	if (rep && rep->vport != FDB_UPLINK_VPORT)
>  		return true;
>  
> -- 
> 2.7.5
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index f72abdeb6d08..9ebe78ec99f0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -750,8 +750,12 @@  bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
 static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
 {
 	struct mlx5e_rep_priv *rpriv = priv->ppriv;
-	struct mlx5_eswitch_rep *rep = rpriv->rep;
+	struct mlx5_eswitch_rep *rep;
 
+	if (!MLX5_CAP_GEN(priv->mdev, eswitch_flow_table))
+		return false;
+
+	rep = rpriv->rep;
 	if (rep && rep->vport != FDB_UPLINK_VPORT)
 		return true;