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 946A745EF0 for ; Thu, 19 Dec 2024 23:53:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1D759402D6; Thu, 19 Dec 2024 23:53:09 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id 573C54025F for ; Thu, 19 Dec 2024 23:53:05 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2f441791e40so1042536a91.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=OZAx4iFb0b5Gh4ciO/9bHTDbLnY2OPmYIrfn3VFStWX1Fj9jjtbabvZoSBsQpopVq0 wKyHYhi6myjzk//hRPbicOQBq0fpij8+eiMUbS/m5SBGh0FwdBjOuFG5cj7WbScshAmr b5nmIMSGmfEWcmU7zsjfZQJFC8r3E4Q3gG+cDc7ZklKwdYTiBCQ25ac90vBQZiwFh7nQ BfqPp5fZGQ38ODf/RytRLfaMQKTeUtH4Iw3DoZ31qgL8GTQqloyr84NvCHxPcfLTxOqO iGEt5YbeYaKlYkEBdCAncHWvwiWVefv/mxiJnZxP7vbt9wbdrcNzWLXKYCRA79hGsx3s lNcA== X-Forwarded-Encrypted: i=1; AJvYcCUJrDqcy2xEQJOJZcpljMkPx/AptuAQaRWt3nub2ZeweFHcdj7icfCpB0BDDAHm3qnSkvd1xhE=@dpdk.org X-Gm-Message-State: AOJu0Yy2HuQC6arcuK7M57skydPmuNyIACXJVI6Sekr0hOtAK96vig0v C2S4ZMND73a+sO6YX5CwGueGk7WDVawIMO7DeyzWLiYBK4HkMFJaKFdY3ovIkmM= X-Gm-Gg: ASbGncvVXpD2vQts33pQ+fgA7mACHMeAN3XpHog4lYO4dLApFqJT+r1mBCLJAUjEJAS 1RAqMHnFW5/QBOaXMMco8dDHVeZNG1Dkcnhib3GMdHro8sHm0QC/tiGiXXkOiYCgqB24UAUwYgz PYzQoD7yn4XSdEKXGoeF7rDs6wPc490IrNaA2kSHpx9DtVw/3FE9nGEyYp7THwWg+ETeByjm7mq khBErWNhbdyMJQIKow0UlLRXgcwRjzUqYJEtybRCG7hJYRVqFTQqsvuxDVpmTVV4fyi+S2Q6uqt Z9Jq5BaT2Q7EVqkqpOVcV6rNuc9gJic5IA== 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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