Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
common/sfc_efx/base: limit reported MCDI response length
[ upstream commit e1c9fca ]

MCDI helper routines in libefx include length checks for response
messages, to ensure that short replies and optional fields are
handled correctly.

If the MCDI response message from the firmware is larger than the
caller's buffer then the response length reported to the caller
should be limited to the buffer size. Otherwise length checks in
the caller may allow reading past the end of the buffer.

Fixes: 6f61965 ("net/sfc/base: import MCDI implementation")

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 cpaelzer committed Jun 10, 2021
1 parent 43fd401 commit 8671136
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/sfc/base/efx_mcdi.c
Expand Up @@ -495,6 +495,9 @@ efx_mcdi_finish_response(
bytes = MIN(emrp->emr_out_length_used, emrp->emr_out_length);
efx_mcdi_read_response(enp, emrp->emr_out_buf, resp_off, bytes);

/* Report bytes copied to caller (response message may be larger) */
emrp->emr_out_length_used = bytes;

#if EFSYS_OPT_MCDI_LOGGING
if (emtp->emt_logger != NULL) {
emtp->emt_logger(emtp->emt_context,
Expand Down

0 comments on commit 8671136

Please sign in to comment.