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 A242945A7E for ; Tue, 1 Oct 2024 18:37:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA56E40DCE; Tue, 1 Oct 2024 18:37:38 +0200 (CEST) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mails.dpdk.org (Postfix) with ESMTP id 2DBF34065F for ; Tue, 1 Oct 2024 18:37:30 +0200 (CEST) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-71dc4451fffso355738b3a.2 for ; Tue, 01 Oct 2024 09:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727800649; x=1728405449; 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=kXH/pUywnL3F195bWRszKKkx1NC1oIJgmdXXUPGOHF/6PO1j7ea/jL7iHXREEDUcfk AGMEE2iP2dCoT4FINBGyTh8YHLmB1MGALyxP1ERbkz+A0F+0UldZIXacwWUvZV9nARrs 8FohBFRoN/12F20x9nCqeNp78S7zhNwwWc4QZmoE3HYSHM1wZDAsE5OySCIB586igvbq Yka5zaO3eladAG9GFD25DhMH2V0EElb6BzfLS0oZFm8cORG/CkNhTutibJgcvVEKGyva Ub+W78PxYd/Q1e57JT3RzSmc0+dU5oPziBH9OBV3yrDwpWgMv/ekgF0oii7kSZjWcgAV /KeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727800649; x=1728405449; 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=gOM8CXvcBHnRTr9Z/5Ctmj23529EXWbHRMMTmnRuzlDOhU+UtFrCsVhkAX+dC9GHJI UxWG1yS7aSfbVBaNPGFDRn6DwwnSh7hEEeDj63zqLSS4FrYPkzrXwGC+QFigkWwNHbhW YwC4HjJxpsck3jfek77nrpHKOoawVyBahMX+IKShWnpZ+5SiTz4IgCiQcXKMspleZt8i OEic/8PWzKIZkb4DIR05Wc76VC0o1zaVEMv1D6qFcEhIPBec5DE1zdvJj4KpApf992ey GPniv4/oRemUOWitverI41lHYLVQTGjMtOFyhWB3JRr42usODEJrhCzI7Qh0P0HAZrBY D2pg== X-Forwarded-Encrypted: i=1; AJvYcCWSkHvdfdxXtF9CKFoNeVzYYUk3ywY0qmeHgNOElfZb3MeIbMALHg1wtw4McQxtSIt3p2M/WlE=@dpdk.org X-Gm-Message-State: AOJu0Yw7w3KxnQlItLEQaAJ/TJgG3OTuAFq1z+t5E7pFXqUYOjsprnfO x28MGjTXaBLfInSmfm3jI6RpJQOU+gtsHM0t2vbLCyLxndDjwAJTYW8mPGoGX+k= X-Google-Smtp-Source: AGHT+IG4E6wkCNsNGZKROwh0VteCGzcvCEWNXSNvC0fQM3u1Pc7762AKp+R1NJBm41vFL5yboTE1JQ== X-Received: by 2002:a05:6a00:10d2:b0:714:1ca1:7134 with SMTP id d2e1a72fcca58-71dc5d42599mr342621b3a.18.1727800649392; Tue, 01 Oct 2024 09:37:29 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b26518818sm8213565b3a.129.2024.10.01.09.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:37:29 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Rosen Xu , Tianfei Zhang , Andy Pei Subject: [PATCH v5 12/17] raw/ifpga/base: fix use after free Date: Tue, 1 Oct 2024 09:35:35 -0700 Message-ID: <20241001163708.355128-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241001163708.355128-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> <20241001163708.355128-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