Skip to content

Commit de31854

Browse files
chumakdSaeed Mahameed
authored andcommitted
net/mlx5e: Fix nullptr on deleting mirroring rule
Deleting a Tc rule with multiple outputs, one of which is internal port, like this one: tc filter del dev enp8s0f0_0 ingress protocol ip pref 5 flower \ dst_mac 0c:42:a1:d1:d0:88 \ src_mac e4:ea:09:08:00:02 \ action tunnel_key set \ src_ip 0.0.0.0 \ dst_ip 7.7.7.8 \ id 8 \ dst_port 4789 \ action mirred egress mirror dev vxlan_sys_4789 pipe \ action mirred egress redirect dev enp8s0f0_1 Triggers a call trace: BUG: kernel NULL pointer dereference, address: 0000000000000230 RIP: 0010:del_sw_hw_rule+0x2b/0x1f0 [mlx5_core] Call Trace: tree_remove_node+0x16/0x30 [mlx5_core] mlx5_del_flow_rules+0x51/0x160 [mlx5_core] __mlx5_eswitch_del_rule+0x4b/0x170 [mlx5_core] mlx5e_tc_del_fdb_flow+0x295/0x550 [mlx5_core] mlx5e_flow_put+0x1f/0x70 [mlx5_core] mlx5e_delete_flower+0x286/0x390 [mlx5_core] tc_setup_cb_destroy+0xac/0x170 fl_hw_destroy_filter+0x94/0xc0 [cls_flower] __fl_delete+0x15e/0x170 [cls_flower] fl_delete+0x36/0x80 [cls_flower] tc_del_tfilter+0x3a6/0x6e0 rtnetlink_rcv_msg+0xe5/0x360 ? rtnl_calcit.isra.0+0x110/0x110 netlink_rcv_skb+0x46/0x110 netlink_unicast+0x16b/0x200 netlink_sendmsg+0x202/0x3d0 sock_sendmsg+0x33/0x40 ____sys_sendmsg+0x1c3/0x200 ? copy_msghdr_from_user+0xd6/0x150 ___sys_sendmsg+0x88/0xd0 ? ___sys_recvmsg+0x88/0xc0 ? do_futex+0x10c/0x460 __sys_sendmsg+0x59/0xa0 do_syscall_64+0x48/0x140 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fix by disabling offloading for flows matching esw_is_chain_src_port_rewrite() which have more than one output. Fixes: 10742ef ("net/mlx5e: VF tunnel TX traffic offloading") Signed-off-by: Dima Chumak <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 0b7cfa4 commit de31854

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,26 +295,28 @@ esw_setup_chain_src_port_rewrite(struct mlx5_flow_destination *dest,
295295
int *i)
296296
{
297297
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
298-
int j, err;
298+
int err;
299299

300300
if (!(attr->flags & MLX5_ESW_ATTR_FLAG_SRC_REWRITE))
301301
return -EOPNOTSUPP;
302302

303-
for (j = esw_attr->split_count; j < esw_attr->out_count; j++, (*i)++) {
304-
err = esw_setup_chain_dest(dest, flow_act, chains, attr->dest_chain, 1, 0, *i);
305-
if (err)
306-
goto err_setup_chain;
303+
/* flow steering cannot handle more than one dest with the same ft
304+
* in a single flow
305+
*/
306+
if (esw_attr->out_count - esw_attr->split_count > 1)
307+
return -EOPNOTSUPP;
307308

308-
if (esw_attr->dests[j].pkt_reformat) {
309-
flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
310-
flow_act->pkt_reformat = esw_attr->dests[j].pkt_reformat;
311-
}
309+
err = esw_setup_chain_dest(dest, flow_act, chains, attr->dest_chain, 1, 0, *i);
310+
if (err)
311+
return err;
312+
313+
if (esw_attr->dests[esw_attr->split_count].pkt_reformat) {
314+
flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
315+
flow_act->pkt_reformat = esw_attr->dests[esw_attr->split_count].pkt_reformat;
312316
}
313-
return 0;
317+
(*i)++;
314318

315-
err_setup_chain:
316-
esw_put_dest_tables_loop(esw, attr, esw_attr->split_count, j);
317-
return err;
319+
return 0;
318320
}
319321

320322
static void esw_cleanup_chain_src_port_rewrite(struct mlx5_eswitch *esw,

0 commit comments

Comments
 (0)