summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
diff options
context:
space:
mode:
authorMichael Chan <michael.chan@broadcom.com>2018-04-26 17:44:33 -0400
committerDavid S. Miller <davem@davemloft.net>2018-04-27 14:47:28 -0400
commit59895f596b13b4b09f739bf8470a5028a5ff2b9a (patch)
tree8ebea69633dfb26bd9c34adacae41a819ec43036 /drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
parentd31cd579a45c44ede9e56c2f6d33537ba395a49b (diff)
downloadlinux-59895f596b13b4b09f739bf8470a5028a5ff2b9a.tar.gz
linux-59895f596b13b4b09f739bf8470a5028a5ff2b9a.tar.bz2
linux-59895f596b13b4b09f739bf8470a5028a5ff2b9a.zip
bnxt_en: Check the lengths of encapsulated firmware responses.
Firmware messages that are forwarded from PF to VFs are encapsulated. The size of these encapsulated messages must not exceed the maximum defined message size. Add appropriate checks to avoid oversize messages. Firmware messages may be expanded in future specs and this will provide some guardrails to avoid data corruption. Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h')
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
index d10f6f6c7860..6f6d85010ecf 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
@@ -11,6 +11,18 @@
#ifndef BNXT_SRIOV_H
#define BNXT_SRIOV_H
+#define BNXT_FWD_RESP_SIZE_ERR(n) \
+ ((offsetof(struct hwrm_fwd_resp_input, encap_resp) + n) > \
+ sizeof(struct hwrm_fwd_resp_input))
+
+#define BNXT_EXEC_FWD_RESP_SIZE_ERR(n) \
+ ((offsetof(struct hwrm_exec_fwd_resp_input, encap_request) + n) >\
+ offsetof(struct hwrm_exec_fwd_resp_input, encap_resp_target_id))
+
+#define BNXT_REJ_FWD_RESP_SIZE_ERR(n) \
+ ((offsetof(struct hwrm_reject_fwd_resp_input, encap_request) + n) >\
+ offsetof(struct hwrm_reject_fwd_resp_input, encap_resp_target_id))
+
int bnxt_get_vf_config(struct net_device *, int, struct ifla_vf_info *);
int bnxt_set_vf_mac(struct net_device *, int, u8 *);
int bnxt_set_vf_vlan(struct net_device *, int, u16, u8, __be16);