Skip to contentSkip to conversation

app/testpmd: fix invalid memory access

PATCH Applied Qi Zhang 3 participants 4 messages May 7, 2018 – May 9, 2018

lore
Share & tools
lore

Qi Zhang

author
#0 lore raw

PATCH 1/1 app/testpmd: fix invalid memory access

When calulate memory size of an RTE_FLOW_ITEM_TYPE_RAW 's mask mask->length is not the real size of binary pattern, it should take spec->length, or memory size will be over counted (0xffff) and invalid memory be access during following memcpy.

Fixes d0ad8648b1c5 ("app/testpmd: fix RSS flow action configuration")
---
 app/test-pmd/config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
app/test-pmd/config.c +2 -1
index 16fc481ce..bcaf429c4 100644
@@ -1077,7 +1077,8 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
 		dst.raw = buf;
 		off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw),
 				     sizeof(*src.raw->pattern));
-		size = off + src.raw->length * sizeof(*src.raw->pattern);
+		size = off + ((const struct rte_flow_item_raw *)item->spec)->
+			length * sizeof(*src.raw->pattern);
 		if (dst.raw) {
 			memcpy(dst.raw, src.raw, sizeof(*src.raw));
 			dst.raw->pattern = memcpy((uint8_t *)dst.raw + off,
Signature · 1 line
2.13.6
#1 lore raw

Hi, zhang qi
This fix patch to DPDK.or is also useful for igb flex byte core dump issue.
I have validation it. But there is some patch check warning.
https://dpdk.org/dev/patchwork/patch/39417/

Quoted 37 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, May 7, 2018 5:51 PM
To: [email protected]
Cc: Peng, Yuan <[email protected]>; Zhao1, Wei <[email protected]>; [email protected]; Zhang, Qi Z <[email protected]>
Subject: [PATCH] app/testpmd: fix invalid memory access

When calulate memory size of an RTE_FLOW_ITEM_TYPE_RAW 's mask mask->length is not the real size of binary pattern, it should take spec->length, or memory size will be over counted (0xffff) and invalid memory be access during following memcpy.

Fixes d0ad8648b1c5 ("app/testpmd: fix RSS flow action configuration")
---
 app/test-pmd/config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

16fc481ce..bcaf429c4 100644

app/test-pmd/config.c +2 -1
@@ -1077,7 +1077,8 @@ flow_item_spec_copy(void *buf, const struct
 rte_flow_item *item,
 		dst.raw = buf;
 		off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw),
 				     sizeof(*src.raw->pattern));
-		size = off + src.raw->length * sizeof(*src.raw->pattern);
+		size = off + ((const struct rte_flow_item_raw *)item->spec)->
+			length * sizeof(*src.raw->pattern);
 		if (dst.raw) {
 			memcpy(dst.raw, src.raw, sizeof(*src.raw));

dst.raw->pattern = memcpy((uint8_t *)dst.raw + off,
--
2.13.6

#2 lore raw

Hi Zhao Wei:

Quoted 11 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Tuesday, May 8, 2018 2:24 PM
To: Zhang, Qi Z <[email protected]>; [email protected]
Cc: Peng, Yuan <[email protected]>; [email protected]
Subject: RE: [PATCH] app/testpmd: fix invalid memory access

Hi, zhang qi
This fix patch to DPDK.or is also useful for igb flex byte core dump issue.
I have validation it. But there is some patch check warning.
https://dpdk.org/dev/patchwork/patch/39417/

Thanks for testing, I will capture the typo if Adrien agree with the fix.

Regards
Qi

Quoted 41 lines
Quoted 8 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, May 7, 2018 5:51 PM
To: [email protected]
Cc: Peng, Yuan <[email protected]>; Zhao1, Wei

<[email protected]>;

Quoted 32 lines

[email protected]; Zhang, Qi Z <[email protected]>
Subject: [PATCH] app/testpmd: fix invalid memory access

When calulate memory size of an RTE_FLOW_ITEM_TYPE_RAW 's mask mask->length is not the real size of binary pattern, it should take spec->length, or memory size will be over counted (0xffff) and invalid memory be access during following memcpy.

Fixes d0ad8648b1c5 ("app/testpmd: fix RSS flow action configuration")
---
 app/test-pmd/config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

16fc481ce..bcaf429c4 100644

app/test-pmd/config.c +2 -1
@@ -1077,7 +1077,8 @@ flow_item_spec_copy(void *buf, const struct
 rte_flow_item *item,
 		dst.raw = buf;
 		off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw),
 				     sizeof(*src.raw->pattern));
-		size = off + src.raw->length * sizeof(*src.raw->pattern);
+		size = off + ((const struct rte_flow_item_raw *)item->spec)->
+			length * sizeof(*src.raw->pattern);
 		if (dst.raw) {
 			memcpy(dst.raw, src.raw, sizeof(*src.raw));

dst.raw->pattern = memcpy((uint8_t *)dst.raw + off,
--
2.13.6

#3 lore raw
In reply to Qi Zhang

07/05/2018 11:50, Qi Zhang:

Quoted 8 lines

When calulate memory size of an RTE_FLOW_ITEM_TYPE_RAW 's mask mask->length is not the real size of binary pattern, it should take spec->length, or memory size will be over counted (0xffff) and invalid memory be access during following memcpy.

Fixes d0ad8648b1c5 ("app/testpmd: fix RSS flow action configuration")

Applied, thanks