[v3,1/5] test/crypto: fix wireless auth digest segment

Message ID 20220921125036.9104-2-ciara.power@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series add remaining SGL support to AESNI_MB |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing warning apply patch failure

Commit Message

Power, Ciara Sept. 21, 2022, 12:50 p.m. UTC
  The segment size for some tests was too small to hold the auth digest.
This caused issues when using op->sym->auth.digest.data for comparisons
in AESNI_MB PMD after a subsequent patch enables SGL.

For example, if segment size is 2, and digest size is 4, then 4 bytes
are read from op->sym->auth.digest.data, which overflows into the memory
after the segment, rather than using the second segment that contains
the remaining half of the digest.

Fixes: 11c5485bb276 ("test/crypto: add scatter-gather tests for IP and OOP")

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 app/test/test_cryptodev.c | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Comments

Fan Zhang Sept. 21, 2022, 1:32 p.m. UTC | #1
Hi Ciara,

> -----Original Message-----
> From: Power, Ciara <ciara.power@intel.com>
> Sent: Wednesday, September 21, 2022 1:51 PM
> To: Akhil Goyal <gakhil@marvell.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>
> Cc: dev@dpdk.org; Ji, Kai <kai.ji@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Power, Ciara <ciara.power@intel.com>
> Subject: [PATCH v3 1/5] test/crypto: fix wireless auth digest segment
> 
> The segment size for some tests was too small to hold the auth digest.
> This caused issues when using op->sym->auth.digest.data for comparisons
> in AESNI_MB PMD after a subsequent patch enables SGL.
> 
> For example, if segment size is 2, and digest size is 4, then 4 bytes
> are read from op->sym->auth.digest.data, which overflows into the memory
> after the segment, rather than using the second segment that contains
> the remaining half of the digest.
> 
> Fixes: 11c5485bb276 ("test/crypto: add scatter-gather tests for IP and OOP")
> 
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> ---
>  app/test/test_cryptodev.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
> index 6ee4480399..5533c135b0 100644
> --- a/app/test/test_cryptodev.c
> +++ b/app/test/test_cryptodev.c
> @@ -3040,6 +3040,14 @@ create_wireless_algo_auth_cipher_operation(
>  			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
>  			sgl_buf = sgl_buf->next;
>  		}
> +
> +		/* The last segment should be large enough to hold full digest
> */
> +		if (sgl_buf->data_len < auth_tag_len) {
> +			rte_pktmbuf_free(sgl_buf->next);
> +			sgl_buf->next = NULL;
> +			rte_pktmbuf_append(sgl_buf, auth_tag_len -
> sgl_buf->data_len);

The append shall work once the mbufs are correctly set and mempool is
allocated well. But we should not assume that - it is better to add a simple
check here to make sure the mbuf are appended.

Other than that,
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
  

Patch

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 6ee4480399..5533c135b0 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -3040,6 +3040,14 @@  create_wireless_algo_auth_cipher_operation(
 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
 			sgl_buf = sgl_buf->next;
 		}
+
+		/* The last segment should be large enough to hold full digest */
+		if (sgl_buf->data_len < auth_tag_len) {
+			rte_pktmbuf_free(sgl_buf->next);
+			sgl_buf->next = NULL;
+			rte_pktmbuf_append(sgl_buf, auth_tag_len - sgl_buf->data_len);
+		}
+
 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
 				uint8_t *, remaining_off);
 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,