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 4709245AE2 for ; Tue, 8 Oct 2024 17:43:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F393140E6E; Tue, 8 Oct 2024 17:43:32 +0200 (CEST) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id 6BC2540E15 for ; Tue, 8 Oct 2024 17:43:23 +0200 (CEST) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7db637d1e4eso4279184a12.2 for ; Tue, 08 Oct 2024 08:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728402202; x=1729007002; 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=DdmWrgw09tadbkT7NdxbMIVnjX7ZkAUu8O2SQsLsM2k=; b=AYPPjuWdXs5JaN7sDVsHw6z5JV2eZbxEeqALDYYey8EunP4BzCKyX89bWfuc3GKqKf 8fSb+5DylFShh3U8bS0eR91W4T8uarHvtLaL0W/FFxlSogRnM2Pa5S/vd+zOfEaHdi59 +UiwlVi2XxIgnNoVjdXFgJSyO/mqLGs/vevuda0e+wX0BIDe8aApD1Vl6U8MdIPUaGre d7LiMaSJz6e/yLYCu1zQiNw1UppwI2B2aLWUKiRVbolcQ2hDiwy2MnLvEqQx8XO7zb4O GGAcTMtgYOgIBnE4c0c7ATPzxhY7kDOXKsnSDlPep9RkzcWGIuKRi3YkBLjD3aoQ8smu XFBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728402202; x=1729007002; 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=DdmWrgw09tadbkT7NdxbMIVnjX7ZkAUu8O2SQsLsM2k=; b=w136l5LXzaES5uS+sLfYzoAkKf9UKZ3kt5NZ3RltWGEfPJhSDO79pHFNez30zkA9uT MzZUSC2sUdj+KhuIeSlr5uSOlsYiYmdejX9LPuEc+8/ZVNgDOcAGuFqUaDb1cx2xMCXe 8OlzeJgCFjCeNiWHvKrnn9d7DrFL6+4X3VtWbPD42UK4YRXo3TLJwdNTllcXJ9Qz4kBV PzfTOf4mplIXEzoUVt2bqAYILrVnrnDV1tHnroQTZ4q7GI9FEGT1kr9R3kOfrpR5sUG8 SXhGCXoFFkthX0+jqqeG87VI9JHKpl2w1eOAXoCyjNqXD9vFWMcyRpy5JBdRN0fsuvtC 80vA== X-Forwarded-Encrypted: i=1; AJvYcCUhsB3Lf1L1J56NN4GiACDnUVN23s3xDzVWUj4MookUEiek0huhBq0f9S1kgw8ZUhyNHHiCDHY=@dpdk.org X-Gm-Message-State: AOJu0Yy8LJ5XFsa7VRpWozCaYvS8XSRUGCDKaMTqJ9EeIARkthWHnGfX gf2OM+js4rIPZppkajx8xNMCXVIiP5jyRInUV2BtM44F8hiPh21UXCnnLkohJhA= X-Google-Smtp-Source: AGHT+IGUzMx6JH4QblW0mE+HBF1L9CNUMTGGN9HsyigWgfqUSWbsXe+RNPklNkk2o7s5G3S+zOEnBw== X-Received: by 2002:a05:6a20:6f9c:b0:1d1:13de:68c6 with SMTP id adf61e73a8af0-1d6dfa406b7mr24027349637.29.1728402202545; Tue, 08 Oct 2024 08:43:22 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0ccf01dsm6293527b3a.70.2024.10.08.08.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 08:43:22 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Rosen Xu , Tianfei Zhang , Andy Pei Subject: [PATCH v8 12/17] raw/ifpga/base: fix use after free Date: Tue, 8 Oct 2024 08:41:42 -0700 Message-ID: <20241008154301.66192-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241008154301.66192-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> <20241008154301.66192-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: 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