Skip to contentSkip to conversation

fix bugs for librte eal

PATCH Superseded Min Hu (Connor) 5 participants 15 messages Apr 21, 2021 – May 5, 2021

lore
Share & tools
lore
#0 lore raw

cover fix bugs for librte eal

This patchset fixed some bugs for librte_eal.

Chengwen Feng (2):
eal: check mp reply result
eal: fix service core index validity

 lib/librte_eal/common/eal_common_options.c | 2 ++
 lib/librte_eal/common/malloc_mp.c          | 4 +---
 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 eal: check mp reply result

From: Chengwen Feng <[email protected]>

This patch adds checking for mp reply result in handle_sync().

Fixes 07dcbfe0101f ("malloc: support multiprocess memory hotplug")
---
 lib/librte_eal/common/malloc_mp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/librte_eal/common/malloc_mp.c +1 -3
index c7101b3..2e597a1 100644
@@ -171,9 +171,7 @@ handle_sync(const struct rte_mp_msg *msg, const void *peer)
 	resp->id = req->id;
 	resp->result = ret == 0 ? REQ_RESULT_SUCCESS : REQ_RESULT_FAIL;
 
-	rte_mp_reply(&reply, peer);
-
-	return 0;
+	return rte_mp_reply(&reply, peer);
 }
 
 static int
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 eal: fix service core index validity

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

This patch adds checking for service core index validity when parsing service corelist.

Fixes 7dbd7a6413ef ("service: add -S corelist option")
---
 lib/librte_eal/common/eal_common_options.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_options.c +2 -0
index 66f9114..b4da878 100644
@@ -785,6 +785,8 @@ eal_parse_service_corelist(const char *corelist)
 		idx = strtoul(corelist, &end, 10);
 		if (errno || end == NULL)
 			return -1;
+		if (idx < 0 || idx >= RTE_MAX_LCORE)
+			return -1;
 		while (isblank(*end))
 			end++;
 		if (*end == '-') {
Signature · 1 line
2.7.4
#3 lore raw

Re: [dpdk-dev] [PATCH 2/2] eal: fix service core index validity

lib/librte_eal/common/eal_common_options.c eal_parse_service_corelist(const char *corelist) · line 788

Quoted 4 lines · On Wed, 21 Apr 2021 09:17:17 +0800 "Min Hu (Connor)" <[email protected]> wrote:
lib/librte_eal/common/eal_common_options.c +1 -0
 		idx = strtoul(corelist, &end, 10);
 		if (errno || end == NULL)
 			return -1;
+		if (idx < 0 || idx >= RTE_MAX_LCORE)

Wondered at first how strtoul() could ever return an negative value but then noticed that idx is int here.

The code that does would be clearer and safer if the variables were an unsigned type. idx, min, max should be the same type everywhere.

Looks like the original code was written in old C style of "all the world's an int"

#4 lore raw

Re: [dpdk-dev] [PATCH 2/2] eal: fix service core index validity

Hi, fixed in v2, thanks.

Quoted 17 lines · Stephen Hemminger

lib/librte_eal/common/eal_common_options.c eal_parse_service_corelist(const char *corelist) · line 788

Quoted 4 lines · On Wed, 21 Apr 2021 09:17:17 +0800 "Min Hu (Connor)" <[email protected]> wrote:
  		idx = strtoul(corelist, &end, 10);
  		if (errno || end == NULL)
  			return -1;
lib/librte_eal/common/eal_common_options.c +1 -0
+		if (idx < 0 || idx >= RTE_MAX_LCORE)

Wondered at first how strtoul() could ever return an negative value but then noticed that idx is int here.

The code that does would be clearer and safer if the variables were an unsigned type. idx, min, max should be the same type everywhere.

Looks like the original code was written in old C style of "all the world's an int" .

#5 lore raw

v2 cover fix bugs for librte eal

In reply to Min Hu (Connor)

This patchset fixed some bugs for librte_eal.

Min Hu (Connor) (2):
eal: check mp reply result
eal: fix service core index validity
---
v2:
* set variables an unsigned type.

 lib/eal/common/eal_common_options.c | 6 ++++--
 lib/eal/common/malloc_mp.c          | 4 +---
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 1/2 eal: check mp reply result

This patch adds checking for mp reply result in handle_sync().

Fixes 07dcbfe0101f ("malloc: support multiprocess memory hotplug")
---
 lib/eal/common/malloc_mp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/eal/common/malloc_mp.c +1 -3
index c7101b3..2e597a1 100644
@@ -171,9 +171,7 @@ handle_sync(const struct rte_mp_msg *msg, const void *peer)
 	resp->id = req->id;
 	resp->result = ret == 0 ? REQ_RESULT_SUCCESS : REQ_RESULT_FAIL;
 
-	rte_mp_reply(&reply, peer);
-
-	return 0;
+	return rte_mp_reply(&reply, peer);
 }
 
 static int
