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 C892545CD8 for ; Mon, 18 Nov 2024 19:22:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0604842DF1; Mon, 18 Nov 2024 19:22:20 +0100 (CET) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mails.dpdk.org (Postfix) with ESMTP id 2AA0A427DE for ; Mon, 18 Nov 2024 19:22:12 +0100 (CET) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-720d01caa66so3054391b3a.2 for ; Mon, 18 Nov 2024 10:22:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731954131; x=1732558931; 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=r+/vLSZvNozxFVz2+LrpvdaudOEKAYA/cRsifFUUMRLc0n/Rt1kZwe6GiCwfHGke1p L9LYbWpoc2+/4b7xf8Dq2Kju/HhovOFxvNYdSIuHNW2yG8ycGJsi3K/mR1X+41KSNPrO ma9EvPreZvRInmhgfs7dvTsVS6Z9gCBY8NG7djUpllAZdYtS8YBWpQd8Oaqkrh3iucxH pAotfeAr1gIWuUBqIwb+vNcajUQCnIfOFuvIlDXqAULmKWWip2v9cqQvGfoOjzRTVBnX HVxUD2pTh40EzqafxX6H6RTu6kgDfhTUk3BaJ1+lAAJOGWsmCvxeYF7g2LMWix/iHq+0 POAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731954131; x=1732558931; 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=rQVZ0hql5RqHq88Ixzhd45KcqT3xLPPrK6etwJlG8AzAXTZuqTzx7A20MYm4BpyzSV VT5t1oN2uDzmkDqxHcgVb6tVBdM/f8NsVEC/K+j0N0bDUbkk/YwuDyT4/qsNH8ztOq0l Y0GkukcxsWJcbR43a3zPoLOQtqdyNs+sYKKJKgr6+J5Hn6+T6OmfyNke+FqM/GlfK5IS wZHq5k3Cq/MYCdf+Mg+BMYgJvdGLcyIkZiMgGWLeKZeeIsQEu+vDuAkmtVa3SCD50kCS xok1WNvwaMFGMI44G1SB5p4e5oHLanHRweEQ8GHB+UgHKN0+eN1tRipBYtqjFbIEYNLL bG6A== X-Forwarded-Encrypted: i=1; AJvYcCVHILZf0fevLqb3VfLTnyrCh9n5ikFFYI15t0cEdbrWi7rBJsVU2Wf7OwXoqPMkQhWnknib7k4=@dpdk.org X-Gm-Message-State: AOJu0YyHY9b5b90Kj2b4skV8W+Z744f/vwzOWMrDMu01vuqCuMwZsCIQ UWN4aJiSFnRlNk8oBGHT37bHzraCacZLAPGA+bdncygtosFQH+J3s2SBHfsmLg0= X-Google-Smtp-Source: AGHT+IE2tN9Ysm1T1wjyAV7+QsldcTT4/bSTrt01sE/bkk1zdfhno4MMsEUmvwtTzbEUCaqB660EUg== X-Received: by 2002:a17:90b:4a48:b0:2ea:5e0c:2850 with SMTP id 98e67ed59e1d1-2ea5e1b732bmr7069963a91.25.1731954131310; Mon, 18 Nov 2024 10:22:11 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea61869bb2sm2916724a91.12.2024.11.18.10.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 10:22:10 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , 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 Message-ID: <20241118182153.87042-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182153.87042-1-stephen@networkplumber.org> References: <20241115060738.313190-1-stephen@networkplumber.org> <20241118182153.87042-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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