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 3E84B45AE3 for ; Tue, 8 Oct 2024 18:49:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BB9FD410E7; Tue, 8 Oct 2024 18:49:15 +0200 (CEST) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id 45C1740E44 for ; Tue, 8 Oct 2024 18:49:04 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20bcae5e482so51667055ad.0 for ; Tue, 08 Oct 2024 09:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728406143; x=1729010943; 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=SVX6YKex3pxkwr3YKj45W0Gal5eP96aS78RAwyzOfuju0CIaTFbYeRAr+6Fhj2t1Re eBSHUbuPJKLNqTygxAkc6WA+5jiTysptCj1FJR2iP0656i5AL2lRbjC41FO/8HFyT8iI xEDWKyb12IMqa7FXcZI5gNenmtLUXRS6e/y/Nv2bPqfU/JoDxeITxr4eHuhvzUEyoR5N K+PxnE1z8WHCPRt1jmT57Tyi/Ty+0skmAwhnA+rz+tQWgxXXhAHm/urbgLtvIg4Qt67v 7K3Gf2x6q8aj9YzNe6OlQMWATdjKSf3EgMufXUeolbI7IzubvQlTrl8qcht6M/zU249D Y+yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728406143; x=1729010943; 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=lscfcehFnwN82xeP9c8U9Gu7FVrjjiAo0HkEqGpY1rzKmpqEc5BFgrFcjPMVPueeIW ORSJMIgDheRrA0suXZ6gzqBuUsVPvG0O+0jNGJnvHABb1ML2HQxLgaqKPoCN6CPm+r7c AbtlA3isHFn2lkeyVOqs2cIV7MMxCulIS1C5f8s+VAzkpN03zmsw9iXikK7r2sNP59Q9 /g6SApWNpbhdyh4LLHeMhIXFgf6rex1GIX4DAH2twp7vFg23CVGUXj5KDGBG20brqg7M /jhsldz5ev9qzTTolf5o0kQFTevFzlRG9N3tsOgCVv9Ts1/wcDOVbawI01u7EexO11c1 qcBQ== X-Forwarded-Encrypted: i=1; AJvYcCWfz+/eJPT5V/fO7PNSPRqggPWYF2I+7YzTf6gekcP6WIzcw7qTXGLSmxeDzXpSoNxu9KgHHkU=@dpdk.org X-Gm-Message-State: AOJu0YzWsR3KUIyRyJCdvzIJYT/jLBfxJmKZgst0cQUPtkA4Nzs+TCWF VHWH2IpIYYdG0yYjGQCQopTx8OR/xauQU8CHt2j0fp64xH6kbgKKm5YBY6cWJL1O1v7WDTPDk2f 0q7kvtg== X-Google-Smtp-Source: AGHT+IHwUSICVjrvFSfXMv7Rn2ynIZvDqebrCB2maze3biVXL2RDiiI0OwPgYk0ise5ri3+NKN4S3A== X-Received: by 2002:a17:902:c94e:b0:20b:6edd:e95a with SMTP id d9443c01a7336-20bfe022cfcmr243712745ad.3.1728406143478; Tue, 08 Oct 2024 09:49:03 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c54056bd9sm13832965ad.85.2024.10.08.09.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 09:49:03 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Rosen Xu , Tianfei Zhang , Andy Pei Subject: [PATCH v9 12/17] raw/ifpga/base: fix use after free Date: Tue, 8 Oct 2024 09:47:16 -0700 Message-ID: <20241008164842.139045-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241008164842.139045-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> <20241008164842.139045-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