crypto: marvell/octeontx - prevent integer overflows
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Sep 2022 06:43:19 +0000 (09:43 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 10:35:27 +0000 (12:35 +0200)
commit12acfa1059ad69aa352ddb2bf23ba1b831aff15f
tree6dee60532d4471374594bbddcb463a2beb6c908c
parentc963ce2fa05df45cf9b4c0854ed7abb2911132f7
crypto: marvell/octeontx - prevent integer overflows

[ Upstream commit caca37cf6c749ff0303f68418cfe7b757a4e0697 ]

The "code_length" value comes from the firmware file.  If your firmware
is untrusted realistically there is probably very little you can do to
protect yourself.  Still we try to limit the damage as much as possible.
Also Smatch marks any data read from the filesystem as untrusted and
prints warnings if it not capped correctly.

The "code_length * 2" can overflow.  The round_up(ucode_size, 16) +
sizeof() expression can overflow too.  Prevent these overflows.

Fixes: d9110b0b01ff ("crypto: marvell - add support for OCTEON TX CPT engine")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c