Skip to content

Commit 1c200f8

Browse files
keesdavem330
authored andcommitted
net: qed: Fix memcpy() overflow of qed_dcbx_params()
The source (&dcbx_info->operational.params) and dest (&p_hwfn->p_dcbx_info->set.config.params) are both struct qed_dcbx_params (560 bytes), not struct qed_dcbx_admin_params (564 bytes), which is used as the memcpy() size. However it seems that struct qed_dcbx_operational_params (dcbx_info->operational)'s layout matches struct qed_dcbx_admin_params (p_hwfn->p_dcbx_info->set.config)'s 4 byte difference (3 padding, 1 byte for "valid"). On the assumption that the size is wrong (rather than the source structure type), adjust the memcpy() size argument to be 4 bytes smaller and add a BUILD_BUG_ON() to validate any changes to the structure sizes. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c3b26fd commit 1c200f8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/ethernet/qlogic/qed/qed_dcbx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,9 +1266,11 @@ int qed_dcbx_get_config_params(struct qed_hwfn *p_hwfn,
12661266
p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_STATIC;
12671267

12681268
p_hwfn->p_dcbx_info->set.enabled = dcbx_info->operational.enabled;
1269+
BUILD_BUG_ON(sizeof(dcbx_info->operational.params) !=
1270+
sizeof(p_hwfn->p_dcbx_info->set.config.params));
12691271
memcpy(&p_hwfn->p_dcbx_info->set.config.params,
12701272
&dcbx_info->operational.params,
1271-
sizeof(struct qed_dcbx_admin_params));
1273+
sizeof(p_hwfn->p_dcbx_info->set.config.params));
12721274
p_hwfn->p_dcbx_info->set.config.valid = true;
12731275

12741276
memcpy(params, &p_hwfn->p_dcbx_info->set, sizeof(struct qed_dcbx_set));

0 commit comments

Comments
 (0)