Skip to content

Commit

Permalink
common/sfc_efx/base: add missing MCDI response length checks
Browse files Browse the repository at this point in the history
Fixes: 6f61965 ("net/sfc/base: import MCDI implementation")
Fixes: e7cd430 ("net/sfc/base: import SFN7xxx family support")
Fixes: 94190e3 ("net/sfc/base: import SFN8xxx family support")
Fixes: 34285fd ("common/sfc_efx/base: add match spec validate API")
Fixes: e61baa8 ("common/sfc_efx/base: add MAE action set provisioning APIs")
Fixes: b4fac34 ("common/sfc_efx/base: add MAE action rule provisioning APIs")
Fixes: ed15d7f ("common/sfc_efx/base: validate and compare outer match specs")
Fixes: 7a673e1 ("common/sfc_efx/base: support outer rule provisioning")
Cc: stable@dpdk.org

Signed-off-by: Andy Moreton <amoreton@xilinx.com>
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
  • Loading branch information
Andy Moreton authored and Ferruh Yigit committed May 19, 2021
1 parent e1c9fca commit e27950a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 11 deletions.
11 changes: 9 additions & 2 deletions drivers/common/sfc_efx/base/ef10_filter.c
Expand Up @@ -1225,20 +1225,25 @@ efx_mcdi_get_parser_disp_info(
goto fail1;
}

if (req.emr_out_length_used < MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMIN) {
rc = EMSGSIZE;
goto fail2;
}

matches_count = MCDI_OUT_DWORD(req,
GET_PARSER_DISP_INFO_OUT_NUM_SUPPORTED_MATCHES);

if (req.emr_out_length_used <
MC_CMD_GET_PARSER_DISP_INFO_OUT_LEN(matches_count)) {
rc = EMSGSIZE;
goto fail2;
goto fail3;
}

*list_lengthp = matches_count;

if (buffer_length < matches_count) {
rc = ENOSPC;
goto fail3;
goto fail4;
}

/*
Expand All @@ -1258,6 +1263,8 @@ efx_mcdi_get_parser_disp_info(

return (0);

fail4:
EFSYS_PROBE(fail4);
fail3:
EFSYS_PROBE(fail3);
fail2:
Expand Down
10 changes: 9 additions & 1 deletion drivers/common/sfc_efx/base/ef10_nic.c
Expand Up @@ -491,11 +491,17 @@ efx_mcdi_get_rxdp_config(
req.emr_out_length = MC_CMD_GET_RXDP_CONFIG_OUT_LEN;

efx_mcdi_execute(enp, &req);

if (req.emr_rc != 0) {
rc = req.emr_rc;
goto fail1;
}

if (req.emr_out_length_used < MC_CMD_GET_RXDP_CONFIG_OUT_LEN) {
rc = EMSGSIZE;
goto fail2;
}

if (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA,
GET_RXDP_CONFIG_OUT_PAD_HOST_DMA) == 0) {
/* RX DMA end padding is disabled */
Expand All @@ -514,14 +520,16 @@ efx_mcdi_get_rxdp_config(
break;
default:
rc = ENOTSUP;
goto fail2;
goto fail3;
}
}

*end_paddingp = end_padding;

return (0);

fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
Expand Down
52 changes: 44 additions & 8 deletions drivers/common/sfc_efx/base/efx_mae.c
Expand Up @@ -109,17 +109,22 @@ efx_mae_get_outer_rule_caps(
goto fail2;
}

if (req.emr_out_length_used < MC_CMD_MAE_GET_OR_CAPS_OUT_LENMIN) {
rc = EMSGSIZE;
goto fail3;
}

mcdi_field_ncaps = MCDI_OUT_DWORD(req, MAE_GET_OR_CAPS_OUT_COUNT);

if (req.emr_out_length_used <
MC_CMD_MAE_GET_OR_CAPS_OUT_LEN(mcdi_field_ncaps)) {
rc = EMSGSIZE;
goto fail3;
goto fail4;
}

if (mcdi_field_ncaps > field_ncaps) {
rc = EMSGSIZE;
goto fail4;
goto fail5;
}

