diff options
author | Gustavo A. R. Silva <garsilva@embeddedor.com> | 2017-11-04 23:54:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-07 20:41:32 -0500 |
commit | 39a4b86f0de4ce5024985a56fc39b16194b04313 (patch) | |
tree | 57d0550e5ea32b7c51ae340d18d8c8a961db8267 | |
parent | 13c249a94f525fe4c757d28854049780b25605c4 (diff) |
net/mlx5e/core/en_fs: fix pointer dereference after free in mlx5e_execute_l2_action
hn is being kfree'd in mlx5e_del_l2_from_hash and then dereferenced
by accessing hn->ai.addr
Fix this by copying the MAC address into a local variable for its safe use
in all possible execution paths within function mlx5e_execute_l2_action.
Addresses-Coverity-ID: 1417789
Fixes: eeb66cdb6826 ("net/mlx5: Separate between E-Switch and MPFS")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c index 850cdc980ab5..4837045ffba3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | |||
@@ -365,21 +365,24 @@ static void mlx5e_execute_l2_action(struct mlx5e_priv *priv, | |||
365 | struct mlx5e_l2_hash_node *hn) | 365 | struct mlx5e_l2_hash_node *hn) |
366 | { | 366 | { |
367 | u8 action = hn->action; | 367 | u8 action = hn->action; |
368 | u8 mac_addr[ETH_ALEN]; | ||
368 | int l2_err = 0; | 369 | int l2_err = 0; |
369 | 370 | ||
371 | ether_addr_copy(mac_addr, hn->ai.addr); | ||
372 | |||
370 | switch (action) { | 373 | switch (action) { |
371 | case MLX5E_ACTION_ADD: | 374 | case MLX5E_ACTION_ADD: |
372 | mlx5e_add_l2_flow_rule(priv, &hn->ai, MLX5E_FULLMATCH); | 375 | mlx5e_add_l2_flow_rule(priv, &hn->ai, MLX5E_FULLMATCH); |
373 | if (!is_multicast_ether_addr(hn->ai.addr)) { | 376 | if (!is_multicast_ether_addr(mac_addr)) { |
374 | l2_err = mlx5_mpfs_add_mac(priv->mdev, hn->ai.addr); | 377 | l2_err = mlx5_mpfs_add_mac(priv->mdev, mac_addr); |
375 | hn->mpfs = !l2_err; | 378 | hn->mpfs = !l2_err; |
376 | } | 379 | } |
377 | hn->action = MLX5E_ACTION_NONE; | 380 | hn->action = MLX5E_ACTION_NONE; |
378 | break; | 381 | break; |
379 | 382 | ||
380 | case MLX5E_ACTION_DEL: | 383 | case MLX5E_ACTION_DEL: |
381 | if (!is_multicast_ether_addr(hn->ai.addr) && hn->mpfs) | 384 | if (!is_multicast_ether_addr(mac_addr) && hn->mpfs) |
382 | l2_err = mlx5_mpfs_del_mac(priv->mdev, hn->ai.addr); | 385 | l2_err = mlx5_mpfs_del_mac(priv->mdev, mac_addr); |
383 | mlx5e_del_l2_flow_rule(priv, &hn->ai); | 386 | mlx5e_del_l2_flow_rule(priv, &hn->ai); |
384 | mlx5e_del_l2_from_hash(hn); | 387 | mlx5e_del_l2_from_hash(hn); |
385 | break; | 388 | break; |
@@ -387,7 +390,7 @@ static void mlx5e_execute_l2_action(struct mlx5e_priv *priv, | |||
387 | 390 | ||
388 | if (l2_err) | 391 | if (l2_err) |
389 | netdev_warn(priv->netdev, "MPFS, failed to %s mac %pM, err(%d)\n", | 392 | netdev_warn(priv->netdev, "MPFS, failed to %s mac %pM, err(%d)\n", |
390 | action == MLX5E_ACTION_ADD ? "add" : "del", hn->ai.addr, l2_err); | 393 | action == MLX5E_ACTION_ADD ? "add" : "del", mac_addr, l2_err); |
391 | } | 394 | } |
392 | 395 | ||
393 | static void mlx5e_sync_netdev_addr(struct mlx5e_priv *priv) | 396 | static void mlx5e_sync_netdev_addr(struct mlx5e_priv *priv) |