* [dpdk-stable] [PATCH v4 03/20] net/bnxt: fix out of bounds issue in hash list
[not found] ` <20211103005251.25524-1-ajit.khaparde@broadcom.com>
@ 2021-11-03 0:52 ` Ajit Khaparde
2021-11-03 0:52 ` [dpdk-stable] [PATCH v4 11/20] net/bnxt: fix clang compiler warnings Ajit Khaparde
[not found] ` <20211104215846.58672-1-ajit.khaparde@broadcom.com>
2 siblings, 0 replies; 4+ messages in thread
From: Ajit Khaparde @ 2021-11-03 0:52 UTC (permalink / raw)
To: dev
Cc: Kishore Padmanabha, stable, Venkat Duvvuru, Mike Baucom, Randy Schacher
[-- Attachment #1: Type: text/plain, Size: 3050 bytes --]
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
The number of hash bucket list calculation is fixed.
Added check to avoid the out of bounds condition.
Fixes: 0001cc58d362 ("net/bnxt: support generic hash table")
Cc: stable@dpdk.org
Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/tf_ulp/ulp_gen_hash.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
index 3c6e7fe924..84c83de35c 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
@@ -16,20 +16,21 @@ int32_t ulp_bit_alloc_list_alloc(struct bit_alloc_list *blist,
{
uint64_t bentry;
uint32_t idx = 0, jdx = 0;
+ uint32_t bsize_64 = blist->bsize / ULP_64B_IN_BYTES;
/* Iterate all numbers that have all 1's */
do {
bentry = blist->bdata[idx++];
- } while (bentry == -1UL && idx < blist->bsize);
+ } while (bentry == -1UL && idx <= bsize_64);
- if (idx < blist->bsize) {
+ if (idx <= bsize_64) {
if (bentry)
jdx = __builtin_clzl(~bentry);
*index = ((idx - 1) * ULP_INDEX_BITMAP_SIZE) + jdx;
ULP_INDEX_BITMAP_SET(blist->bdata[(idx - 1)], jdx);
return 0;
}
- jdx = (uint32_t)(blist->bsize * ULP_INDEX_BITMAP_SIZE);
+ jdx = (uint32_t)(bsize_64 * ULP_INDEX_BITMAP_SIZE);
BNXT_TF_DBG(ERR, "bit allocator is full reached max:%x\n", jdx);
return -1;
}
@@ -39,9 +40,10 @@ int32_t ulp_bit_alloc_list_dealloc(struct bit_alloc_list *blist,
uint32_t index)
{
uint32_t idx = 0, jdx;
+ uint32_t bsize_64 = blist->bsize / ULP_64B_IN_BYTES;
idx = index / ULP_INDEX_BITMAP_SIZE;
- if (idx >= blist->bsize) {
+ if (idx >= bsize_64) {
BNXT_TF_DBG(ERR, "invalid bit index %x:%x\n", idx,
blist->bsize);
return -EINVAL;
@@ -127,7 +129,8 @@ ulp_gen_hash_tbl_list_init(struct ulp_hash_create_params *cparams,
hash_tbl->hash_mask = size - 1;
/* allocate the memory for the bit allocator */
- size = (cparams->num_key_entries / sizeof(uint64_t)) + 1;
+ size = (cparams->num_key_entries / sizeof(uint64_t));
+ size = ULP_BYTE_ROUND_OFF_8(size);
hash_tbl->bit_list.bsize = size;
hash_tbl->bit_list.bdata = rte_zmalloc("Generic hash bit alloc", size,
ULP_BUFFER_ALIGN_64_BYTE);
@@ -311,7 +314,12 @@ ulp_gen_hash_tbl_list_add(struct ulp_gen_hash_tbl *hash_tbl,
BNXT_TF_DBG(ERR, "Error in bit list alloc\n");
return -ENOMEM;
}
-
+ if (key_index > hash_tbl->num_key_entries) {
+ BNXT_TF_DBG(ERR, "reached max size %u:%u\n", key_index,
+ hash_tbl->num_key_entries);
+ ulp_bit_alloc_list_dealloc(&hash_tbl->bit_list, key_index);
+ return -ENOMEM;
+ }
/* Update the hash entry */
ULP_HASH_BUCKET_MARK_INUSE(bucket, (uint16_t)key_index);
--
2.30.1 (Apple Git-130)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-stable] [PATCH v4 11/20] net/bnxt: fix clang compiler warnings
[not found] ` <20211103005251.25524-1-ajit.khaparde@broadcom.com>
2021-11-03 0:52 ` [dpdk-stable] [PATCH v4 03/20] net/bnxt: fix out of bounds issue in hash list Ajit Khaparde
@ 2021-11-03 0:52 ` Ajit Khaparde
2021-11-03 13:24 ` [dpdk-stable] [dpdk-dev] " Ferruh Yigit
[not found] ` <20211104215846.58672-1-ajit.khaparde@broadcom.com>
2 siblings, 1 reply; 4+ messages in thread
From: Ajit Khaparde @ 2021-11-03 0:52 UTC (permalink / raw)
To: dev; +Cc: Shahaji Bhosle, stable, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 1959 bytes --]
From: Shahaji Bhosle <sbhosle@broadcom.com>
Typecast flow_item type, action_item type and the ENUMs to uint32_t
before comparing.
Fixes: 53a0d4f7663 ("net/bnxt: support flow API item parsing")
Cc: stable@dpdk.org
Bugzilla ID: 821
Signed-off-by: Shahaji Bhosle <sbhosle@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index 605c29223c..d21c088d59 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -137,10 +137,10 @@ bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[],
/* Parse all the items in the pattern */
while (item && item->type != RTE_FLOW_ITEM_TYPE_END) {
- if (item->type >= (uint32_t)
+ if (item->type >= (typeof(item->type))
BNXT_RTE_FLOW_ITEM_TYPE_END) {
if (item->type >=
- (uint32_t)BNXT_RTE_FLOW_ITEM_TYPE_LAST)
+ (typeof(item->type))BNXT_RTE_FLOW_ITEM_TYPE_LAST)
goto hdr_parser_error;
/* get the header information */
hdr_info = &ulp_vendor_hdr_info[item->type -
@@ -186,9 +186,9 @@ bnxt_ulp_rte_parser_act_parse(const struct rte_flow_action actions[],
/* Parse all the items in the pattern */
while (action_item && action_item->type != RTE_FLOW_ACTION_TYPE_END) {
if (action_item->type >=
- (uint32_t)BNXT_RTE_FLOW_ACTION_TYPE_END) {
+ (typeof(action_item->type))BNXT_RTE_FLOW_ACTION_TYPE_END) {
if (action_item->type >=
- (uint32_t)BNXT_RTE_FLOW_ACTION_TYPE_LAST)
+ (typeof(action_item->type))BNXT_RTE_FLOW_ACTION_TYPE_LAST)
goto act_parser_error;
/* get the header information from bnxt actinfo table */
hdr_info = &ulp_vendor_act_info[action_item->type -
--
2.30.1 (Apple Git-130)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH v4 11/20] net/bnxt: fix clang compiler warnings
2021-11-03 0:52 ` [dpdk-stable] [PATCH v4 11/20] net/bnxt: fix clang compiler warnings Ajit Khaparde
@ 2021-11-03 13:24 ` Ferruh Yigit
0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2021-11-03 13:24 UTC (permalink / raw)
To: Ajit Khaparde, dev; +Cc: Shahaji Bhosle, stable, Venkat Duvvuru
On 11/3/2021 12:52 AM, Ajit Khaparde wrote:
> From: Shahaji Bhosle <sbhosle@broadcom.com>
>
> Typecast flow_item type, action_item type and the ENUMs to uint32_t
> before comparing.
>
> Fixes: 53a0d4f7663 ("net/bnxt: support flow API item parsing")
> Cc: stable@dpdk.org
Hi Ajit,
Is above Fixes commit correct? It is from v20.05.
As far as I can see the error comes from:
Fixes: bdf4a3c6316b ("net/bnxt: support tunnel offload")
if that is correct, stable tag is not needed.
>
> Bugzilla ID: 821
Can you please move the tag above 'Fixes' line?
> Signed-off-by: Shahaji Bhosle <sbhosle@broadcom.com>
> Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
<...>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-stable] [PATCH v5 03/22] net/bnxt: fix out of bounds issue in hash list
[not found] ` <20211104215846.58672-1-ajit.khaparde@broadcom.com>
@ 2021-11-04 21:58 ` Ajit Khaparde
0 siblings, 0 replies; 4+ messages in thread
From: Ajit Khaparde @ 2021-11-04 21:58 UTC (permalink / raw)
To: dev
Cc: Kishore Padmanabha, stable, Venkat Duvvuru, Mike Baucom, Randy Schacher
[-- Attachment #1: Type: text/plain, Size: 3050 bytes --]
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
The number of hash bucket list calculation is fixed.
Added check to avoid the out of bounds condition.
Fixes: 0001cc58d362 ("net/bnxt: support generic hash table")
Cc: stable@dpdk.org
Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/tf_ulp/ulp_gen_hash.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
index 3c6e7fe924..84c83de35c 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
@@ -16,20 +16,21 @@ int32_t ulp_bit_alloc_list_alloc(struct bit_alloc_list *blist,
{
uint64_t bentry;
uint32_t idx = 0, jdx = 0;
+ uint32_t bsize_64 = blist->bsize / ULP_64B_IN_BYTES;
/* Iterate all numbers that have all 1's */
do {
bentry = blist->bdata[idx++];
- } while (bentry == -1UL && idx < blist->bsize);
+ } while (bentry == -1UL && idx <= bsize_64);
- if (idx < blist->bsize) {
+ if (idx <= bsize_64) {
if (bentry)
jdx = __builtin_clzl(~bentry);
*index = ((idx - 1) * ULP_INDEX_BITMAP_SIZE) + jdx;
ULP_INDEX_BITMAP_SET(blist->bdata[(idx - 1)], jdx);
return 0;
}
- jdx = (uint32_t)(blist->bsize * ULP_INDEX_BITMAP_SIZE);
+ jdx = (uint32_t)(bsize_64 * ULP_INDEX_BITMAP_SIZE);
BNXT_TF_DBG(ERR, "bit allocator is full reached max:%x\n", jdx);
return -1;
}
@@ -39,9 +40,10 @@ int32_t ulp_bit_alloc_list_dealloc(struct bit_alloc_list *blist,
uint32_t index)
{
uint32_t idx = 0, jdx;
+ uint32_t bsize_64 = blist->bsize / ULP_64B_IN_BYTES;
idx = index / ULP_INDEX_BITMAP_SIZE;
- if (idx >= blist->bsize) {
+ if (idx >= bsize_64) {
BNXT_TF_DBG(ERR, "invalid bit index %x:%x\n", idx,
blist->bsize);
return -EINVAL;
@@ -127,7 +129,8 @@ ulp_gen_hash_tbl_list_init(struct ulp_hash_create_params *cparams,
hash_tbl->hash_mask = size - 1;
/* allocate the memory for the bit allocator */
- size = (cparams->num_key_entries / sizeof(uint64_t)) + 1;
+ size = (cparams->num_key_entries / sizeof(uint64_t));
+ size = ULP_BYTE_ROUND_OFF_8(size);
hash_tbl->bit_list.bsize = size;
hash_tbl->bit_list.bdata = rte_zmalloc("Generic hash bit alloc", size,
ULP_BUFFER_ALIGN_64_BYTE);
@@ -311,7 +314,12 @@ ulp_gen_hash_tbl_list_add(struct ulp_gen_hash_tbl *hash_tbl,
BNXT_TF_DBG(ERR, "Error in bit list alloc\n");
return -ENOMEM;
}
-
+ if (key_index > hash_tbl->num_key_entries) {
+ BNXT_TF_DBG(ERR, "reached max size %u:%u\n", key_index,
+ hash_tbl->num_key_entries);
+ ulp_bit_alloc_list_dealloc(&hash_tbl->bit_list, key_index);
+ return -ENOMEM;
+ }
/* Update the hash entry */
ULP_HASH_BUCKET_MARK_INUSE(bucket, (uint16_t)key_index);
--
2.30.1 (Apple Git-130)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-04 21:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20211102040556.7840-1-venkatkumar.duvvuru@broadcom.com>
[not found] ` <20211103005251.25524-1-ajit.khaparde@broadcom.com>
2021-11-03 0:52 ` [dpdk-stable] [PATCH v4 03/20] net/bnxt: fix out of bounds issue in hash list Ajit Khaparde
2021-11-03 0:52 ` [dpdk-stable] [PATCH v4 11/20] net/bnxt: fix clang compiler warnings Ajit Khaparde
2021-11-03 13:24 ` [dpdk-stable] [dpdk-dev] " Ferruh Yigit
[not found] ` <20211104215846.58672-1-ajit.khaparde@broadcom.com>
2021-11-04 21:58 ` [dpdk-stable] [PATCH v5 03/22] net/bnxt: fix out of bounds issue in hash list Ajit Khaparde
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).