From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
Roi Dayan <roid@nvidia.com>, Chris Mi <cmi@nvidia.com>
Subject: [net 07/14] net/mlx5: E-Switch, Set correctly vport destination
Date: Mon, 21 Nov 2022 18:25:52 -0800 [thread overview]
Message-ID: <20221122022559.89459-8-saeed@kernel.org> (raw)
In-Reply-To: <20221122022559.89459-1-saeed@kernel.org>
From: Roi Dayan <roid@nvidia.com>
The cited commit moved from using reformat_id integer to packet_reformat
pointer which introduced the possibility to null pointer dereference.
When setting packet reformat flag and pkt_reformat pointer must
exists so checking MLX5_ESW_DEST_ENCAP is not enough, we need
to make sure the pkt_reformat is valid and check for MLX5_ESW_DEST_ENCAP_VALID.
If the dest encap valid flag does not exists then pkt_reformat can be
either invalid address or null.
Also, to make sure we don't try to access invalid pkt_reformat set it to
null when invalidated and invalidate it before calling add flow code as
its logically more correct and to be safe.
Fixes: 2b688ea5efde ("net/mlx5: Add flow steering actions to fs_cmd shim layer")
Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Chris Mi <cmi@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 10 ++++++----
.../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
index 5aff97914367..5b6a79d2034e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
@@ -224,15 +224,16 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
list_for_each_entry(flow, flow_list, tmp_list) {
if (!mlx5e_is_offloaded_flow(flow) || flow_flag_test(flow, SLOW))
continue;
- spec = &flow->attr->parse_attr->spec;
-
- /* update from encap rule to slow path rule */
- rule = mlx5e_tc_offload_to_slow_path(esw, flow, spec);
attr = mlx5e_tc_get_encap_attr(flow);
esw_attr = attr->esw_attr;
/* mark the flow's encap dest as non-valid */
esw_attr->dests[flow->tmp_entry_index].flags &= ~MLX5_ESW_DEST_ENCAP_VALID;
+ esw_attr->dests[flow->tmp_entry_index].pkt_reformat = NULL;
+
+ /* update from encap rule to slow path rule */
+ spec = &flow->attr->parse_attr->spec;
+ rule = mlx5e_tc_offload_to_slow_path(esw, flow, spec);
if (IS_ERR(rule)) {
err = PTR_ERR(rule);
@@ -251,6 +252,7 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
/* we know that the encap is valid */
e->flags &= ~MLX5_ENCAP_ENTRY_VALID;
mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat);
+ e->pkt_reformat = NULL;
}
static void mlx5e_take_tmp_flow(struct mlx5e_tc_flow *flow,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 728ca9f2bb9d..3fda75fe168c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -433,7 +433,7 @@ esw_setup_vport_dest(struct mlx5_flow_destination *dest, struct mlx5_flow_act *f
mlx5_lag_mpesw_is_activated(esw->dev))
dest[dest_idx].type = MLX5_FLOW_DESTINATION_TYPE_UPLINK;
}
- if (esw_attr->dests[attr_idx].flags & MLX5_ESW_DEST_ENCAP) {
+ if (esw_attr->dests[attr_idx].flags & MLX5_ESW_DEST_ENCAP_VALID) {
if (pkt_reformat) {
flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
flow_act->pkt_reformat = esw_attr->dests[attr_idx].pkt_reformat;
--
2.38.1
next prev parent reply other threads:[~2022-11-22 2:28 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 2:25 [pull request][net 00/14] mlx5 fixes 2022-11-21 Saeed Mahameed
2022-11-22 2:25 ` [net 01/14] net/mlx5: Do not query pci info while pci disabled Saeed Mahameed
2022-11-23 5:00 ` patchwork-bot+netdevbpf
2022-11-22 2:25 ` [net 02/14] net/mlx5: Fix FW tracer timestamp calculation Saeed Mahameed
2022-11-22 2:25 ` [net 03/14] net/mlx5: SF: Fix probing active SFs during driver probe phase Saeed Mahameed
2022-11-23 14:57 ` Maciej Fijalkowski
2022-11-23 17:11 ` Parav Pandit
2022-11-23 17:44 ` Maciej Fijalkowski
2022-11-23 23:36 ` Saeed Mahameed
2022-11-22 2:25 ` [net 04/14] net/mlx5: cmdif, Print info on any firmware cmd failure to tracepoint Saeed Mahameed
2022-11-23 15:06 ` Maciej Fijalkowski
2022-11-23 23:48 ` Saeed Mahameed
2022-11-24 1:55 ` Jakub Kicinski
2022-11-24 4:37 ` Saeed Mahameed
2022-11-22 2:25 ` [net 05/14] net/mlx5: Fix handling of entry refcount when command is not issued to FW Saeed Mahameed
2022-11-22 2:25 ` [net 06/14] net/mlx5: Lag, avoid lockdep warnings Saeed Mahameed
2022-11-22 2:25 ` Saeed Mahameed [this message]
2022-11-22 2:25 ` [net 08/14] net/mlx5: Fix sync reset event handler error flow Saeed Mahameed
2022-11-22 2:25 ` [net 09/14] net/mlx5e: Fix missing alignment in size of MTT/KLM entries Saeed Mahameed
2022-11-22 2:25 ` [net 10/14] net/mlx5e: Offload rule only when all encaps are valid Saeed Mahameed
2022-11-22 2:25 ` [net 11/14] net/mlx5e: Remove leftovers from old XSK queues enumeration Saeed Mahameed
2022-11-22 2:25 ` [net 12/14] net/mlx5e: Fix MACsec SA initialization routine Saeed Mahameed
2022-11-22 2:25 ` [net 13/14] net/mlx5e: Fix MACsec update SecY Saeed Mahameed
2022-11-23 15:21 ` Maciej Fijalkowski
2022-11-23 23:57 ` Saeed Mahameed
2022-11-22 2:25 ` [net 14/14] net/mlx5e: Fix possible race condition in macsec extended packet number update routine Saeed Mahameed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221122022559.89459-8-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=cmi@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=roid@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.