From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 706AA606A31A for ; Wed, 2 Dec 2026 01:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=VSACU4P7 Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3810940608; Wed, 2 Dec 2026 02:12:01 +0100 (CET) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTPS id F0619402D5 for ; Wed, 2 Dec 2026 02:11:58 +0100 (CET) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2f046b0adc0so72916205ad.1 for ; Tue, 01 Dec 2026 17:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796173917; x=1796778717; 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:content-type; bh=9JBAT2P2zLauX+fW2na1WWySSxC4ZxVcaa+DN7VfrcU=; b=VSACU4P7sVNTs3DFtOvfVrZFmgBhJg/1qUg+FE4wP/iR8mrtBkg39zL/B0JSXZygWV SGlKmGa2HdWXNfwiTZUge8z+WfeiZrQxil21khgkzMsYwS71SAfeXLu7NQhfsu2Uq3iC 4tqAeDIjWnYOEacxS7pP0jDz3GYi5Nywp6aUjGKMIhCIt3Ul1qLhgYoGoeZoO+N10jIM aHe+BZxDAxh9uYH4SivWmGF5ud2qc8hC8hwgvB69d7086i8GxDpc6WwBZiIAQxUfcjoP D9zXp5IsnW53LhmR25W0kNk7VnTEUetVlu4s7zPHDKAI0FLm4jizIz37OKjVmo9aOmkG wSmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796173917; x=1796778717; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=9JBAT2P2zLauX+fW2na1WWySSxC4ZxVcaa+DN7VfrcU=; b=BOpCSJMiqf0hjpvINc125tDq0fMPuN4foUnQpvyXzjZbF+1B4jr74eg/8TSV9jT80X jo3xFiJOb0kHHjnwhHQjLRN91O6c6NK8Zqs/Mosat3Q2S+MXdqswBG20GRCe7W6ZK26J 6oaRJn/LP2VBNSsp9PY5YpmjoWSztM+xbL4/jflQ6GeNHkOjsZYHGlpRZa0V0jdkif9v NljSZlueUsruEEAXxe7I+INmidGI+iBMI0MxbXD+WOeMX2g31czCBrBc74+AFj8wxIB9 N/q2eFUu6dja7EzubECzjq0kbS8cyVkvJJzLjLS6OpY8R2zX32CODIPLKHx2gXBVRu48 UAUQ== X-Gm-Message-State: APuU4Z8D4CofaEeYtA5Ugi7kPZd2aEH63aWizJ9QoJIFek+/Enshqy2R yalOgAZzFjw5zsc5hS78qhYPd3Ivl0fHps6YlATZyd5WxLyNhwlqYSzQvyuxB+JtLx+p0BHOvyz RXUlIXXk= X-Gm-Gg: AZFdTZc8ZMymIkN4vjTm+JWmxKMrU8l3h5fybi6ejr9CklbrMOTtWX1wMbutuztsFun WyMswMZMpCE+/6zOUgggMOinYtWwo2+WpgEtewOpJzP8AXFgk3jTJCCAFU6i9pCMe6qpfPzySLk 0o8nsBetXdw/19ZD7HvrtLU24AOTFRKa35TgQgus4v4swk9CkKC5nGuB8tr1ORFTK+9QZ+hmAuO YMZDMEbJebruUQfjSuAxPYRrP+EtjMAAGTfIwthIZfSv0Rn5zfrFvyd8uv4mIa5busjnfhSZqgD BcjM3aJESJAHSwudonoQJui6W5J0PSk17fIuK/cvK74IhW/RAfAEED5b83QdYi+bzqLjI4p7xWC Z6yA4Was1GHJcU7Ud15GPapdfVtyb/79I+ZMexZLJ8y2dFVGl4jVxv9qFrqss15gSpvBFUu41aB URVB19gZBZL3F8qPC+yrWN13i5311HvrhfvgfIP2l0gwll15hDO3z0tMMB50+MEYRpmhk2D1ijt WE5AaxNFBffbu1zbxBQiJSVQG13h5EkxKgoXQsKWJGqcjoM5SQuoYipoj+Cbq+dIuh9sTX/0CTe qWaK5OH0Wdh9mlgb6Yj5dREOwMcGvdniYNcLwRDtRFyth0lPh+g7aAXT7l7n0vZanB70KYQKRjB IFqg5GiC/Dm28wA== X-Received: by 2002:a17:90b:5303:b0:3b4:41a8:7850 with SMTP id 98e67ed59e1d1-3b441a87c7bmr34360721a91.6.1796173917112; Tue, 01 Dec 2026 17:11:57 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cdec1168866sm11120980a12.25.2026.12.01.17.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 17:11:56 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Kishore Padmanabha , Ajit Khaparde Subject: [PATCH v2 1/6] net/bnxt: fix use after free when freeing filters Date: Tue, 1 Dec 2026 17:05:01 -0800 Message-ID: <20261202011153.3255223-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261202011153.3255223-1-stephen@networkplumber.org> References: <20260917172116.660120-1-stephen@networkplumber.org> <20261202011153.3255223-1-stephen@networkplumber.org> X-Archived-By: 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-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 bnxt_free_filter_mem() freed each filter and then passed the freed pointer to STAILQ_REMOVE, which walks the list to unlink it. STAILQ_FOREACH also read the next pointer out of the freed element. The loop empties the list, so take each entry off the head and free it after it is unlinked. STAILQ_REMOVE_HEAD also avoids the list walk that STAILQ_REMOVE does to find the element. Found while moving the list macros into a DPDK header, where the compiler could see them and report -Wuse-after-free. The fix does not depend on that work. Fixes: f11fd694a84a ("net/bnxt: free memory allocated for VF filters") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/bnxt/bnxt_filter.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 7b90ba651f..541b329e81 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -151,10 +151,9 @@ void bnxt_free_filter_mem(struct bnxt *bp) bp->filter_info = NULL; for (i = 0; i < bp->pf->max_vfs; i++) { - STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) { + while ((filter = STAILQ_FIRST(&bp->pf->vf_info[i].filter))) { + STAILQ_REMOVE_HEAD(&bp->pf->vf_info[i].filter, next); rte_free(filter); - STAILQ_REMOVE(&bp->pf->vf_info[i].filter, filter, - bnxt_filter_info, next); } } } -- 2.53.0