From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
cloud.wangxiaoyun@huawei.com, stable@dpdk.org
Subject: [PATCH v2 11/19] net/hinic: fix flow type bitmask overflow
Date: Mon, 18 Nov 2024 10:20:52 -0800 [thread overview]
Message-ID: <20241118182153.87042-12-stephen@networkplumber.org> (raw)
In-Reply-To: <20241118182153.87042-1-stephen@networkplumber.org>
The type mask is 64 bit value, doing a shift of literal 1 (32 bit)
will result in int type (32 bit) and cause truncation.
Link: https://pvs-studio.com/en/blog/posts/cpp/1183/
Fixes: f4ca3fd54c4d ("net/hinic: create and destroy flow director filter")
Cc: cloud.wangxiaoyun@huawei.com
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/hinic/hinic_pmd_flow.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c
index 8fdd5a35be..6b1ca6ff88 100644
--- a/drivers/net/hinic/hinic_pmd_flow.c
+++ b/drivers/net/hinic/hinic_pmd_flow.c
@@ -1979,8 +1979,8 @@ static int hinic_lookup_new_filter(struct hinic_5tuple_filter *filter,
return -EINVAL;
}
- if (!(filter_info->type_mask & (1 << type_id))) {
- filter_info->type_mask |= 1 << type_id;
+ if (!(filter_info->type_mask & (UINT64_C(1) << type_id))) {
+ filter_info->type_mask |= UINT64_C(1) << type_id;
filter->index = type_id;
filter_info->pkt_filters[type_id].enable = true;
filter_info->pkt_filters[type_id].pkt_proto =
@@ -2138,7 +2138,7 @@ static void hinic_remove_5tuple_filter(struct rte_eth_dev *dev,
filter_info->pkt_type = 0;
filter_info->qid = 0;
filter_info->pkt_filters[filter->index].qid = 0;
- filter_info->type_mask &= ~(1 << (filter->index));
+ filter_info->type_mask &= ~(UINT64_C(1) << filter->index);
TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
rte_free(filter);
@@ -2268,8 +2268,8 @@ hinic_ethertype_filter_insert(struct hinic_filter_info *filter_info,
if (id < 0)
return -EINVAL;
- if (!(filter_info->type_mask & (1 << id))) {
- filter_info->type_mask |= 1 << id;
+ if (!(filter_info->type_mask & (UINT64_C(1) << id))) {
+ filter_info->type_mask |= UINT64_C(1) << id;
filter_info->pkt_filters[id].pkt_proto =
ethertype_filter->pkt_proto;
filter_info->pkt_filters[id].enable = ethertype_filter->enable;
@@ -2289,7 +2289,7 @@ hinic_ethertype_filter_remove(struct hinic_filter_info *filter_info,
return;
filter_info->pkt_type = 0;
- filter_info->type_mask &= ~(1 << idx);
+ filter_info->type_mask &= ~(UINT64_C(1) << idx);
filter_info->pkt_filters[idx].pkt_proto = (uint16_t)0;
filter_info->pkt_filters[idx].enable = FALSE;
filter_info->pkt_filters[idx].qid = 0;
@@ -2355,7 +2355,7 @@ hinic_add_del_ethertype_filter(struct rte_eth_dev *dev,
if (i < 0)
return -EINVAL;
- if ((filter_info->type_mask & (1 << i))) {
+ if ((filter_info->type_mask & (UINT64_C(1) << i))) {
filter_info->pkt_filters[i].enable = FALSE;
(void)hinic_set_fdir_filter(nic_dev->hwdev,
filter_info->pkt_type,
--
2.45.2
next prev parent reply other threads:[~2024-11-18 18:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241115060738.313190-1-stephen@networkplumber.org>
2024-11-15 6:05 ` [PATCH 06/16] eal: fix out of bounds access in devargs Stephen Hemminger
2024-11-15 6:05 ` [PATCH 07/16] net/qede: fix missing debug string Stephen Hemminger
2024-11-15 6:05 ` [PATCH 09/16] examples/ptpclient: fix self memcmp Stephen Hemminger
2024-11-15 6:05 ` [PATCH 11/16] net/hinic: fix flow type bitmask overflow Stephen Hemminger
2024-11-15 6:05 ` [PATCH 12/16] crypto/dpaa2_sec: fix bitmask truncation Stephen Hemminger
2024-11-18 7:03 ` Hemant Agrawal
2024-11-15 6:05 ` [PATCH 13/16] crypto/dpaa_sec: " Stephen Hemminger
2024-11-18 7:03 ` Hemant Agrawal
2024-11-15 6:05 ` [PATCH 14/16] event/dpaa: " Stephen Hemminger
2024-11-18 7:04 ` Hemant Agrawal
2024-11-15 6:05 ` [PATCH 15/16] net/dpaa: " Stephen Hemminger
2024-11-18 7:04 ` Hemant Agrawal
2024-11-15 6:05 ` [PATCH 16/16] net/dpaa2: " Stephen Hemminger
2024-11-18 7:04 ` Hemant Agrawal
[not found] ` <20241118182153.87042-1-stephen@networkplumber.org>
2024-11-18 18:20 ` [PATCH v2 06/19] eal: fix out of bounds access in devargs Stephen Hemminger
2024-11-18 18:20 ` [PATCH v2 07/19] net/qede: fix missing debug string Stephen Hemminger
2024-11-18 18:20 ` [PATCH v2 09/19] examples/ptpclient: fix self memcmp Stephen Hemminger
2024-11-18 18:20 ` Stephen Hemminger [this message]
2024-11-18 18:20 ` [PATCH v2 12/19] crypto/dpaa2_sec: fix bitmask truncation Stephen Hemminger
2024-11-18 18:20 ` [PATCH v2 13/19] crypto/dpaa_sec: " Stephen Hemminger
2024-11-18 18:20 ` [PATCH v2 14/19] event/dpaa: " Stephen Hemminger
2024-11-18 18:20 ` [PATCH v2 15/19] net/dpaa: " Stephen Hemminger
2024-11-18 18:20 ` [PATCH v2 16/19] net/dpaa2: " Stephen Hemminger
2024-11-18 18:20 ` [PATCH v2 17/19] net/qede: don't use same loop variable twice Stephen Hemminger
2024-11-18 18:20 ` [PATCH v2 18/19] examples/l3fwd: fix operator precedence bugs Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241118182153.87042-12-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=cloud.wangxiaoyun@huawei.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).