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 808FF45CD8; Mon, 18 Nov 2024 19:23:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2870E42E0C; Mon, 18 Nov 2024 19:22:20 +0100 (CET) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id 238DC427DA for ; Mon, 18 Nov 2024 19:22:12 +0100 (CET) Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2e59746062fso2718335a91.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=DV/muThZsJnpM/G5sMGQySZNKvoD1KLelNhP9XKi6CA/wSPdypuD0tZ1vuLnTid6mc nXFYSTF7jhegedTSLvKNficfm5I8Zz+XSyx+COFt02w11eixNWMcIymZ+yTxhltx+0vb FXfNsCbREzxBTb+PBTnQvwuuQNsAtNt/ra846NLtmWHmmNVd1RaZjYBqIVzQRnDmB2Nk lwhySxGayGCiCgJ6FGR5wqlzlDvfLS2jM7pC821Nd4c2nyjJbmFXborP22++3CpwUpd1 ke0KWFgrT6itXYB7Bglmnx5Eaxokec0V0pn3sOdkm12fylkR1tZBDI7ADGT8shKiz+jr PqbA== X-Gm-Message-State: AOJu0Yy+UTyPEPTXbYm7ofJ4RmV5x8CVGgxXvrH7CKwzKhkgEs/HuqO7 CqqXDHRRUib6SaPWvQECiDkEHEjOoEz9V866KIX0yj3KCP13TZL1ZU8Nhmb0W/xdLN+0iYamx+k A 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: 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