Signature · 1 line
2.7.4
#7 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] eal: check mp reply result

+Cc Anatoly

29/04/2021 04:34, Min Hu (Connor):

Quoted 24 lines

This patch adds checking for mp reply result in handle_sync().

Fixes 07dcbfe0101f ("malloc: support multiprocess memory hotplug")
---
 lib/eal/common/malloc_mp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/eal/common/malloc_mp.c +1 -3
index c7101b3..2e597a1 100644
@@ -171,9 +171,7 @@ handle_sync(const struct rte_mp_msg *msg, const void *peer)
 	resp->id = req->id;
 	resp->result = ret == 0 ? REQ_RESULT_SUCCESS : REQ_RESULT_FAIL;
 
-	rte_mp_reply(&reply, peer);
-
-	return 0;
+	return rte_mp_reply(&reply, peer);
 }
#8 lore raw

PATCH v2 2/2 eal: fix service core index validity

In reply to Min Hu (Connor)

This patch adds checking for service core index validity when parsing service corelist.

Fixes 7dbd7a6413ef ("service: add -S corelist option")
---
 lib/eal/common/eal_common_options.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_options.c +4 -2
index 66f9114..97ab6e0 100644
@@ -758,10 +758,10 @@ static int
 eal_parse_service_corelist(const char *corelist)
 {
 	struct rte_config *cfg = rte_eal_get_configuration();
-	int i, idx = 0;
+	int i;
 	unsigned count = 0;
 	char *end = NULL;
-	int min, max;
+	uint32_t min, max, idx;
 	uint32_t taken_lcore_count = 0;
 
 	if (corelist == NULL)
@@ -785,6 +785,8 @@ eal_parse_service_corelist(const char *corelist)
 		idx = strtoul(corelist, &end, 10);
 		if (errno || end == NULL)
 			return -1;
+		if (idx >= RTE_MAX_LCORE)
+			return -1;
 		while (isblank(*end))
 			end++;
 		if (*end == '-') {
Signature · 1 line
2.7.4
#9 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] eal: fix service core index validity

+Cc Harry

29/04/2021 04:34, Min Hu (Connor):

Quoted 39 lines

This patch adds checking for service core index validity when parsing service corelist.

Fixes 7dbd7a6413ef ("service: add -S corelist option")
---
 lib/eal/common/eal_common_options.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_options.c +4 -2
index 66f9114..97ab6e0 100644
@@ -758,10 +758,10 @@ static int
 eal_parse_service_corelist(const char *corelist)
 {
 	struct rte_config *cfg = rte_eal_get_configuration();
-	int i, idx = 0;
+	int i;
 	unsigned count = 0;
 	char *end = NULL;
-	int min, max;
+	uint32_t min, max, idx;
 	uint32_t taken_lcore_count = 0;
 
 	if (corelist == NULL)
@@ -785,6 +785,8 @@ eal_parse_service_corelist(const char *corelist)
 		idx = strtoul(corelist, &end, 10);
 		if (errno || end == NULL)
 			return -1;
+		if (idx >= RTE_MAX_LCORE)
+			return -1;
 		while (isblank(*end))
 			end++;
 		if (*end == '-') {
#10 lore raw

v3 cover fix bugs for librte eal

In reply to Min Hu (Connor)

This patchset fixed some bugs for librte_eal.

v3:
* change patch's author
v2:
* set variables an unsigned type.

Chengwen Feng (2):
eal: check mp reply result
eal: fix service core index validity

 lib/eal/common/eal_common_options.c | 6 ++++--
 lib/eal/common/malloc_mp.c          | 4 +---
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.8.1
#11 lore raw

PATCH v3 1/2 eal: check mp reply result

This patch adds checking for mp reply result in handle_sync().

Fixes 07dcbfe0101f ("malloc: support multiprocess memory hotplug")

---
v2->v3:
* change patch's author

---
 lib/eal/common/malloc_mp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/eal/common/malloc_mp.c +1 -3
index c7101b3..2e597a1 100644
@@ -171,9 +171,7 @@ handle_sync(const struct rte_mp_msg *msg, const void *peer)
 	resp->id = req->id;
 	resp->result = ret == 0 ? REQ_RESULT_SUCCESS : REQ_RESULT_FAIL;
 
-	rte_mp_reply(&reply, peer);
-
-	return 0;
+	return rte_mp_reply(&reply, peer);
 }
 
 static int
Signature · 1 line
2.8.1
#12 lore raw

PATCH v3 2/2 eal: fix service core index validity

In reply to Chengwen Feng

This patch adds checking for service core index validity when parsing service corelist.

Fixes 7dbd7a6413ef ("service: add -S corelist option")

---
v2->v3:
* change patch's author

---
 lib/eal/common/eal_common_options.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_options.c +4 -2
index 66f9114..97ab6e0 100644
@@ -758,10 +758,10 @@ static int
 eal_parse_service_corelist(const char *corelist)
 {
 	struct rte_config *cfg = rte_eal_get_configuration();
-	int i, idx = 0;
+	int i;
 	unsigned count = 0;
 	char *end = NULL;
-	int min, max;
+	uint32_t min, max, idx;
 	uint32_t taken_lcore_count = 0;
 
 	if (corelist == NULL)
@@ -785,6 +785,8 @@ eal_parse_service_corelist(const char *corelist)
 		idx = strtoul(corelist, &end, 10);
 		if (errno || end == NULL)
 			return -1;
+		if (idx >= RTE_MAX_LCORE)
+			return -1;
 		while (isblank(*end))
 			end++;
 		if (*end == '-') {
Signature · 1 line
2.8.1
Acked-by on v3 2/2
#13 lore raw

Re: [dpdk-dev] [PATCH v3 2/2] eal: fix service core index validity

Quoted 10 lines

-----Original Message-----
From: Chengwen Feng <[email protected]>
Sent: Wednesday, May 5, 2021 5:10 AM
To: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Burakov, Anatoly <[email protected]>; Van Haaren, Harry <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: [PATCH v3 2/2] eal: fix service core index validity

Quoted 8 lines

This patch adds checking for service core index validity when parsing service corelist.

Fixes 7dbd7a6413ef ("service: add -S corelist option")

Thanks,

#14 lore raw

Re: [dpdk-dev] [PATCH v3 2/2] eal: fix service core index validity

05/05/2021 12:43, Van Haaren, Harry:

Quoted 8 lines

From: Chengwen Feng <[email protected]>

Quoted 7 lines

This patch adds checking for service core index validity when parsing service corelist.

Fixes 7dbd7a6413ef ("service: add -S corelist option")
Quoted 6 lines
Quoted 2 lines

Thanks,

Series applied, thanks.