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 5273945A50 for ; Sat, 28 Sep 2024 18:48:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F40740693; Sat, 28 Sep 2024 18:48:49 +0200 (CEST) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id BE52A40664 for ; Sat, 28 Sep 2024 18:48:37 +0200 (CEST) Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2e109539aedso45875a91.0 for ; Sat, 28 Sep 2024 09:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542117; x=1728146917; 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=eq4Ndv7u2AKHNdVYqW7kAA2/uXGCZGwlNL3A/FR7uEquNfOA2OXlNefr8FfAJTCUcP hsY5vWfj24MJ6eSAQqd5+dIpPGvXRycGC1C0YXnSL7eM5r0udoH1ilLxeZmuXv6of/+l 4yzCOhc9ORkC8We4hGHqScKUI11Xg8INddiHJnA6KS/Gh+9kc7NSHU+drbRbnrQeX7mC 7iPTLTIyvthXl1FQXyy3TvLceO+M8j1qvwtjgwUA8F2AC2mAhVh3jIpVHJolY82mR/Rp WuTFcZrq5ZDR8n+hex69THjLlz/tJkwRYwdjXUvpZagGzLCyYR1dK1ftMWkoj/H1jSqO /tIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542117; x=1728146917; 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=jRYUEVpZ9q/4O1MIlY+akxQomLQ2wQCfXUK8CRbK9zXRndG73HnLLgVMmXv0RsQQxd 1Px4hSCeIGVGX68Mlcgk8t1yZ92bdcmxQCNtnEwPY3elIOQYSvQhMcVfhZxGAAPL1EO6 AbE1zHw9sHtypyLmGMdce9h0eff/bLJLBRdunBntzSuCtKqBJx6OHMJnNTj4lTnsQFb5 LndXxkhv+6fqxpOmzV9OYlQYibUdpOn/vwn+ZdXe3O9JAHd5OMgXMhXGKhes9VF9tcgo 56Vi9RZM3I1+f76LU/DSm0JbN8sG/qeF1cpyXFHRJ6nzfGI5meN21/ulAS5DROa8+oim ihLQ== X-Forwarded-Encrypted: i=1; AJvYcCWsdgNWOz22kCBMhI6AbYdDO/G2V/Q1IyUOk0Hj8ME2UnOZKwVHnxY/jemHvxdY2y3isUygY7w=@dpdk.org X-Gm-Message-State: AOJu0YwZmenqNmY8DltP6jm5VfP7ZdiIs1lD2aMIJnoeGin8no/mHfJ+ w+co7IKZRMh8dM4q3bAueX/It13fR6+OJHJa7cZpOtE6FXL+6Hlhr42jOa3+ic4= X-Google-Smtp-Source: AGHT+IGvpkDWcCd8TpjQ8+dgnaVLi5YExQWg8hChS8PioG+8MPvFlGTM1eY24ToijozfrZmQjBbcAw== X-Received: by 2002:a17:90b:2390:b0:2d3:bd6f:a31e with SMTP id 98e67ed59e1d1-2e0b8e97a69mr7975732a91.28.1727542116966; Sat, 28 Sep 2024 09:48:36 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37e47c7dsm28854015ad.216.2024.09.28.09.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:36 -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 v2 13/16] raw/ifpga/base: fix use after free Date: Sat, 28 Sep 2024 09:47:21 -0700 Message-ID: <20240928164814.861933-14-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240928164814.861933-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> <20240928164814.861933-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