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 05D6B4613A; Mon, 27 Jan 2025 19:09:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26F0840B92; Mon, 27 Jan 2025 19:09:00 +0100 (CET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 00C2140A72 for ; Mon, 27 Jan 2025 19:08:57 +0100 (CET) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-21675fd60feso106073835ad.2 for ; Mon, 27 Jan 2025 10:08:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1738001336; x=1738606136; 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=p06eYsvXv1vuLyeuHmh4ow/1C2d1Q/ipxd+44YVjGEM=; b=ug9E7tYWZ8RJ/uQoEgFh25VO8EKIGUiMBDjJzy+SVNXsh8vusBsIwbtRixYj/R6rcf 9K79zk2c2mp9Ynf34rMb+ZrbWyvaQdACcpcxl/ZqzPqcaURlr0avbityriX7JK+lBRHx KpkMX8lA0NxgMlwbETa/Skepvp5mArPN1iqtwmZ+Inbl+O6I7GYFttPBCu4vjDqjWcGR RG7U+ELMenjPF7MFygoUle0nfIaLgil7esfYD6AFPBbd+iYk0p96jfJBL7MkT7xgmU4R 895196z4rEkszGRrbTdLRxo+uV2vbnf5/2RXgWMB7cGMxraWzZdYBWFBAe9daBm4YH5Q mmsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738001336; x=1738606136; 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=p06eYsvXv1vuLyeuHmh4ow/1C2d1Q/ipxd+44YVjGEM=; b=ldjm8w+b3mAtyJ6EkfdH54MYJVH1zlyuo0gGpRKMSudAOeTSIlob8jkMcJ4tYFipk2 EfUP5g0yEIj5fM1ECwAK4/gLhFxoh5kO6BNZ/8EfBzqKcUFKAzqYfu74cmUuWVFUedpT rnYFpgyDRWtfpkYMc63OsyAItDYW+VCOxp+xZzIjB2OgZLmtkcnzi4ubrnw+I+xj85JF hJXSWnCO3UdepMz+d5gXjcRo7LYr4bh5eSbamC4BbpJwgnG+9LIzg7fAOq8MlUd1WmJu KCAOnjVW8HU8G3wMM9nN5OmobVFMCjq/p9tiNw4kAQQANiZmgqSlV9IxJOUqb0IhOow3 /1Fg== X-Gm-Message-State: AOJu0YxLoZbjpAkMsO+zDtRp1L2KWyi3R/EXPSbxq3XoQAznmaR95Hmx DZBRcjScfBcsB2K8QtoHSN5k4ZLKvu9T+xRiq9/0U6eIpRGqriT0ok7InEjaOhtMCaLa3jhEgDq f X-Gm-Gg: ASbGncu6D8mvLQrChNHnJYdgDktLFB0CQoNJxUlEIJTtaT5w0yUdLtPykkJ6l7jMaUR 9LBFDLoKxZwmoDlhTwgnzq9oMN2slvun+neepRlZS6A7XJMJAG5ysbfiVp/u9/Bv8cRQYBP2ZTR cCthxNoAVghdnLm58SJF4ObHRmODcF2ZjJL6BGDxHRMrFszuEMGw3Sm6j7P0RLDEmbx2d9L5Imc rd3njw4kLmPaqPZ54qO7NH/Zwfu/m5EYPY61cplb4+mdOY7C8QLbr5IXGNLDLaG+Syc+D4ohL1W 2EbiniAT/1iv64EqCW/Uh5VYTsbwA0hjmtNsH18fhzW0S2CCjiQEy+JrAg== X-Google-Smtp-Source: AGHT+IHHfxiqFTIu56QYSHrl8BHA0EApsG0PfRgfJdCtFsdIroOHp7oPVPhMnjf1fGkeR9CXXYZ5Kg== X-Received: by 2002:a17:902:d4c9:b0:216:31aa:12fc with SMTP id d9443c01a7336-21c35563f15mr703604635ad.24.1738001336275; Mon, 27 Jan 2025 10:08:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 10:08:55 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , ajit.khaparde@broadcom.com, stable@dpdk.org, Somnath Kotur , Kalesh AP Subject: [RFC 4/7] net/bnxt: fix use after free Date: Mon, 27 Jan 2025 10:03:58 -0800 Message-ID: <20250127180842.97907-5-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 filter cleanup loop was using STAILQ_FOREACH and rte_free and would dereference the filter after free. Found by build with -Dbsanitize=address,undefined Fixes: e8fe0e067b68 ("net/bnxt: fix allocation of PF info struct") Cc: ajit.khaparde@broadcom.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/bnxt/bnxt_filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 7b90ba651f..f083f3aa94 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -3,14 +3,12 @@ * All rights reserved. */ -#include - #include #include #include #include #include -#include +#include #include "bnxt.h" #include "bnxt_filter.h" @@ -151,7 +149,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) { + struct bnxt_filter_info *tmp; + + STAILQ_FOREACH_SAFE(filter, &bp->pf->vf_info[i].filter, next, tmp) { rte_free(filter); STAILQ_REMOVE(&bp->pf->vf_info[i].filter, filter, bnxt_filter_info, next); -- 2.45.2