DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] bonding: fix overflow check
@ 2021-04-22  9:22 Min Hu (Connor)
  2021-04-26 15:08 ` Ferruh Yigit
  2021-04-27  1:40 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
  0 siblings, 2 replies; 7+ messages in thread
From: Min Hu (Connor) @ 2021-04-22  9:22 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, humin29

Buffer 'test_params->slave_port_ids' of size 6 accessed may
overflow, since its index 'i' can have value be is out of range.

This patch fixed it.

Fixes: 92073ef961ee ("bond: unit tests")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 app/test/test_link_bonding.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 8a5c831..b5a6042 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -2216,7 +2216,8 @@ test_activebackup_rx_burst(void)
 			"failed to get primary slave for bonded port (%d)",
 			test_params->bonded_port_id);
 
-	for (i = 0; i < test_params->bonded_slave_count; i++) {
+	for (i = 0; i < test_params->bonded_slave_count &&
+		i < TEST_MAX_NUMBER_OF_PORTS; i++) {
 		/* Generate test bursts of packets to transmit */
 		TEST_ASSERT_EQUAL(generate_test_burst(
 				&gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0),
-- 
2.7.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] bonding: fix overflow check
  2021-04-22  9:22 [dpdk-dev] [PATCH] bonding: fix overflow check Min Hu (Connor)
@ 2021-04-26 15:08 ` Ferruh Yigit
  2021-04-27  1:41   ` Min Hu (Connor)
  2021-04-27  1:40 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
  1 sibling, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2021-04-26 15:08 UTC (permalink / raw)
  To: Min Hu (Connor), dev

On 4/22/2021 10:22 AM, Min Hu (Connor) wrote:
> Buffer 'test_params->slave_port_ids' of size 6 accessed may
> overflow, since its index 'i' can have value be is out of range.
> 
> This patch fixed it.
> 
> Fixes: 92073ef961ee ("bond: unit tests")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>  app/test/test_link_bonding.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
> index 8a5c831..b5a6042 100644
> --- a/app/test/test_link_bonding.c
> +++ b/app/test/test_link_bonding.c
> @@ -2216,7 +2216,8 @@ test_activebackup_rx_burst(void)
>  			"failed to get primary slave for bonded port (%d)",
>  			test_params->bonded_port_id);
>  
> -	for (i = 0; i < test_params->bonded_slave_count; i++) {
> +	for (i = 0; i < test_params->bonded_slave_count &&
> +		i < TEST_MAX_NUMBER_OF_PORTS; i++) {
>  		/* Generate test bursts of packets to transmit */
>  		TEST_ASSERT_EQUAL(generate_test_burst(
>  				&gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0),
> 

Hi Connor,

There is nothing wrong with the check you add, but at first place how
'test_params->bonded_slave_count' can become bigger than
'TEST_MAX_NUMBER_OF_PORTS'? Should we fix there, instead of this loop?

Also in same function, there are a few more loops iterate until " <
test_params->bonded_slave_count", so fixing the root case works for them too.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH v2] bonding: fix overflow check
  2021-04-22  9:22 [dpdk-dev] [PATCH] bonding: fix overflow check Min Hu (Connor)
  2021-04-26 15:08 ` Ferruh Yigit
@ 2021-04-27  1:40 ` Min Hu (Connor)
  2021-04-29 13:33   ` Ferruh Yigit
  1 sibling, 1 reply; 7+ messages in thread
From: Min Hu (Connor) @ 2021-04-27  1:40 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit

Buffer 'test_params->slave_port_ids' of size 6 accessed may
overflow, since its index 'i' can have value be is out of range.

This patch fixed it.

Fixes: 92073ef961ee ("bond: unit tests")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
v2:
* fix bonded_slave_count value.
---
 app/test/test_link_bonding.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 8a5c831..f8abb22 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -2216,6 +2216,9 @@ test_activebackup_rx_burst(void)
 			"failed to get primary slave for bonded port (%d)",
 			test_params->bonded_port_id);
 
