net/mlx5: fix crash for empty raw encap data
authorXiaoyu Min <jackmin@mellanox.com>
Tue, 20 Aug 2019 09:47:14 +0000 (17:47 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 26 Aug 2019 12:41:13 +0000 (14:41 +0200)
For the rte_flow_action_raw_encap, the header definition for
encapsulation must be available, otherwise it will lead to crash on some
OFED versions and logically it should be rejected.

Fixes: 8ba9eee4ce32 ("net/mlx5: add raw data encap/decap to Direct Verbs")
Cc: stable@dpdk.org
Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
Acked-by: Dekel Peled <dekelp@mellanox.com>
drivers/net/mlx5/mlx5_flow_dv.c

index 21faa98..41500bc 100644 (file)
@@ -949,6 +949,8 @@ flow_dv_validate_action_raw_encap(uint64_t action_flags,
                                  const struct rte_flow_attr *attr,
                                  struct rte_flow_error *error)
 {
+       const struct rte_flow_action_raw_encap *raw_encap =
+               (const struct rte_flow_action_raw_encap *)action->conf;
        if (!(action->conf))
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, action,
@@ -970,6 +972,10 @@ flow_dv_validate_action_raw_encap(uint64_t action_flags,
                                          NULL,
                                          "encap action not supported for "
                                          "ingress");
+       if (!raw_encap->size || !raw_encap->data)
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ACTION, action,
+                                         "raw encap data cannot be empty");
        return 0;
 }