net/i40e: fix out of bounds read issue
PATCH 1/1 net/i40e: fix out of bounds read issue
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694
--- drivers/net/i40e/i40e_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +2 -2
@@ -13180,7 +13180,7 @@ i40e_rss_config_hash_function(struct i40e_pf *pf, }for (j =I40E_FILTER_PCTYPE_INVALID +1 ; - j <I40E_FILTER_PCTYPE_MAX ; j++) { + j <I40E_FILTER_PCTYPE_MAX && i <UINT64_BIT ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) i40e_write_global_rx_ctl(hw, I40E_GLQF_HSYM(j),
@@ -13312,7 +13312,7 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf, }for (j =I40E_FILTER_PCTYPE_INVALID +1 ; - j <I40E_FILTER_PCTYPE_MAX ; j++) { + j <I40E_FILTER_PCTYPE_MAX && i <UINT64_BIT ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) i40e_write_global_rx_ctl(hw, I40E_GLQF_HSYM(j),
Signature · 1 line
2.17.1
Quoted 16 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSS flow")Signed-off-by Chenxu Di <[email protected]>---
drivers/net/i40e/i40e_ethdev.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/i40e/i40e_ethdev.c +0
-0
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13183
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c +1
-1@@ -13180,7 +13180,7 @@ i40e_rss_config_hash_function(struct i40e_pf *pf, }for (j =I40E_FILTER_PCTYPE_INVALID +1 ; - j <I40E_FILTER_PCTYPE_MAX ; j++) { + j <I40E_FILTER_PCTYPE_MAX && i <UINT64_BIT ; j++) {
I see i is defined as uint32_t, why compare it to UINT64_BIT here? And could you specify where is the out of bounds read before the fix?
Quoted 15 lines
drivers/net/i40e/i40e_ethdev.c +1
-1if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) i40e_write_global_rx_ctl(hw, I40E_GLQF_HSYM(j),@@ -13312,7 +13312,7 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf, }for (j =I40E_FILTER_PCTYPE_INVALID +1 ; - j <I40E_FILTER_PCTYPE_MAX ; j++) { + j <I40E_FILTER_PCTYPE_MAX && i <UINT64_BIT ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) i40e_write_global_rx_ctl(hw, I40E_GLQF_HSYM(j),Signature · 1 line
2.17.1
Hi, xiaolong
Quoted 27 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Thursday, May 7, 2020 1:15 PM
To: Di, ChenxuX <[email protected]>
Cc: [email protected]; Xing, Beilei <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix out of bounds read issueQuoted 19 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSSflow")
Signed-off-by Chenxu Di <[email protected]>---
drivers/net/i40e/i40e_ethdev.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex749d85f54..6c295ac5a100644drivers/net/i40e/i40e_ethdev.c +0
-0@@ -13180,7 +13180,7 @@ i40e_rss_config_hash_function(struct i40e_pf *pf, }
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13183
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +1
-1for (j =I40E_FILTER_PCTYPE_INVALID +1 ; - j <I40E_FILTER_PCTYPE_MAX ; j++) { + j <I40E_FILTER_PCTYPE_MAX && i <UINT64_BIT ; j++) {I see i is defined as
uint32_t, why compare it toUINT64_BIThere? And could you specify where is the out of bounds read before the fix?
The UINT64_BIT is the define of 64. And i is just used as the index of pctypes_tbl[]. And the code is just copy the function i40e_set_hash_filter_global_config(), So I don't why he use the define UINT64_BIT as the value 64.
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13184
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +0
-0if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
the out of bounds read is the pctypes_tbl[i]. the above code is that :
for (i = RTE_ETH_FLOW_UNKNOWN + 1; i < UINT64_BIT; i++) {
if (mask0 & (1UL << i))
break;
}If the loop doesn't break; the value of i will be 64 while the length of pctypes_tbl[] is 64.
Quoted 14 lines
Quoted 14 lines
drivers/net/i40e/i40e_ethdev.c +1
-2i40e_write_global_rx_ctl(hw, I40E_GLQF_HSYM(j),@@ -13312,7 +13312,7 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf, }for (j =I40E_FILTER_PCTYPE_INVALID +1 ; - j <I40E_FILTER_PCTYPE_MAX ; j++) { + j <I40E_FILTER_PCTYPE_MAX && i <UINT64_BIT ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) i40e_write_global_rx_ctl(hw, I40E_GLQF_HSYM(j), --2.17.1
Quoted 43 lines · ChenxuX
Hi, xiaolong
Quoted 27 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Thursday, May 7, 2020 1:15 PM
To: Di, ChenxuX <[email protected]>
Cc: [email protected]; Xing, Beilei <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix out of bounds read issueQuoted 19 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSSflow")
Signed-off-by Chenxu Di <[email protected]>---
drivers/net/i40e/i40e_ethdev.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex749d85f54..6c295ac5a100644drivers/net/i40e/i40e_ethdev.c +0
-0@@ -13180,7 +13180,7 @@ i40e_rss_config_hash_function(struct i40e_pf *pf, }Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13183
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +1
-1for (j =I40E_FILTER_PCTYPE_INVALID +1 ; - j <I40E_FILTER_PCTYPE_MAX ; j++) { + j <I40E_FILTER_PCTYPE_MAX && i <UINT64_BIT ; j++) {I see i is defined as
uint32_t, why compare it toUINT64_BIThere? And could you specify where is the out of bounds read before the fix?The
UINT64_BITis the define of 64. And i is just used as the index of pctypes_tbl[]. And the code is just copy the functioni40e_set_hash_filter_global_config(), So I don't why he use the defineUINT64_BITas the value 64.Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13184
Quoted 2 lines
drivers/net/i40e/i40e_ethdev.c +0
-0if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
Quoted 7 lines
the out of bounds read is the pctypes_tbl[i]. the above code is that :
for (i = RTE_ETH_FLOW_UNKNOWN + 1; i < UINT64_BIT; i++) { if (mask0 & (1UL << i)) break; }If the loop doesn't break; the value of i will be 64 while the length of pctypes_tbl[] is 64.
Got it, can you move the i < UINT64_BIT check before the new for loop, so it doesn't need to check it everytime?
Thanks,
Xiaolong
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/net/i40e/i40e_ethdev.c +1
-2i40e_write_global_rx_ctl(hw, I40E_GLQF_HSYM(j),@@ -13312,7 +13312,7 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf, }for (j =I40E_FILTER_PCTYPE_INVALID +1 ; - j <I40E_FILTER_PCTYPE_MAX ; j++) { + j <I40E_FILTER_PCTYPE_MAX && i <UINT64_BIT ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) i40e_write_global_rx_ctl(hw, I40E_GLQF_HSYM(j), --2.17.1
PATCH v2 1/1 net/i40e: fix out of bounds read issue
In reply to Chenxu DiThis patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694
--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/i40e/i40e_ethdev.c +6 -0
@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
Signature · 1 line
2.17.1
Nacked by: Qiming Yang <[email protected]>
Quoted 48 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenxu Di
Sent: Thursday, May 7, 2020 17:50
To: [email protected]
Cc: Di, ChenxuX <[email protected]>
Subject: [dpdk-dev] [PATCH v2] net/i40e: fix out of bounds read issueThis patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSS flow")Signed-off-by Chenxu Di <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/i40e/i40e_ethdev.c +3
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf, break; } +if (i ==UINT64_BIT ) +return 0 ; +drivers/net/i40e/i40e_ethdev.c +0
-0for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) { if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) @@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct
i40e_pf*pf,drivers/net/i40e/i40e_ethdev.c +3
-1break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) --2.17.1
Hi, Qiming
Quoted 1 line · Qiming
Nacked by: Qiming Yang <[email protected]>
Could you post the reason why you nack this patch?
Thanks,
Xiaolong
Quoted 50 lines
Quoted 49 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenxu Di
Sent: Thursday, May 7, 2020 17:50
To: [email protected]
Cc: Di, ChenxuX <[email protected]>
Subject: [dpdk-dev] [PATCH v2] net/i40e: fix out of bounds read issueThis patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSS flow")Signed-off-by Chenxu Di <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/i40e/i40e_ethdev.c +3
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf, break; } +if (i ==UINT64_BIT ) +return 0 ; +drivers/net/i40e/i40e_ethdev.c +0
-0for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) { if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) @@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct
i40e_pf*pf,drivers/net/i40e/i40e_ethdev.c +3
-1break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) --2.17.1
Hi, Xiaolong
I reviewed that function, it need rework, not only this coverity issue, the logical was wrong.
Qiming
Quoted 68 lines
-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Friday, May 8, 2020 10:36
To: Yang, Qiming <[email protected]>
Cc: Di, ChenxuX <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix out of bounds read issueHi, Qiming
Quoted 1 line · Qiming
Nacked by: Qiming Yang <[email protected]>
Could you post the reason why you nack this patch?
Thanks,
XiaolongQuoted 51 lines
Quoted 50 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenxu Di
Sent: Thursday, May 7, 2020 17:50
To: [email protected]
Cc: Di, ChenxuX <[email protected]>
Subject: [dpdk-dev] [PATCH v2] net/i40e: fix out of bounds read issueThis patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSSflow")
Signed-off-by Chenxu Di <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex749d85f54..c2d5c6835100644drivers/net/i40e/i40e_ethdev.c +3
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf, break; } +if (i ==UINT64_BIT ) +return 0 ; +drivers/net/i40e/i40e_ethdev.c +0
-0for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) { if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) @@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct
i40e_pf*pf,drivers/net/i40e/i40e_ethdev.c +3
-1break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) --2.17.1
PATCH v3 1/1 net/i40e: fix out of bounds read issue
In reply to Chenxu DiThis patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694
--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/i40e/i40e_ethdev.c +6 -0
@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
Signature · 1 line
2.17.1
hi, chenxu
Quoted 16 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSS flow")Signed-off-by Chenxu Di <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/i40e/i40e_ethdev.c +0
-0
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13184
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c +3
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return 0 ; +
Should this function need to return none zero value and show error info out, or said should considerate "out of bound" as a configure failed.
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +3
-0for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
Hi,
Quoted 30 lines
-----Original Message-----
From: Guo, Jia
Sent: Wednesday, May 13, 2020 2:51 PM
To: Di, ChenxuX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>
Subject: Re: [PATCH v3] net/i40e: fix out of bounds read issuehi, chenxu
Quoted 20 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSSflow")
Signed-off-by Chenxu Di <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex749d85f54..c2d5c6835100644drivers/net/i40e/i40e_ethdev.c +0
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,break ; }
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13184
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+if (i ==UINT64_BIT ) +return 0 ; +Should this function need to return none zero value and show error info out, or said should considerate "out of bound" as a configure failed.
It will just find the flow type and do the things. If not find the flow type, it just do nothing and return.
Quoted 14 lines
Quoted 14 lines
drivers/net/i40e/i40e_ethdev.c +3
-0for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
Quoted 34 lines · ChenxuX
Hi,
Quoted 30 lines
-----Original Message-----
From: Guo, Jia
Sent: Wednesday, May 13, 2020 2:51 PM
To: Di, ChenxuX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>
Subject: Re: [PATCH v3] net/i40e: fix out of bounds read issuehi, chenxu
Quoted 20 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSSflow")
Signed-off-by Chenxu Di <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex749d85f54..c2d5c6835100644drivers/net/i40e/i40e_ethdev.c +0
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,break ; }
Quoted 8 lines
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13184
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+if (i ==UINT64_BIT ) +return 0 ; +Should this function need to return none zero value and show error info out, or said should considerate "out of bound" as a configure failed.
It will just find the flow type and do the things. If not find the flow type, it just do nothing and return.
i40e_rss_config_hash_function is return int value right, should it always return 0? Should the case of not finding be considerate as none-success config?
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c +3
-0for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
Hi
Quoted 51 lines
-----Original Message-----
From: Guo, Jia
Sent: Thursday, May 14, 2020 2:17 PM
To: Di, ChenxuX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>
Subject: Re: [PATCH v3] net/i40e: fix out of bounds read issueQuoted 26 lines · ChenxuX
Hi,
Quoted 22 lines
-----Original Message-----
From: Guo, Jia
Sent: Wednesday, May 13, 2020 2:51 PM
To: Di, ChenxuX <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>
Subject: Re: [PATCH v3] net/i40e: fix out of bounds read issuehi, chenxu
Quoted 12 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSSflow")
Signed-off-by Chenxu Di <[email protected]>--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)Quoted 5 lines
Quoted 5 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf
Quoted 5 lines
(quoted diff) +0
-0
b/drivers/net/i40e/i40e_ethdev.cindex749d85f54..c2d5c6835100644drivers/net/i40e/i40e_ethdev.c +0
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf*pf,
Quoted 10 lines
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf, · line 13184
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c +3
-0break ; } +if (i ==UINT64_BIT ) +return 0 ; +Should this function need to return none zero value and show error info out, or said should considerate "out of bound" as a configure failed.
Quoted 7 lines
Quoted 1 line
It will just find the flow type and do the things. If not find the flow type, it just
do nothing and return.
i40e_rss_config_hash_functionis return int value right, should it always return 0? Should the case of not finding be considerate as none-success config?
The original code has too many tabs (for->if->for->if ), it is over 90 words per line. So just break and move it out .
After break the loop,
if the first loop go to the end without break, the value i will be 64 while the length of pf->adapter->pctypes_tbl is 64. That is the reason of the out of bound which the original code will not cause.
Actually it will not happen the case of not finding. It is just the code fix the out of bound caused by breaking the loop .
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c i40e_rss_config_hash_function(struct i40e_pf *pf,
Quoted 4 lines
drivers/net/i40e/i40e_ethdev.c +0
-0for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) { if (pf->adapter->pctypes_tbl[i] & (1ULL << j)) @@ -13311,6
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
+13314,9 @@ i40e_rss_clear_hash_function(struct
i40e_pf*pf,break; }drivers/net/i40e/i40e_ethdev.c +3
-0+if (i ==UINT64_BIT ) +return 0 ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
PATCH v4 1/1 net/i40e: fix out of bounds read issue
In reply to Chenxu DiThis patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694
---
v4:
-Updated the return value.
--- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/i40e/i40e_ethdev.c +6 -0
@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return -EINVAL ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return -EINVAL ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
Signature · 1 line
2.17.1
Quoted 29 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSS flow")Signed-off-by Chenxu Di <[email protected]>---
v4:(quoted diff) +0
-2-Updated the return value. --- drivers/net/i40e/i40e_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/i40e/i40e_ethdev.c +3
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return -EINVAL ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
drivers/net/i40e/i40e_ethdev.c i40e_rss_clear_hash_function(struct i40e_pf *pf, · line 13322
Quoted 9 lines
drivers/net/i40e/i40e_ethdev.c +3
-0@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return -EINVAL ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))
Ye Xiaolong
AppliedMinor nit: 'issue' doesn't need to be mentioned in the commit title, since the 'fix' implies something is broken.
Quoted 41 lines · Chenxu Di
This patch fixes (out-of-bounds read) coverity issue.
Coverity issue: 357699
Coverity issue: 357694Fixes feaae285b342 ("net/i40e: support hash configuration in RSS flow")Signed-off-by Chenxu Di <[email protected]>---
v4:
-Updated the return value.
---drivers/net/i40e/i40e_ethdev.c| 6 ++++++1 file changed, 6 insertions(+)drivers/net/i40e/i40e_ethdev.c +6
-0@@ -13179,6 +13179,9 @@ i40e_rss_config_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return -EINVAL ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))@@ -13311,6 +13314,9 @@ i40e_rss_clear_hash_function(struct i40e_pf *pf,break ; } +if (i ==UINT64_BIT ) +return -EINVAL ; +for (j =I40E_FILTER_PCTYPE_INVALID +1 ; j <I40E_FILTER_PCTYPE_MAX ; j++) {if (pf->adapter->pctypes_tbl[i] & (1ULL << j))Signature · 1 line
2.17.1
Applied to dpdk-next-net-intel, Thanks.