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 38B7745EF0; Thu, 19 Dec 2024 23:53:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09FC2402CD; Thu, 19 Dec 2024 23:53:08 +0100 (CET) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by mails.dpdk.org (Postfix) with ESMTP id 5A17A40265 for ; Thu, 19 Dec 2024 23:53:05 +0100 (CET) Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7fcf59a41ddso781014a12.3 for ; Thu, 19 Dec 2024 14:53:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1734648784; x=1735253584; 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=W3bnID6nrrsciGGgquDcwcvgLNdpCl2HdSOu5NTn+m8=; b=oXplDrgJmulBIxcFaKi5h3IqFx1rekcijf7Fd7AcIOfEcJxhEyYhEs+hGKs7c6SgT6 ucmDvAdtZy5J2BfpjVDl11xi7v2/Y3icO/m6TLcxmkuSw3HRTzbrQwcsQ9OvuZxSRyqG VQmu06Dgg7FH0pINV0DHX6Yy07hKPXU9bqYUn64Oe6Ysm4+QtjDnvPu36UlRfuZ2yZr8 zfmtmU4jDzwLCEWt0rZQIQB5p+YzSKTy9sCLSnnsuUsDhliQyIETBHI31Fve0yC9WMAk iQkzj1rvnTkFfaZhcZtucWqxBzuqCdh0InETV7ZftAAQ8Bi9aLdZskkyRTl4bTSMdpLz FBdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734648784; x=1735253584; 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=W3bnID6nrrsciGGgquDcwcvgLNdpCl2HdSOu5NTn+m8=; b=M7UsKKptK4A/qQtTzmM7076iK992nL9p7JUUyDhGGFGTSMB1czUJ9HdRnbnO6GVPvB qD5pkF24VexS2Y5s9l59FsvFlkAwH/miaz+tgaVz9WCaGZRkZ4Zxk8DTlqPGYAJOBAIZ EiuNmKIo+g73n+KfSL+Jvk2CCP1xjC2uVSXsTSo2+cnTv+uE7JrGVsub73LM5C0Xg/w/ W47RwZbgW1g3+4DMt3oiwtwBWyEL0XdD4fv2/TVVmj0QeXYCUr7O2KXD0Vopd0u5iLyJ I9XERmtDprwcfH65s8ef2NVbLnRFnHZINzGy+QHiN/etXzovxs3ctreXNT2RXfdaXZfA 4PaQ== X-Gm-Message-State: AOJu0YzEI8zxGIP51+X++dLkTfLtNLavGi4/R0sp4X+roNXQE50XBiT3 LwR6rIybOAp+Z/uHqgGbYM17znzOvSnKkt4p8Ex1uFahQqzFwwrmns8omQ98+yagiLVX32avIfw 5f6I= X-Gm-Gg: ASbGnctbyYjOvQnV9MdpNuWTqHPAfF2YcdxHVma0LdYi3HlqfXxUW3l3x6Of7eg/fec dR5v/nn4JLfSA+wi09YqZPID5qDrALqNcZ2dJHJXTtVu0iv06F94tqvjZhgYs3wjmMJ4S+c6YvV KwZLVXumMnLTmOdKrOOPhVegaN4pwbjpLxthCqvguPqx62WtW/voiowc/+aiMZVluQRJL33EVWl E+ON9lIk9lyy6SJNRwJGm3MLvHT1dVGOPm5ZkAIk2tW+M7oFRFyyuZU3eGqVUZ25YoNlijLmneh ajR5+qSNB2gV//Odqf6FRbDWNla2uRIStw== X-Google-Smtp-Source: AGHT+IFogvVpIIlRYRH0K1+WciT66x78jW3lf7+relBDnORmEw0pkFno0qsyCYdPgI4LlJACCE1SBQ== X-Received: by 2002:a17:90b:2e4b:b0:2ea:a9ac:eee1 with SMTP id 98e67ed59e1d1-2f452e1e268mr1155976a91.10.1734648784535; Thu, 19 Dec 2024 14:53:04 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ed62b30asm3901021a91.12.2024.12.19.14.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 14:53:04 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , ajit.khaparde@broadcom.com, stable@dpdk.org, Somnath Kotur , Kalesh AP Subject: [PATCH v2 2/5] net/bnxt: fix use after free Date: Thu, 19 Dec 2024 14:49:52 -0800 Message-ID: <20241219225253.782792-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241219225253.782792-1-stephen@networkplumber.org> References: <20241218170530.140747-1-stephen@networkplumber.org> <20241219225253.782792-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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 7b90ba651f..3804a5ec16 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -12,6 +12,13 @@ #include #include +#ifndef STAILQ_FOREACH_SAFE +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST((head)); \ + (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + #include "bnxt.h" #include "bnxt_filter.h" #include "bnxt_hwrm.h" @@ -151,7 +158,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