net/mlx5e: Fix use-after-free when reverting termination table
authorRoi Dayan <roid@nvidia.com>
Mon, 14 Nov 2022 18:04:29 +0000 (20:04 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 24 Nov 2022 08:03:21 +0000 (00:03 -0800)
When having multiple dests with termination tables and second one
or afterwards fails the driver reverts usage of term tables but
doesn't reset the assignment in attr->dests[num_vport_dests].termtbl
which case a use-after-free when releasing the rule.
Fix by resetting the assignment of termtbl to null.

Fixes: 10caabdaad5a ("net/mlx5e: Use termination table for VLAN push actions")
Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c

index 108a350..edd9102 100644 (file)
@@ -312,6 +312,8 @@ revert_changes:
        for (curr_dest = 0; curr_dest < num_vport_dests; curr_dest++) {
                struct mlx5_termtbl_handle *tt = attr->dests[curr_dest].termtbl;
 
+               attr->dests[curr_dest].termtbl = NULL;
+
                /* search for the destination associated with the
                 * current term table
                 */