From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0E0D45D0B; Fri, 15 Nov 2024 07:09:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C52742FDD; Fri, 15 Nov 2024 07:08:07 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id 04CF042F8D for ; Fri, 15 Nov 2024 07:08:02 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2e31af47681so326355a91.2 for ; Thu, 14 Nov 2024 22:08:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731650881; x=1732255681; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s8cDxKTwDgpRG08HW7SNzZQgtXLpjw6cnHRlWVwqwFs=; b=Y9jY9+r4zL/sRkV1Aei0kL8dcE5PIlGJRk8lvYjr+77a+LinOVcTdrExsJs/ncPG/B aqVwLP0VQ9gElwAmAy4zuQpAhkzwkROBt+im0dCI4Hp2pFuEhPtnc0dJq2ZHvSzyEMQH 7h95JhE3Y1L43SH7SCr5V08PGZK8OkKC1/8UN8XH/LikzSEFXGJnsqa7FMZZpgF1HA1K MpRZQcArTITX+OYBCR13I1J/YJxOpG3HTP5QeNcvj125hSy8zoPunY01+slFFDhJTq+W VhtcvFLkGmafojBT2rXDmlbVIoIZ028d0R16Bg24rjd/eXBdkM8flTzuChklgk+gRoQS S7hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731650881; x=1732255681; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s8cDxKTwDgpRG08HW7SNzZQgtXLpjw6cnHRlWVwqwFs=; b=nhSCKf9iNsv7QQVbmqaG3YB5Qi9B7jIf8sVVn136q7W24ms4TvCA+LE61bTSyFxEUd 0iRTfaAZbvVSHbA9X0Z1tLMIkjkJkYZKaP5scamPEMcxReoiyGkLnSMUVxuKOQtRBaJJ XoMNeQzM0iFnotlWJxj5LmSKHpOrTfk64C/lpi9VfmidxsKvNHXZwl4nNeCgf7p9Dg33 XYHRbyjj9t9FSOKAtxMXntBfCyzrims0tft7FSctGhKwJxlCRmB23++exuFECo71TM9q yUIH06Wcvfh1wU4Pf9Ip/n1t4s5vb0hWvUPZEYjEqT4Vsew7so5qrWPHjozeF20DgMId //Lw== X-Gm-Message-State: AOJu0Yzgd/uVZ0oO5mH3JFCiDBKAjNSh8Y4EmrAvP/E2UxvgyHI1GDoG SRvyGEUHtRn9FO7bP+7lt3G1BLPrgN4FlSOEAXEgkUOk7O9vRHZSRNvbekaoOEvERx/o7FpeGTK J X-Google-Smtp-Source: AGHT+IHKNtuLeSm3CCcb6Z0LxVzUHHjX9zr2OKt5ElPvUSr0F20w0nXQDnS3+lAhb6zRScIUb+J8NQ== X-Received: by 2002:a17:90b:4a0c:b0:2e2:c6c2:b3d5 with SMTP id 98e67ed59e1d1-2ea154f6d9emr2065661a91.9.1731650881190; Thu, 14 Nov 2024 22:08:01 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea06f4856esm2123781a91.23.2024.11.14.22.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 22:08:00 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , cloud.wangxiaoyun@huawei.com, stable@dpdk.org, Ziyang Xuan Subject: [PATCH 11/16] net/hinic: fix flow type bitmask overflow Date: Thu, 14 Nov 2024 22:05:48 -0800 Message-ID: <20241115060738.313190-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241115060738.313190-1-stephen@networkplumber.org> References: <20241115060738.313190-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.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 --- 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