]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: qed: Fix memcpy() overflow of qed_dcbx_params()
authorKees Cook <keescook@chromium.org>
Thu, 17 Jun 2021 17:09:53 +0000 (10:09 -0700)
committerSasha Levin <sashal@kernel.org>
Wed, 30 Jun 2021 12:48:33 +0000 (08:48 -0400)
commit144ca5c30c7a97d0c37c404c157db1b1358e2fcf
tree12a9476df18bdf60ccfd7785fbdce7ee4a349cea
parentdf084ef4de987d870eb958ce2e1ae97f6251109a
net: qed: Fix memcpy() overflow of qed_dcbx_params()

[ Upstream commit 1c200f832e14420fa770193f9871f4ce2df00d07 ]

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 <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/qlogic/qed/qed_dcbx.c