+	if (test_params->bonded_slave_count > TEST_MAX_NUMBER_OF_PORTS)
+		test_params->bonded_slave_count = TEST_MAX_NUMBER_OF_PORTS;
+
 	for (i = 0; i < test_params->bonded_slave_count; i++) {
 		/* Generate test bursts of packets to transmit */
 		TEST_ASSERT_EQUAL(generate_test_burst(
-- 
2.7.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] bonding: fix overflow check
  2021-04-26 15:08 ` Ferruh Yigit
@ 2021-04-27  1:41   ` Min Hu (Connor)
  0 siblings, 0 replies; 7+ messages in thread
From: Min Hu (Connor) @ 2021-04-27  1:41 UTC (permalink / raw)
  To: Ferruh Yigit, dev



在 2021/4/26 23:08, Ferruh Yigit 写道:
> On 4/22/2021 10:22 AM, Min Hu (Connor) wrote:
>> Buffer 'test_params->slave_port_ids' of size 6 accessed may
>> overflow, since its index 'i' can have value be is out of range.
>>
>> This patch fixed it.
>>
>> Fixes: 92073ef961ee ("bond: unit tests")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>>   app/test/test_link_bonding.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
>> index 8a5c831..b5a6042 100644
>> --- a/app/test/test_link_bonding.c
>> +++ b/app/test/test_link_bonding.c
>> @@ -2216,7 +2216,8 @@ test_activebackup_rx_burst(void)
>>   			"failed to get primary slave for bonded port (%d)",
>>   			test_params->bonded_port_id);
>>   
>> -	for (i = 0; i < test_params->bonded_slave_count; i++) {
>> +	for (i = 0; i < test_params->bonded_slave_count &&
>> +		i < TEST_MAX_NUMBER_OF_PORTS; i++) {
>>   		/* Generate test bursts of packets to transmit */
>>   		TEST_ASSERT_EQUAL(generate_test_burst(
>>   				&gen_pkt_burst[0], burst_size, 0, 1, 0, 0, 0),
>>
> 
> Hi Connor,
> 
> There is nothing wrong with the check you add, but at first place how
> 'test_params->bonded_slave_count' can become bigger than
> 'TEST_MAX_NUMBER_OF_PORTS'? Should we fix there, instead of this loop?
> 
> Also in same function, there are a few more loops iterate until " <
> test_params->bonded_slave_count", so fixing the root case works for them too.
> 
Hi, fixed in v2, thanks.
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] bonding: fix overflow check
  2021-04-27  1:40 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
@ 2021-04-29 13:33   ` Ferruh Yigit
  2021-04-30  2:54     ` Min Hu (Connor)
  0 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2021-04-29 13:33 UTC (permalink / raw)
  To: Min Hu (Connor), dev

On 4/27/2021 2:40 AM, Min Hu (Connor) wrote:
> Buffer 'test_params->slave_port_ids' of size 6 accessed may
> overflow, since its index 'i' can have value be is out of range.
> 
> This patch fixed it.
> 
> Fixes: 92073ef961ee ("bond: unit tests")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
> v2:
> * fix bonded_slave_count value.
> ---
>  app/test/test_link_bonding.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
> index 8a5c831..f8abb22 100644
> --- a/app/test/test_link_bonding.c
> +++ b/app/test/test_link_bonding.c
> @@ -2216,6 +2216,9 @@ test_activebackup_rx_burst(void)
>  			"failed to get primary slave for bonded port (%d)",
>  			test_params->bonded_port_id);
>  
> +	if (test_params->bonded_slave_count > TEST_MAX_NUMBER_OF_PORTS)
> +		test_params->bonded_slave_count = TEST_MAX_NUMBER_OF_PORTS;
> +

Hi Connor,

Similar comment as previous version, what is the root cause, how
'bonded_slave_count' end up being bigger than 'TEST_MAX_NUMBER_OF_PORTS'?

>  	for (i = 0; i < test_params->bonded_slave_count; i++) {
>  		/* Generate test bursts of packets to transmit */
>  		TEST_ASSERT_EQUAL(generate_test_burst(
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] bonding: fix overflow check
  2021-04-29 13:33   ` Ferruh Yigit
@ 2021-04-30  2:54     ` Min Hu (Connor)
  2021-04-30  9:30       ` Ferruh Yigit
  0 siblings, 1 reply; 7+ messages in thread
From: Min Hu (Connor) @ 2021-04-30  2:54 UTC (permalink / raw)
  To: Ferruh Yigit, dev



在 2021/4/29 21:33, Ferruh Yigit 写道:
> On 4/27/2021 2:40 AM, Min Hu (Connor) wrote:
>> Buffer 'test_params->slave_port_ids' of size 6 accessed may
>> overflow, since its index 'i' can have value be is out of range.
>>
>> This patch fixed it.
>>
>> Fixes: 92073ef961ee ("bond: unit tests")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>> v2:
>> * fix bonded_slave_count value.
>> ---
>>   app/test/test_link_bonding.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
>> index 8a5c831..f8abb22 100644
>> --- a/app/test/test_link_bonding.c
>> +++ b/app/test/test_link_bonding.c
>> @@ -2216,6 +2216,9 @@ test_activebackup_rx_burst(void)
>>   			"failed to get primary slave for bonded port (%d)",
>>   			test_params->bonded_port_id);
>>   
>> +	if (test_params->bonded_slave_count > TEST_MAX_NUMBER_OF_PORTS)
>> +		test_params->bonded_slave_count = TEST_MAX_NUMBER_OF_PORTS;
>> +
> 
> Hi Connor,
> 
> Similar comment as previous version, what is the root cause, how
> 'bonded_slave_count' end up being bigger than 'TEST_MAX_NUMBER_OF_PORTS'?
> 
Hi Ferruh,
Currently, it will not happen.
But if the testcase extended, for instance,
"test_add_slave_to_bonded_device" is called over
TEST_MAX_NUMBER_OF_PORTS(6) times in
"test_add_already_bonded_slave_to_bonded_device",
then 'bonded_slave_count' will be bigger than
'TEST_MAX_NUMBER_OF_PORTS'.

>>   	for (i = 0; i < test_params->bonded_slave_count; i++) {
>>   		/* Generate test bursts of packets to transmit */
>>   		TEST_ASSERT_EQUAL(generate_test_burst(
>>
> 
> .
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] bonding: fix overflow check
  2021-04-30  2:54     ` Min Hu (Connor)
@ 2021-04-30  9:30       ` Ferruh Yigit
  0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2021-04-30  9:30 UTC (permalink / raw)
  To: Min Hu (Connor), dev

On 4/30/2021 3:54 AM, Min Hu (Connor) wrote:
> 
> 
> 在 2021/4/29 21:33, Ferruh Yigit 写道:
>> On 4/27/2021 2:40 AM, Min Hu (Connor) wrote:
>>> Buffer 'test_params->slave_port_ids' of size 6 accessed may
>>> overflow, since its index 'i' can have value be is out of range.
>>>
>>> This patch fixed it.
>>>
>>> Fixes: 92073ef961ee ("bond: unit tests")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>> ---
>>> v2:
>>> * fix bonded_slave_count value.
>>> ---
>>>   app/test/test_link_bonding.c | 3 +++
>>>   1 file changed, 3 insertions(+)
>>>
>>> diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
>>> index 8a5c831..f8abb22 100644
>>> --- a/app/test/test_link_bonding.c
>>> +++ b/app/test/test_link_bonding.c
>>> @@ -2216,6 +2216,9 @@ test_activebackup_rx_burst(void)
>>>               "failed to get primary slave for bonded port (%d)",
>>>               test_params->bonded_port_id);
>>>   +    if (test_params->bonded_slave_count > TEST_MAX_NUMBER_OF_PORTS)
>>> +        test_params->bonded_slave_count = TEST_MAX_NUMBER_OF_PORTS;
>>> +
>>
>> Hi Connor,
>>
>> Similar comment as previous version, what is the root cause, how
>> 'bonded_slave_count' end up being bigger than 'TEST_MAX_NUMBER_OF_PORTS'?
>>
> Hi Ferruh,
> Currently, it will not happen.
> But if the testcase extended, for instance,
> "test_add_slave_to_bonded_device" is called over
> TEST_MAX_NUMBER_OF_PORTS(6) times in
> "test_add_already_bonded_slave_to_bonded_device",
> then 'bonded_slave_count' will be bigger than
> 'TEST_MAX_NUMBER_OF_PORTS'.
> 

What do you think adding 'test_params->bonded_slave_count' check at the
beginning of the 'test_add_slave_to_bonded_device()' and fail test case if it is
bigger than 'TEST_MAX_NUMBER_OF_PORTS'?

>>>       for (i = 0; i < test_params->bonded_slave_count; i++) {
>>>           /* Generate test bursts of packets to transmit */
>>>           TEST_ASSERT_EQUAL(generate_test_burst(
>>>
>>
>> .
>>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-04-30  9:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22  9:22 [dpdk-dev] [PATCH] bonding: fix overflow check Min Hu (Connor)
2021-04-26 15:08 ` Ferruh Yigit
2021-04-27  1:41   ` Min Hu (Connor)
2021-04-27  1:40 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
2021-04-29 13:33   ` Ferruh Yigit
2021-04-30  2:54     ` Min Hu (Connor)
2021-04-30  9:30       ` Ferruh Yigit

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).