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 DA51645A5D for ; Sun, 29 Sep 2024 17:41:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9A2740684; Sun, 29 Sep 2024 17:41:39 +0200 (CEST) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id A56634065A for ; Sun, 29 Sep 2024 17:41:29 +0200 (CEST) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-71971d2099cso2922788b3a.2 for ; Sun, 29 Sep 2024 08:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727624489; x=1728229289; 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=06J0UyE8Dnp7ti3PueEoXg75lBUxlkSP8fL1kmtEqoE=; b=RDwrfE12+a0q4EDg+rk3xux4ZT7a7rBYpYyP7avUNaaZpC88Y0/GWmKM57uQiqXR6d Tm2HMC5oGQmObVK7TwjDTyVK3EC9myO+SauX1YA360Wd3UG/SiK3/nO2+4/GnPAbNZ0X 9otNN2iTx2a592MSmF4v/aZ2DjlW7lJf16DqZiNC9LNchEtQqnwcWEOU2kNbvU0mdUEk 7hMBSRWTNZcTYmHv08fIgOzOrh5cQwRqiBSivkkLwqKj1qJk8hPjqNKs9eWypZSw6E7y 6bTuGpVtVSJvYZuDjoYzw+iLNMvgLI25c1ZiCe8ATXNBiFYpXM6nkbQCoysDUmMRNfzr EjMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727624489; x=1728229289; 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=06J0UyE8Dnp7ti3PueEoXg75lBUxlkSP8fL1kmtEqoE=; b=xCSW7OH/fr1hn7dudsZmf4kSoBsbgEJByIVsueSPtc1JP3vKMC7z+AaX2H1Sqvm2Tl PCsWwIkNW2TlXmmRog/MgqGACSVq/xbl8biZiPP3YWD+zDKagyQVRbVfOFcNhnKEFzgf hagkIMFcw7G3wMAX6lG8TlHo1lwpJ2CDW4eCP9dvtd5ati1u4qbEZuTpYKCndzKfFQLr EILE/eBPr4buNHtQCwJfA75FzEZpeRdHkfEXeHuKbZVETopGRgVQDxYQ87zyskxnuV1o AXxzhl/JlChk9OYnT/MRVJqefkKcwLU/JY53O3bJV8ROExo+Nt8XM3zBOU+eSYuCIyAC zNNA== X-Forwarded-Encrypted: i=1; AJvYcCX/pC9jmYHQSZpub3WhlxoKJBMBLOaHNU9vwZp46w0JM46wu2Uv9mat37hQcotKx4EHS+WbKLU=@dpdk.org X-Gm-Message-State: AOJu0Yyw3F4ycxtHezFNPam7argeHLSUlBUYq+mjmaTkO/7NRCkO8m05 rUtqosAI8w06xbpFIROmJMYyoRiP+WctrzPpp+AviCssnBOpYCUisUmfJpR9g28= X-Google-Smtp-Source: AGHT+IGuu54fYFPaJbjafsqbOQqlTTEdFM3V4uYWsqnxtztheZJ5FdYEDROzFM9dOIHvvCKDHofaMw== X-Received: by 2002:a05:6a21:4d8b:b0:1d4:becc:6eeb with SMTP id adf61e73a8af0-1d4fa77a314mr12898683637.31.1727624488845; Sun, 29 Sep 2024 08:41:28 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b2649c775sm4707416b3a.29.2024.09.29.08.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2024 08:41:28 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , tianfei.zhang@intel.com, stable@dpdk.org, Rosen Xu , Andy Pei Subject: [PATCH v3 12/18] raw/ifpga/base: fix use after free Date: Sun, 29 Sep 2024 08:34:37 -0700 Message-ID: <20240929154107.62539-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240929154107.62539-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> <20240929154107.62539-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 TAILQ_FOREACH() macro would refer to info after it had been freed. Fix by introducing TAILQ_FOREACH_SAFE here. Fixes: 4a19f89104f8 ("raw/ifpga/base: support multiple cards") Cc: tianfei.zhang@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/raw/ifpga/base/opae_intel_max10.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c index dd97a5f9fd..d5a9ceb6e3 100644 --- a/drivers/raw/ifpga/base/opae_intel_max10.c +++ b/drivers/raw/ifpga/base/opae_intel_max10.c @@ -6,6 +6,13 @@ #include #include "opae_osdep.h" +#ifndef TAILQ_FOREACH_SAFE +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST((head)); \ + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + int max10_sys_read(struct intel_max10_device *dev, unsigned int offset, unsigned int *val) { @@ -746,9 +753,9 @@ static int fdt_get_named_reg(const void *fdt, int node, const char *name, static void max10_sensor_uinit(struct intel_max10_device *dev) { - struct opae_sensor_info *info; + struct opae_sensor_info *info, *next; - TAILQ_FOREACH(info, &dev->opae_sensor_list, node) { + TAILQ_FOREACH_SAFE(info, &dev->opae_sensor_list, node, next) { TAILQ_REMOVE(&dev->opae_sensor_list, info, node); opae_free(info); } -- 2.45.2