From: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
To: Fiona.trahe@intel.com, Deepak.k.jain@intel.com, john.griffin@intel.com
Cc: dev@dpdk.org, Tomasz Jozwiak <tomaszx.jozwiak@intel.com>,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH v2 1/3] crypto/qat: fix out-of-bounds compiler error
Date: Mon, 22 Jan 2018 17:28:03 +0100 [thread overview]
Message-ID: <1516638485-10139-2-git-send-email-tomaszx.jozwiak@intel.com> (raw)
In-Reply-To: <1516638485-10139-1-git-send-email-tomaszx.jozwiak@intel.com>
This commit fixes
- bpi_cipher_encrypt to prevent before 'array subscript is
above array bounds' error
- bpi_cipher_decrypt to prevent before 'array subscript is
above array bounds' error
Fixes: d18ab45f7654 ("crypto/qat: support DOCSIS BPI mode")
Cc: stable@dpdk.org
Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
---
drivers/crypto/qat/qat_crypto.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c
index a572967..f85c2c8 100644
--- a/drivers/crypto/qat/qat_crypto.c
+++ b/drivers/crypto/qat/qat_crypto.c
@@ -69,6 +69,10 @@
#include "adf_transport_access_macros.h"
#define BYTE_LENGTH 8
+/* bpi is only used for partial blocks of DES and AES
+ * so AES block len can be assumed as max len for iv, src and dst
+ */
+#define BPI_MAX_ENCR_IV_LEN ICP_QAT_HW_AES_BLK_SZ
static int
qat_is_cipher_alg_supported(enum rte_crypto_cipher_algorithm algo,
@@ -121,16 +125,16 @@ bpi_cipher_encrypt(uint8_t *src, uint8_t *dst,
{
EVP_CIPHER_CTX *ctx = (EVP_CIPHER_CTX *)bpi_ctx;
int encrypted_ivlen;
- uint8_t encrypted_iv[16];
- int i;
+ uint8_t encrypted_iv[BPI_MAX_ENCR_IV_LEN];
+ uint8_t *encr = encrypted_iv;
/* ECB method: encrypt the IV, then XOR this with plaintext */
if (EVP_EncryptUpdate(ctx, encrypted_iv, &encrypted_ivlen, iv, ivlen)
<= 0)
goto cipher_encrypt_err;
- for (i = 0; i < srclen; i++)
- *(dst+i) = *(src+i)^(encrypted_iv[i]);
+ for (; srclen != 0; --srclen, ++dst, ++src, ++encr)
+ *dst = *src ^ *encr;
return 0;
@@ -150,16 +154,16 @@ bpi_cipher_decrypt(uint8_t *src, uint8_t *dst,
{
EVP_CIPHER_CTX *ctx = (EVP_CIPHER_CTX *)bpi_ctx;
int encrypted_ivlen;
- uint8_t encrypted_iv[16];
- int i;
+ uint8_t encrypted_iv[BPI_MAX_ENCR_IV_LEN];
+ uint8_t *encr = encrypted_iv;
/* ECB method: encrypt (not decrypt!) the IV, then XOR with plaintext */
if (EVP_EncryptUpdate(ctx, encrypted_iv, &encrypted_ivlen, iv, ivlen)
<= 0)
goto cipher_decrypt_err;
- for (i = 0; i < srclen; i++)
- *(dst+i) = *(src+i)^(encrypted_iv[i]);
+ for (; srclen != 0; --srclen, ++dst, ++src, ++encr)
+ *dst = *src ^ *encr;
return 0;
--
2.7.4
next prev parent reply other threads:[~2018-01-22 16:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 13:53 [dpdk-dev] [PATCH] " Tomasz Jozwiak
2018-01-15 14:30 ` Trahe, Fiona
2018-01-17 17:23 ` De Lara Guarch, Pablo
2018-01-22 16:28 ` [dpdk-dev] [PATCH v2 0/3] Fixes for QAT PMD Tomasz Jozwiak
2018-01-22 16:28 ` Tomasz Jozwiak [this message]
2018-01-22 16:28 ` [dpdk-dev] [PATCH v2 2/3] crypto/qat: fix typo in error message Tomasz Jozwiak
2018-01-22 16:28 ` [dpdk-dev] [PATCH v2 3/3] crypto/qat: fix parameter type Tomasz Jozwiak
2018-01-23 11:50 ` [dpdk-dev] [PATCH v2 0/3] Fixes for QAT PMD De Lara Guarch, Pablo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1516638485-10139-2-git-send-email-tomaszx.jozwiak@intel.com \
--to=tomaszx.jozwiak@intel.com \
--cc=Deepak.k.jain@intel.com \
--cc=Fiona.trahe@intel.com \
--cc=dev@dpdk.org \
--cc=john.griffin@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).