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 6E58A4613A; Mon, 27 Jan 2025 19:09:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3E9740A80; Mon, 27 Jan 2025 19:08:58 +0100 (CET) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mails.dpdk.org (Postfix) with ESMTP id 0455740A6F for ; Mon, 27 Jan 2025 19:08:54 +0100 (CET) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-219f8263ae0so87944005ad.0 for ; Mon, 27 Jan 2025 10:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1738001334; x=1738606134; 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=dWjyaJpPfRt2O7mge3JlSRiZF+HI7CLC8EddcDD7LKw=; b=2cIf9+JM3kIWaALLL2/NbQVWBDr5V3f2lCcRWBRnJbFMBSife54vDOUUCBfQeUXjq4 Eb4AHntXrxq0j4Ldntufjlz3TnC39v/GzrN1jEGDP+1QSqU5lTUEOUwpVmyOP0stXp5m t6GKDbstgph3vmBEZHOdOmcv8quDKeFTlRX0NYrOr8mQ3934GIsVx8pB3HjrpcyGrXLE WICyIFKLUpnkWZDDuR6ewDzs+qc9Ptv3smd8Iiveyb3N9BTGyF8Ykik4+qds9LQ6TIqy pJRI8nBsnVbq+KPsyYKQLubjoKpoRS+TiswoJqckHn+gPdRIf3ST/b7VIV/SPyZifgud 1rtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738001334; x=1738606134; 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=dWjyaJpPfRt2O7mge3JlSRiZF+HI7CLC8EddcDD7LKw=; b=bX35pv/jMudfseJeSjUyrbScp7JFVb/K7efCgixahyRZRbOWdMafFdzfr0octPWGmL /1+YQ3TWEvswTV+xrXsO4O2EZVpkmNJocmE6PWq6OoNzvhd1Kvv3cUiVXE1TlhriNswB +r4MwPVbsWHXYZZ9Amp53FZdBYMxz2d4D4vPrD9Z/z6IJ2Ec8Nik0RRitd/XdpVZYMdy g7310iX6AyhdGdKMfZRSUH2Q6QIYwHCysdL4j0w2A9M0inuOIa3RRlax65UIgr+TXFA8 iBONpwQQWuF9+vYiIkYhhP5gxTPL1eZ2dneoyB3ssOQS/NJJl9LMY/9R1ys8EVlUZ+qT P/mA== X-Gm-Message-State: AOJu0YyLs+z6ktGH0jbY9Dwbvz+PKmt4Q1O7dmlGNafnDeRQdpEmEqdx AniG5LjcH6LG9gDZFouMewrREaaSnwfK3dXrsVYmYTHbs2F3dc+idpxwB/qsxkdPfLc+K4VF5WC o X-Gm-Gg: ASbGnctnK9WLrBaGBU9cokGRtyYFvGK+9ELTH9rmQr3VJkkzrtFXxeGa5oj+MNV8RwU KhnWd1vEObAMPh3Z6k1Gg4Bltz0j974nfGu7UedUbCsYWSmmhpwmmYWBgCotlDoFK343SBphiZ/ QYqqr1J6eW5ue3pxgO3MQJqUsY4L/pfUYvC0BUZ+Dhb2tRb/yZsAion9Wtuo7RhUlcrZJdbGvWC x16ScVf4OjJjYeHT5L+6dcjlFmQy62p/uFcaP0xl/U/dtaFNvxQYWo5AocmDtgxwVVSsbl+wsRY wz7gue3qnjoXocrxYMy682hKL2GIxJQMoMudKEZI7jeIxrmB8Epr+9ZDRw== X-Google-Smtp-Source: AGHT+IGjJftGHUzjSVZzI+6HjhZW9Wqhsw+qsQTb8bbF0iYel1PCI37xa0iEXF8QrxzdNMaXRaYUUg== X-Received: by 2002:a17:903:2342:b0:215:854c:a71a with SMTP id d9443c01a7336-21c355c432fmr684923515ad.34.1738001334162; Mon, 27 Jan 2025 10:08:54 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da41413absm66166665ad.123.2025.01.27.10.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 10:08:53 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , shahed.shaikh@cavium.com, stable@dpdk.org, Devendra Singh Rawat , Alok Prasad , Shahed Shaikh Subject: [RFC 2/7] net/qede: fix use after free Date: Mon, 27 Jan 2025 10:03:56 -0800 Message-ID: <20250127180842.97907-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250127180842.97907-1-stephen@networkplumber.org> References: <20250127180842.97907-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 loop cleaning up flowdir resources was using SLIST_FOREACH but the inner loop would call rte_free. Found by building with address sanitizer undefined check. Also remove needless initialization, and null check. Fixes: f5765f66f9bb ("net/qede: refactor flow director into generic aRFS") Cc: shahed.shaikh@cavium.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/qede/qede_ethdev.h | 3 +-- drivers/net/qede/qede_filter.c | 13 +++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/net/qede/qede_ethdev.h b/drivers/net/qede/qede_ethdev.h index 3015c18504..b502658425 100644 --- a/drivers/net/qede/qede_ethdev.h +++ b/drivers/net/qede/qede_ethdev.h @@ -8,8 +8,7 @@ #ifndef _QEDE_ETHDEV_H_ #define _QEDE_ETHDEV_H_ -#include - +#include #include #include #include diff --git a/drivers/net/qede/qede_filter.c b/drivers/net/qede/qede_filter.c index 14fb4338e9..c3f74c89d9 100644 --- a/drivers/net/qede/qede_filter.c +++ b/drivers/net/qede/qede_filter.c @@ -154,15 +154,12 @@ int qede_check_fdir_support(struct rte_eth_dev *eth_dev) void qede_fdir_dealloc_resc(struct rte_eth_dev *eth_dev) { struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); - struct qede_arfs_entry *tmp = NULL; + struct qede_arfs_entry *tmp, *tmp2; - SLIST_FOREACH(tmp, &qdev->arfs_info.arfs_list_head, list) { - if (tmp) { - rte_memzone_free(tmp->mz); - SLIST_REMOVE(&qdev->arfs_info.arfs_list_head, tmp, - qede_arfs_entry, list); - rte_free(tmp); - } + SLIST_FOREACH_SAFE(tmp, &qdev->arfs_info.arfs_list_head, list, tmp2) { + rte_memzone_free(tmp->mz); + SLIST_REMOVE(&qdev->arfs_info.arfs_list_head, tmp, qede_arfs_entry, list); + rte_free(tmp); } } -- 2.45.2