Skip to content

Commit

Permalink
nfp: flower: check that we don't exceed the FW key size
Browse files Browse the repository at this point in the history
Add a check to make sure the total length of the flow key sent to the
firmware stays within the supported limit.

Signed-off-by: Louis Peens <louis.peens@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Louis Peens authored and David S. Miller committed Aug 20, 2020
1 parent 1e76a2f commit e4cab45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/netronome/nfp/flower/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ struct nfp_app;
#define NFP_FLOWER_MASK_ELEMENT_RS 1
#define NFP_FLOWER_MASK_HASH_BITS 10

#define NFP_FLOWER_KEY_MAX_LW 32

#define NFP_FL_META_FLAG_MANAGE_MASK BIT(7)

#define NFP_FL_MASK_REUSE_TIME_NS 40000
Expand Down
11 changes: 11 additions & 0 deletions drivers/net/ethernet/netronome/nfp/flower/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
{
struct flow_rule *rule = flow_cls_offload_flow_rule(flow);
u32 port_id;
int ext_len;
int err;
u8 *ext;
u8 *msk;
Expand Down Expand Up @@ -589,5 +590,15 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
}
}

/* Check that the flow key does not exceed the maximum limit.
* All structures in the key is multiples of 4 bytes, so use u32.
*/
ext_len = (u32 *)ext - (u32 *)nfp_flow->unmasked_data;
if (ext_len > NFP_FLOWER_KEY_MAX_LW) {
NL_SET_ERR_MSG_MOD(extack,
"unsupported offload: flow key too long");
return -EOPNOTSUPP;
}

return 0;
}

0 comments on commit e4cab45

Please sign in to comment.