crypto: cavium - prevent integer overflow loading firmware
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Sep 2022 06:43:27 +0000 (09:43 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 30 Sep 2022 05:57:49 +0000 (13:57 +0800)
commit2526d6bf27d15054bb0778b2f7bc6625fd934905
treee11d83d5b3c1ebad04b1a4a9811b7d8efab6adf3
parentcaca37cf6c749ff0303f68418cfe7b757a4e0697
crypto: cavium - prevent integer overflow loading firmware

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 "ntohl(ucode->code_length) * 2" multiplication can have an
integer overflow.

Fixes: 9e2c7d99941d ("crypto: cavium - 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>
drivers/crypto/cavium/cpt/cptpf_main.c