for (i = 0; i < mcdi_field_ncaps; ++i) {
Expand Down Expand Up @@ -147,6 +152,8 @@ efx_mae_get_outer_rule_caps(

return (0);

fail5:
EFSYS_PROBE(fail5);
fail4:
EFSYS_PROBE(fail4);
fail3:
Expand Down Expand Up @@ -191,17 +198,22 @@ efx_mae_get_action_rule_caps(
goto fail2;
}

mcdi_field_ncaps = MCDI_OUT_DWORD(req, MAE_GET_OR_CAPS_OUT_COUNT);
if (req.emr_out_length_used < MC_CMD_MAE_GET_AR_CAPS_OUT_LENMIN) {
rc = EMSGSIZE;
goto fail3;
}

mcdi_field_ncaps = MCDI_OUT_DWORD(req, MAE_GET_AR_CAPS_OUT_COUNT);

if (req.emr_out_length_used <
MC_CMD_MAE_GET_AR_CAPS_OUT_LEN(mcdi_field_ncaps)) {
rc = EMSGSIZE;
goto fail3;
goto fail4;
}

if (mcdi_field_ncaps > field_ncaps) {
rc = EMSGSIZE;
goto fail4;
goto fail5;
}

for (i = 0; i < mcdi_field_ncaps; ++i) {
Expand Down Expand Up @@ -229,6 +241,8 @@ efx_mae_get_action_rule_caps(

return (0);

fail5:
EFSYS_PROBE(fail5);
fail4:
EFSYS_PROBE(fail4);
fail3:
Expand Down Expand Up @@ -1773,15 +1787,22 @@ efx_mae_outer_rule_remove(
goto fail2;
}

if (req.emr_out_length_used < MC_CMD_MAE_OUTER_RULE_REMOVE_OUT_LENMIN) {
rc = EMSGSIZE;
goto fail3;
}

if (MCDI_OUT_DWORD(req, MAE_OUTER_RULE_REMOVE_OUT_REMOVED_OR_ID) !=
or_idp->id) {
/* Firmware failed to remove the outer rule. */
rc = EAGAIN;
goto fail3;
goto fail4;
}

return (0);

fail4:
EFSYS_PROBE(fail4);
fail3:
EFSYS_PROBE(fail3);
fail2:
Expand Down Expand Up @@ -2176,15 +2197,22 @@ efx_mae_action_set_free(
goto fail2;
}

if (req.emr_out_length_used < MC_CMD_MAE_ACTION_SET_FREE_OUT_LENMIN) {
rc = EMSGSIZE;
goto fail3;
}

if (MCDI_OUT_DWORD(req, MAE_ACTION_SET_FREE_OUT_FREED_AS_ID) !=
aset_idp->id) {
/* Firmware failed to free the action set. */
rc = EAGAIN;
goto fail3;
goto fail4;
}

return (0);

fail4:
EFSYS_PROBE(fail4);
fail3:
EFSYS_PROBE(fail3);
fail2:
Expand Down Expand Up @@ -2326,15 +2354,23 @@ efx_mae_action_rule_remove(
goto fail2;
}

if (req.emr_out_length_used <
MC_CMD_MAE_ACTION_RULE_DELETE_OUT_LENMIN) {
rc = EMSGSIZE;
goto fail3;
}

if (MCDI_OUT_DWORD(req, MAE_ACTION_RULE_DELETE_OUT_DELETED_AR_ID) !=
ar_idp->id) {
/* Firmware failed to delete the action rule. */
rc = EAGAIN;
goto fail3;
goto fail4;
}

return (0);

fail4:
EFSYS_PROBE(fail4);
fail3:
EFSYS_PROBE(fail3);
fail2:
Expand Down
7 changes: 7 additions & 0 deletions drivers/common/sfc_efx/base/efx_mcdi.c
Expand Up @@ -2294,6 +2294,11 @@ efx_mcdi_get_workarounds(
goto fail1;
}

if (req.emr_out_length_used < MC_CMD_GET_WORKAROUNDS_OUT_LEN) {
rc = EMSGSIZE;
goto fail2;
}

if (implementedp != NULL) {
*implementedp =
MCDI_OUT_DWORD(req, GET_WORKAROUNDS_OUT_IMPLEMENTED);
Expand All @@ -2305,6 +2310,8 @@ efx_mcdi_get_workarounds(

return (0);

fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);

Expand Down

0 comments on commit e27950a

Please sign in to comment.