examples/l3fwd-acl:memset the acl matching result array

Message ID 20220125072915.17083-1-chenzhiheng0227@gmail.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series examples/l3fwd-acl:memset the acl matching result array |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-abi-testing warning Testing issues

Commit Message

Zhiheng Chen Jan. 25, 2022, 7:29 a.m. UTC
  If we don't memset acl result array before matching,
we can get arbitrary dirty data from memory.

Signed-off-by: Zhiheng Chen <chenzhiheng0227@gmail.com>
---
 examples/l3fwd-acl/main.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Ananyev, Konstantin Jan. 25, 2022, 2:02 p.m. UTC | #1
> If we don't memset acl result array before matching,
> we can get arbitrary dirty data from memory.

I don't think it is the case.
acl_classify() on successful completion will always populate result array.
The only exception - user provided ivalid input parameters, or acl ctx is not build, etc.
So no need to do memset() here.
 
> Signed-off-by: Zhiheng Chen <chenzhiheng0227@gmail.com>
> ---
>  examples/l3fwd-acl/main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
> index 1fb1807235..7b9539b3ca 100644
> --- a/examples/l3fwd-acl/main.c
> +++ b/examples/l3fwd-acl/main.c
> @@ -738,6 +738,9 @@ prepare_acl_parameter(struct rte_mbuf **pkts_in, struct acl_search_t *acl,
>  	acl->num_ipv4 = 0;
>  	acl->num_ipv6 = 0;
> 
> +	memset(acl->res_ipv4, 0, sizeof(acl->res_ipv4));
> +	memset(acl->res_ipv6, 0, sizeof(acl->res_ipv6));
> +
>  	/* Prefetch first packets */
>  	for (i = 0; i < PREFETCH_OFFSET && i < nb_rx; i++) {
>  		rte_prefetch0(rte_pktmbuf_mtod(
> --
> 2.32.0
  

Patch

diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 1fb1807235..7b9539b3ca 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -738,6 +738,9 @@  prepare_acl_parameter(struct rte_mbuf **pkts_in, struct acl_search_t *acl,
 	acl->num_ipv4 = 0;
 	acl->num_ipv6 = 0;
 
+	memset(acl->res_ipv4, 0, sizeof(acl->res_ipv4));
+	memset(acl->res_ipv6, 0, sizeof(acl->res_ipv6));
+
 	/* Prefetch first packets */
 	for (i = 0; i < PREFETCH_OFFSET && i < nb_rx; i++) {
 		rte_prefetch0(rte_pktmbuf_mtod(