From patchwork Sat Sep 28 16:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144592 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2160645A50; Sat, 28 Sep 2024 18:48:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9232C4027A; Sat, 28 Sep 2024 18:48:30 +0200 (CEST) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id A2BB940273 for ; Sat, 28 Sep 2024 18:48:26 +0200 (CEST) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7198de684a7so2206381b3a.2 for ; Sat, 28 Sep 2024 09:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542106; x=1728146906; 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=r85PygVEKMsrCf5pc1qY5kVkFIpvpKhIoRqq+vwpAy0=; b=aK8J188GY6JtqVjjqKClb9ihY9Dtyylqe5qlxYbzumKgraiYL0+ge+ee3XlrmMVVY+ 9rSuM8ZzDvZFXfEVgGBs/tLXjEoCeI9KQY2PLu01ba6hyDakm4kAyFcP7iDtPGEkmvb4 SgrpAyRfcLekHqlKHYO7uQyHVd5bWiqgeKR6oOkIMXqPr0Frl6ZKYovTH+W+PZl4pAE+ 3WCDRJfxg3B510Pb1CIUmQKkfMNNtwNixRhCGzrohG6Bs3YoqaXfkvX4fwQ7HcxuTr/W fUpbB9vj+P3DK5T/jZU6dAANqaLUD05/uWf/94agPC65mmMlCWdKn9k+XDJ7yYEBsRt7 I3BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542106; x=1728146906; 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=r85PygVEKMsrCf5pc1qY5kVkFIpvpKhIoRqq+vwpAy0=; b=NOPx2p7QGcBdaLW/OZMkkas/qTgIHnYkSBnNFc31PK+AqOMCSvxJ3rP1MI4YRdWh/b lLpo2dDYldrS8Mipvlvb0CmQOp7dfxQ6BkBBAlgtUVo79fUi1alnaDl9ooEP9ys69eeW A/PEcro/rN/GCY9TkiuVJVJ7Noojsv81FS5wDV28sI6OkZST/YeGPwTfxsAGL4MGvFZ/ g2frHmX8GJofMBtKnceCgdZJwdkhd+UjCavmX5o3v/aWo/3RV3pQt5aFVye+z5Ln6TJz 4/yD3wjsLU/tTfxWvhTnt9htx/sjp62DPzlkQP+DgpUxluiHJXL3phyPgVEtkKpx1Vpj xqIA== X-Gm-Message-State: AOJu0Yz/dPa1UuV6CS8i79PmTCDd0/cNpaoc2BKD8K4XyG+8zXrvjtEM n+s4lQdIv7dlmA8nZb63gmwpmW7XHd7fDXONS3Gs09Qk0OsfQH22ZZMarQE436OF1lDJb1c2zjh k X-Google-Smtp-Source: AGHT+IGbhYTSJrIadaYf611BV7qsZBs5j4SF+feEqSQD977VRWWLcnkCAZ2zSEAbinphDkxdOJKwRw== X-Received: by 2002:a17:902:d510:b0:20b:46cb:8cbe with SMTP id d9443c01a7336-20b46cb8f2bmr87467145ad.29.1727542105707; Sat, 28 Sep 2024 09:48:25 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:25 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , Anatoly Burakov Subject: [PATCH v2 01/16] eal: add function attributes for allocation functions Date: Sat, 28 Sep 2024 09:47:09 -0700 Message-ID: <20240928164814.861933-2-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The allocation functions take a alignment argument that can be useful to hint the compiler optimizer. This is supported by Gcc and Clang but only useful with Gcc because Clang gives warning if alignment is 0. Recent versions of GCC have a malloc attribute that can be used to find mismatches between allocation and free; the typical problem caught is a pointer allocated with rte_malloc() that is then incorrectly freed using free(). Signed-off-by: Stephen Hemminger --- lib/eal/include/rte_common.h | 30 ++++++++++++++++++++++++++++++ lib/eal/include/rte_malloc.h | 24 ++++++++++++++++-------- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index eec0400dad..e73c9f2aef 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -228,6 +228,36 @@ typedef uint16_t unaligned_uint16_t; #define __rte_alloc_size(...) #endif +/** + * Tells the compiler that the function returns a value that points to + * memory aligned by a function argument. + * Not enabled on clang because it warns if align argument is zero. + */ +#if defined(RTE_CC_GCC) +#define __rte_alloc_align(align_arg) \ + __attribute__((alloc_align(align_arg))) +#else +#define __rte_alloc_align(...) +#endif + +/** + * Tells the compiler this is a function like malloc and that the pointer + * returned cannot alias any other pointer (ie new memory). + * + * Also, with recent GCC versions also able to track that proper + * dealloctor function is used for this pointer. + */ +#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000) +#define __rte_alloc_func(...) \ + __attribute__((malloc, malloc(__VA_ARGS__))) + +#elif defined(RTE_CC_GCC) || defined(RTE_CC_CLANG) +#define __rte_alloc_func(...) \ + __attribute__((malloc)) +#else +#define __rte_alloc_func(...) +#endif + #define RTE_PRIORITY_LOG 101 #define RTE_PRIORITY_BUS 110 #define RTE_PRIORITY_CLASS 120 diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h index 1f91e7bdde..cf3c174022 100644 --- a/lib/eal/include/rte_malloc.h +++ b/lib/eal/include/rte_malloc.h @@ -54,7 +54,8 @@ struct rte_malloc_socket_stats { */ void * rte_malloc(const char *type, size_t size, unsigned align) - __rte_alloc_size(2); + __rte_alloc_size(2) + __rte_alloc_align(3); /** * Allocate zeroed memory from the heap. @@ -81,7 +82,8 @@ rte_malloc(const char *type, size_t size, unsigned align) */ void * rte_zmalloc(const char *type, size_t size, unsigned align) - __rte_alloc_size(2); + __rte_alloc_size(2) + __rte_alloc_align(3); /** * Replacement function for calloc(), using huge-page memory. Memory area is @@ -108,7 +110,8 @@ rte_zmalloc(const char *type, size_t size, unsigned align) */ void * rte_calloc(const char *type, size_t num, size_t size, unsigned align) - __rte_alloc_size(2, 3); + __rte_alloc_size(2, 3) + __rte_alloc_align(4); /** * Replacement function for realloc(), using huge-page memory. Reserved area @@ -132,7 +135,8 @@ rte_calloc(const char *type, size_t num, size_t size, unsigned align) */ void * rte_realloc(void *ptr, size_t size, unsigned int align) - __rte_alloc_size(2); + __rte_alloc_size(2) + __rte_alloc_align(3); /** * Replacement function for realloc(), using huge-page memory. Reserved area @@ -158,7 +162,8 @@ rte_realloc(void *ptr, size_t size, unsigned int align) */ void * rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket) - __rte_alloc_size(2); + __rte_alloc_size(2) + __rte_alloc_align(3); /** * This function allocates memory from the huge-page area of memory. The memory @@ -185,7 +190,8 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket) */ void * rte_malloc_socket(const char *type, size_t size, unsigned align, int socket) - __rte_alloc_size(2); + __rte_alloc_size(2) + __rte_alloc_align(3); /** * Allocate zeroed memory from the heap. @@ -214,7 +220,8 @@ rte_malloc_socket(const char *type, size_t size, unsigned align, int socket) */ void * rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket) - __rte_alloc_size(2); + __rte_alloc_size(2) + __rte_alloc_align(3); /** * Replacement function for calloc(), using huge-page memory. Memory area is @@ -243,7 +250,8 @@ rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket) */ void * rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, int socket) - __rte_alloc_size(2, 3); + __rte_alloc_size(2, 3) + __rte_alloc_align(4); /** * Frees the memory space pointed to by the provided pointer. From patchwork Sat Sep 28 16:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144593 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1EEFC45A51; Sat, 28 Sep 2024 18:48:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE8C14042E; Sat, 28 Sep 2024 18:48:31 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id 42FA740273 for ; Sat, 28 Sep 2024 18:48:27 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2053525bd90so29638905ad.0 for ; Sat, 28 Sep 2024 09:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542106; x=1728146906; 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=TMGxOfORgNYeQMB92D3aLopJwJhBzDDfOXuG4U/9wME=; b=qzIajZqw+X2sy1WKHdnFpECxxbc3Yl192G3biWXAiY3Yafi2pJfCd+LQyYnxpmg+lm ywsQom6Bw8UeKZgYgjnyag/Xp6V+h8zxie7EDhvxQ8iUlP6/is30fK2gZPc/ABgdXS2R WA5iUGvknV7syrzp47vG5hDp0QtV4+vaUXqqYamw0igptfFW0rLi0PyJHh+gr/F07ubt /lODF+07ifA9NAxzrYf0mTWmUstY14pF8eYg/PYlcMizGKx4dK/Clgc7Uo1vAaCd+SLS fnZW5akiHsrGFJaNqu0ieHST2jLagBWWjgYSfCQqv6ofcFWK3CiPr8WuS1fYm2EbaNS9 s8aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542106; x=1728146906; 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=TMGxOfORgNYeQMB92D3aLopJwJhBzDDfOXuG4U/9wME=; b=oIcSPKNoYReK79jQDa0mvRmhSj4Xmda2QJZ4BJq3sVawJmNoN6qVjvGDfQ+QOHNkks trpfB2FZ2OYIw4V3sxV+oJp7HCM6mI4fsD+M21lIjYZGhxNlegjvGvjo27ea0XuEfAWH FsVHaoHbFIJLog46c6T41WMwcjIcTj2sS/kFQbKDYGTqpktFrIoiSJRljlO9WALb71y3 gUASDE4xPcDFuxQj20JUT1xhNnCYBViM45mMOL+TZFlPNLO3pLV1uxjLPd/cfmFP1WuJ Ih4AZJMD1i3UF9zj3JzpOm+XecpChjSFwWv6aXixod+r9cLMUCOqujqSNiMwoN2IKcHa dH9g== X-Gm-Message-State: AOJu0YyakTuDQg+yVQoHnJtzkNfoYqc0F/24DsFT3VKmeFKuehDrgYvD /03SdfVAnEbyC/sCbbNqfwnwde4V4f4ZWLf5xd5nBXB/ApKWshj5rApk9fj8ENPUeIPeocAlpv5 / X-Google-Smtp-Source: AGHT+IGwg/SZfoWlYx4yhmcN+E2LWfaExD9dUQ1/bzFS4BxmPRcVC32FiGbw+yE4xK+4yYsbuY+wAQ== X-Received: by 2002:a17:902:ce90:b0:20b:4c02:ee66 with SMTP id d9443c01a7336-20b4c02f00dmr87188765ad.43.1727542106494; Sat, 28 Sep 2024 09:48:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:26 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov , Tyler Retzlaff Subject: [PATCH v2 02/16] memzone: fix use after free in tracing Date: Sat, 28 Sep 2024 09:47:10 -0700 Message-ID: <20240928164814.861933-3-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Using the freed value for tracing is not a good idea. Although it is harmless for tracing, it will cause analyzers to flag this as unsafe. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_memzone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 2d9b6aa3e3..90efbb621d 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -331,9 +331,10 @@ rte_memzone_free(const struct rte_memzone *mz) rte_rwlock_write_unlock(&mcfg->mlock); + rte_eal_trace_memzone_free(name, addr, ret); + rte_free(addr); - rte_eal_trace_memzone_free(name, addr, ret); return ret; } From patchwork Sat Sep 28 16:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144594 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BC35B45A50; Sat, 28 Sep 2024 18:48:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1BDED40609; Sat, 28 Sep 2024 18:48:33 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 385FF402C0 for ; Sat, 28 Sep 2024 18:48:28 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-206b9455460so23378495ad.0 for ; Sat, 28 Sep 2024 09:48:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542107; x=1728146907; 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=2cYQdgVy1X6dw8VoCeBFzYfkLKZs2l4/Y2IfDXVHMDQ=; b=YpcnRospNaaffb+44wv6HDwkzywzXPD7GBVPuM7xS+0KOwtYzQb5RAgYt0gGpjfxSj y3+I9vnedkdjopYqd103mAMNAr//VAR19CZFLMH27qz9wcq6CTgiQ6XqmPeflghm7sV+ CToqozzxb+72O+BmE5vAXeCxc905yJqbrkZp54wHqmEBnVlQAML1hVKOR2PVKbCELgPe qNoSZWD4vmHuRCLjPN+UJ15Q5tNuuhbC1BrAbQNiiXZSM8pPSEcwapu+bkAffaktvE4h s3Nw8gXStcbTUppqoGsjqyB6iaBPh0c4z9zsdCmfxa5PEvv8JmRj8PgJiDMelJ876JvV su1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542107; x=1728146907; 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=2cYQdgVy1X6dw8VoCeBFzYfkLKZs2l4/Y2IfDXVHMDQ=; b=NWSr20I8PPWjL0umqQpgoID8NUmKNhRUsEyU2HP8UY/Z7Y5rxyuMvkrBxO1+N3MRCa nzmhYNH3pp+C7vf0aft7ZYcb43DcTY65OtLudXV6bHtlauW4KtfetxsL7kZe4vsSCDlc 1nxpdPAB0ffTIPpqM5ef2X9V6nNW5gdOByL/4VbsUIK/Kb8QaAXL/J+K3M34AfFnQqsd H/3BVYaTSZva9+jFvmT43qpe4ZEU+BUabO7LfAyuQ1JCq5XJPOACOwzZDLWo3yrlYT2K 6ROzpqHX9xv1t5PZ8CKKbR2mgbTaNwX5W/kktV8dOSm4syaPJl+fr0UH0QErojxc49ZK v3pA== X-Gm-Message-State: AOJu0YyLTDTb5Xs6AGKINOkiL3HMkeDE1w8mBgojAHKbSzS/jwz3gRF5 VrqXdyxOWDhGZtkTUxYEs/3gDVouKqU4kyB40thpeRw1m6hShdtKnFWF45pHveoPNspFMYIkmKZ E X-Google-Smtp-Source: AGHT+IE4zKJNatoMiIzh13bFx3/nAF5ftr68QkqPK4mHJIVYaH4ZKMtKzHIaOACNMqij5MZ1Qe+Gng== X-Received: by 2002:a17:902:e5c4:b0:205:4d27:616e with SMTP id d9443c01a7336-20b3668bdcamr108375575ad.22.1727542107416; Sat, 28 Sep 2024 09:48:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:27 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , vikas.gupta@broadcom.com, stable@dpdk.org, Ajit Khaparde , Raveendra Padasalagi , Akhil Goyal Subject: [PATCH v2 03/16] cryptodev/bcmfs: fix mis-matched free Date: Sat, 28 Sep 2024 09:47:11 -0700 Message-ID: <20240928164814.861933-4-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The device structure is allocated with rte_malloc() and then incorrectly freed with free(). This will lead to corrupt malloc pool. Bugzilla ID: 1552 Fixes: c8e79da7c676 ("crypto/bcmfs: introduce BCMFS driver") Cc: vikas.gupta@broadcom.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/crypto/bcmfs/bcmfs_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/bcmfs/bcmfs_device.c b/drivers/crypto/bcmfs/bcmfs_device.c index ada7ba342c..46522970d5 100644 --- a/drivers/crypto/bcmfs/bcmfs_device.c +++ b/drivers/crypto/bcmfs/bcmfs_device.c @@ -139,7 +139,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev, return fsdev; cleanup: - free(fsdev); + rte_free(fsdev); return NULL; } @@ -163,7 +163,7 @@ fsdev_release(struct bcmfs_device *fsdev) return; TAILQ_REMOVE(&fsdev_list, fsdev, next); - free(fsdev); + rte_free(fsdev); } static int From patchwork Sat Sep 28 16:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144595 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C704A45A51; 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 9176140608; Sat, 28 Sep 2024 18:48:34 +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 33D81402C8 for ; Sat, 28 Sep 2024 18:48:29 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-206b9455460so23378575ad.0 for ; Sat, 28 Sep 2024 09:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542108; x=1728146908; 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=le4GjgP5SCWBlNQZ0/lUAXoHeoD0MAUe464ixNio0Ms=; b=1sw9npz1Ifu/bKS6zt8ZYEjEyIIAIyqIy2+bhVZF5DUcTwg197e9nWxetQvUnAbpW3 AZc2kd7VdmzHEYuqCsKekSpmYDNICDWcjCf2p0CSjWJItFSCb4CHoeg3kC48FZKcKTO8 vah9vrlQa7Hcju+PJ5so7AMB5GukTvPhHA6cXN/LaGD9udqP43/v1kt3SqpLw5XCCYdL VlwtsTMQkoZHnlvh8SO/QhqcvzgfZnp223g0/7Yf4nLkqFi4BcJk6gUfRF3CwZFJgSYs ltXl0BxXZ4VlrW0WHJ/GkInsl4YQvvxA6UyXGuLqBmxmREsk/8dqh36r38IxiWrqiyMa kY1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542108; x=1728146908; 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=le4GjgP5SCWBlNQZ0/lUAXoHeoD0MAUe464ixNio0Ms=; b=r0ULLFvXSJmHw9dQQt3tU6i5fIRR4knDwFEE2kWuIiO5X6x+0aQ2gVY3iPexcGZnsN 7287boMQlgRC6iVk2ZFfpBjVvzuuItRd6T7zv9EiVgm3vkT7ON4F0Yfg+f5oIzVAOgN+ otcU9FC3u+Lw9FRSzJjXXy710L/7ltxMNxqObChrWu6F2CTW5wElqcr9HiekEGDCR3Z4 eLZ3M87CFC7ou0B1oDmjf0myJpFKHK4kj+wisuzCaSb7/yHI1Cy5lTFlQbIasg7yjCz8 wpcz4ozU0AlEelhfx945hXs0xpEzV1VlpOw0VIdCyA9oImeTlmaO91kozPqn3ej0XSfM TbnQ== X-Gm-Message-State: AOJu0Yzw+7CRrDKbLVGpgr6S/pEoflS9f8LbBQe19jXvuPERmMTHhveB 6CjeZCXYUSBEdk6KzPxkkpxbLuj2t3cVHHpGkASgMKavE6lnf5sXWj9vW2EfJ1alG/VyNu21EUV e X-Google-Smtp-Source: AGHT+IFf09mriK0E7T+aSA5dVZ6M55ZYnnCDZ0dcJcbmHQi0jxQPvEzJ8kzZF8pBQ/BojzU2vypIuA== X-Received: by 2002:a17:902:d4c5:b0:205:6121:1b2d with SMTP id d9443c01a7336-20b19bc04e9mr159903495ad.3.1727542108317; Sat, 28 Sep 2024 09:48:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:27 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , kevin.laatz@intel.com, stable@dpdk.org, Bruce Richardson , Conor Walsh Subject: [PATCH v2 04/16] dma/ixd: fix incorrect free function in cleanup Date: Sat, 28 Sep 2024 09:47:12 -0700 Message-ID: <20240928164814.861933-5-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The data structure is allocated with rte_malloc and incorrectly freed in cleanup logic using free. Bugzilla ID: 1549 Fixes: 9449330a8458 ("dma/idxd: create dmadev instances on PCI probe") Cc: kevin.laatz@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/dma/idxd/idxd_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c index 81637d9420..f89e2b41ff 100644 --- a/drivers/dma/idxd/idxd_pci.c +++ b/drivers/dma/idxd/idxd_pci.c @@ -301,7 +301,7 @@ init_pci_device(struct rte_pci_device *dev, struct idxd_dmadev *idxd, return nb_wqs; err: - free(pci); + rte_free(pci); return err_code; } From patchwork Sat Sep 28 16:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144596 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AF89745A50; Sat, 28 Sep 2024 18:48:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 430654065D; Sat, 28 Sep 2024 18:48:36 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 093E540273 for ; Sat, 28 Sep 2024 18:48:30 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-205659dc63aso29492805ad.1 for ; Sat, 28 Sep 2024 09:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542109; x=1728146909; 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=v8Aok7msKv3e47qbX+0n/i5gaFzOgWTvqMZUsJlTOls=; b=GPudUOheP8xEsD1/veltw/AIvXKZ9fAkLIslAR06VVHhmICcV9W0s2PNgWhOeDCxbQ SqjDZuKsGscGE+Y1E784Vco3wwvYKKEaNe68wT/Rv7h4k38QIq7RvIcBD0xj1Ve86Igc F0w9YdD91tZZPCsB++1kJ71ykoun8uMh6V4hd/fpuFONtt6voXf6a2sIkm2jY8cgJdK4 3rFj+Bj4y9EZPhDBHj0wocNrumENNsYROUf4r1XldpUxegpbdProb555cXvACKrUjRGt 010YdwP6dOtKb2Re03G5rzyt5z7gvcYm+4SXXqxtnRXq1YHk6BM+dsFBgMGfrDIoMFet pIhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542109; x=1728146909; 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=v8Aok7msKv3e47qbX+0n/i5gaFzOgWTvqMZUsJlTOls=; b=tAM8mcMzGKO0qGuM6pm0b8wljNH7K772BkMfiDsDBaUO/8ITnuKCce/8i2DeEKEXSq pHTWYMZYAFGeJXz0+7o1x5fZ2fGMZF6UZuId+pkt5M0nXC0xNFOVVB/wgUEFK1Jl+egJ 2hmh90oGTrmpwtorO01zGKv4UoqtpiA7nPCm/fNZSSd648csBKwRv0tuGfT49ylG6abU v7ob35vk1jZT4d53/HN+Ex8oUHiA0rW5PsKyTTd33udTttNQoX+gW15lQO4EY7Ai61sj jfphY/w/UPAgcS8TyMqBJcZRhZyk1v38ITp3oyxN1j/7bw5q+cmkrTpXitRU1/mZtAgZ P9Ug== X-Gm-Message-State: AOJu0YzSku09DnedJZh01CtE4Mo/DAaOcducF9NcD52vpX8RmD+SIoDE 33/etOzqAhpl2U4FZ4GSfI1ZPRQbhPXsEhW+8/61nzbMGCrsZJ0yzAPgAU94d/gPZOYL7qybuHN I X-Google-Smtp-Source: AGHT+IHzDrARRgZsh21qYFZ7zmTv99y2H8mFUdRiJnKSkVBhqi0cwH/m0YhGcFGZuxJqmQYr72GiRA== X-Received: by 2002:a17:902:db0a:b0:205:5f35:80b6 with SMTP id d9443c01a7336-20b37bcedc1mr105261305ad.61.1727542109213; Sat, 28 Sep 2024 09:48:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:28 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , sthotton@marvell.com, stable@dpdk.org, Pavan Nikhilesh Subject: [PATCH v2 05/16] event/cnxk: fix pointer mismatch in cleanup Date: Sat, 28 Sep 2024 09:47:13 -0700 Message-ID: <20240928164814.861933-6-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The code to cleanup in case of error was passing incorrect value to rte_free. The ports[] entry was allocated with rte_malloc and that should be used instead of the offset in that object. Fixes: 97a05c1fe634 ("event/cnxk: add port config") Cc: sthotton@marvell.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/event/cnxk/cnxk_eventdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/event/cnxk/cnxk_eventdev.c b/drivers/event/cnxk/cnxk_eventdev.c index 4b2d6bffa6..08c6ce0c07 100644 --- a/drivers/event/cnxk/cnxk_eventdev.c +++ b/drivers/event/cnxk/cnxk_eventdev.c @@ -121,8 +121,10 @@ cnxk_setup_event_ports(const struct rte_eventdev *event_dev, return 0; hws_fini: for (i = i - 1; i >= 0; i--) { + void *ws = event_dev->data->ports[i]; + event_dev->data->ports[i] = NULL; - rte_free(cnxk_sso_hws_get_cookie(event_dev->data->ports[i])); + rte_free(ws); } return -ENOMEM; } From patchwork Sat Sep 28 16:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144597 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F9C045A50; Sat, 28 Sep 2024 18:49:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A029040662; Sat, 28 Sep 2024 18:48:37 +0200 (CEST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id 00CA7402F1 for ; Sat, 28 Sep 2024 18:48:30 +0200 (CEST) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2068a7c9286so33703685ad.1 for ; Sat, 28 Sep 2024 09:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542110; x=1728146910; 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=qX5JnPmSsf+JiqhomIoZSRVblyTHeI0U9/zFsuxKGzU=; b=L0pZppOAl+rmoX1l2Zb+bcSFTvauQ0P1mGfs1Bt5COucP+rxO2ZjB+YAsVRWOKp0Ha ElcfMVNfohJPWW1Q8q71k5USnFWP0iAXbecNXFw6EwxGiokQGvORDzONaAQuTmaULnct c21Tx74TfjKEILlHz0gLd2iEE3EOWjjmPPUIAzUxsr375avdbo8LLB5YGl/wtv3LPnSB 60Vckx/lc+bAVjxPpeHty86eY2kvK8447m0TboOR1tChJMUHUfeXytFz4mFTfewWgiOF MKhtABRsEGBc+jEpPp/E1iWiu9xB8nKF2D1GEzf1DLRy1l4pEa2j9qJCZ7dpHOYDp1WY 9imA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542110; x=1728146910; 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=qX5JnPmSsf+JiqhomIoZSRVblyTHeI0U9/zFsuxKGzU=; b=MGKpLUhbQyODY9kAX2J8Cma7Cgd23YSe62TSwG9cDTmdy8Z7PghSyZ+del4C4l5RW4 nPTa58m6AdaO9/mQxVPZeYPyHxtdFUqrtjTy2bqFiHyW1GzSOwOTkzhfbgmU57FxNBAf GSKXyoJlIfss+x8CjPx4OeQzSg1UKwrJflUUvA7DqNcIYpfc9U/8gQcpUyYkQrt03uFt o6mtdS4FyaU98a6iTvAFMqzYCAbZFMugKO0EPUWuwgRV3H3jCZKE3HS/+wE08qHJO6Kt wJmd5Rft1TRu6/ErSimH/ZsLYSYnFNR+8z3FMRGE6JfCd3tOn2pJr2q4/v3u33IgFU4u /A8g== X-Gm-Message-State: AOJu0YzznBtYESnK6SRWmy9J9lyqsTX4eEwJhjCntQC8+0Og+9q+umP0 +dtWrKb6eOZjgj3RmqeYuiDElF3ZtnYwcN57dPedp9HqVOl6Oxy2h/At7mP1g02Y5oG0VN8ICcK r X-Google-Smtp-Source: AGHT+IEbuIYIYY6PPWvEia46YJD4FitoSCFSi3zwpTUIwhibSLcnD8OTrFHu/v+tc/yDIyyH0LVZgw== X-Received: by 2002:a17:903:3283:b0:205:4885:235e with SMTP id d9443c01a7336-20b37bb79ddmr82339105ad.39.1727542110167; Sat, 28 Sep 2024 09:48:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:29 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , jin.yu@intel.com, stable@dpdk.org, Maxime Coquelin , Chenbo Xia Subject: [PATCH v2 06/16] examples/vhost: fix free function mismatch Date: Sat, 28 Sep 2024 09:47:14 -0700 Message-ID: <20240928164814.861933-7-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The pointer bdev is allocated with rte_zmalloc() and then incorrectly freed with free() which will lead pool corruption. Bugzilla ID: 1553 Fixes: c19beb3f38cd ("examples/vhost_blk: introduce vhost storage sample") Cc: jin.yu@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- examples/vhost_blk/vhost_blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c index 03f1ac9c3f..9c9e326949 100644 --- a/examples/vhost_blk/vhost_blk.c +++ b/examples/vhost_blk/vhost_blk.c @@ -776,7 +776,7 @@ vhost_blk_bdev_construct(const char *bdev_name, bdev->data = rte_zmalloc(NULL, blk_cnt * blk_size, 0); if (!bdev->data) { fprintf(stderr, "No enough reserved huge memory for disk\n"); - free(bdev); + rte_free(bdev); return NULL; } From patchwork Sat Sep 28 16:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144598 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2943045A50; Sat, 28 Sep 2024 18:49:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED1C440665; Sat, 28 Sep 2024 18:48:38 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 382014060A for ; Sat, 28 Sep 2024 18:48:32 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20792913262so37292025ad.3 for ; Sat, 28 Sep 2024 09:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542111; x=1728146911; 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=OCC/7pypcVANnAzLwv1ykHuWe7RDnUwbh8hT6nfkbJU=; b=Kp0oAA0bE8XAI2bynUJUbSUYmI0yba5uQHq96NHKjROagheiRYaQhhcpPVsBwzpvBM Sm35XWVoNatpJw/OZUPjIJcO1qSPbGkzOmZNxdqVa6+p4y6galel1skGarX9OCB783sE 2DQjnE5AA+mcXOlBhH0TBjY29DgGHDwiotUt0luYRs5UZaRna7J0b6BjXVFs8tggu2LQ TrGCHtEQ4N31IkAVPaahsugTlzG03jvzM4Eh01KxUMU3lH+Koc+16wfbCiA6V0KouRQT Vja6kCk6V3A6GpUNgqbg9q9O1gL/6bFzG57FIgtT6F4IKiArDBGeDUwg/0Zvez6RnxQ1 qQ/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542111; x=1728146911; 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=OCC/7pypcVANnAzLwv1ykHuWe7RDnUwbh8hT6nfkbJU=; b=Yf37aO+lVIsZPb8oa/AAIWGI1H+5+UJvJyDm3LHRcijT8yvH2qCyjQeQ/gg1yf6D7N 0xAt+vqc5vnTTGRr9ujRL9eBOvY0rPJgIw0p8ZqG0BDn9+Txay23jO/M0RrvcP6q2S41 QYKMFXWp8lxQocofMFOKccA/t3gmnU3MyuYoNNeVPG2QS+AiEgJidvBaZFwoRT6ed+c9 B6mkpUQYdUFeR2lGhavPMy+rvgvZwU/kfEx/z+crS2KUqkGKS47eEpIkeomNEkX+s8eD /x7jceLdsOuGD4VeGl8R7Obm633Rp1km1LONRWL4pC2/PRRvlQJ9CMxV/Jyo7hUAcG9m 4Dow== X-Gm-Message-State: AOJu0Yxb9JnnRVsk+QPHSJ+E9+QllcwBdmHP8l2vnJYg3CIBMEN8K1Ii xITHBUArQL/dG+QpQ+EmMZ3nYlOOyIEHjFXUsIY2keGbD7rfWUl7k4SDR9I0cAyhhitNsuIrc0J q X-Google-Smtp-Source: AGHT+IG613I/l/Eu25gScUGL2krNLxal+eYJdhsq0f+CpdGkcbn70LzNl/iJtkPbozP7csjiULEH9Q== X-Received: by 2002:a17:903:18e:b0:20b:6c3c:d481 with SMTP id d9443c01a7336-20b6c3cd81cmr7328205ad.23.1727542111373; Sat, 28 Sep 2024 09:48:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , rbhansali@marvell.com, stable@dpdk.org, Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Harman Kalra Subject: [PATCH v2 07/16] net/cnxk: fix use-after-free Date: Sat, 28 Sep 2024 09:47:15 -0700 Message-ID: <20240928164814.861933-8-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The driver would refer to the mempool object after it was freed. Bugzilla ID: 1554 Fixes: 7ea187184a51 ("common/cnxk: support 1-N pool-aura per NIX LF") Cc: rbhansali@marvell.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/cnxk/cnxk_ethdev_sec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/cnxk/cnxk_ethdev_sec.c b/drivers/net/cnxk/cnxk_ethdev_sec.c index 6f5319e534..e428d2115d 100644 --- a/drivers/net/cnxk/cnxk_ethdev_sec.c +++ b/drivers/net/cnxk/cnxk_ethdev_sec.c @@ -136,8 +136,8 @@ cnxk_nix_inl_custom_meta_pool_cb(uintptr_t pmpool, uintptr_t *mpool, const char return -EINVAL; } - rte_mempool_free(hp); plt_free(hp->pool_config); + rte_mempool_free(hp); *aura_handle = 0; *mpool = 0; From patchwork Sat Sep 28 16:47:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144599 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 044DC45A50; Sat, 28 Sep 2024 18:49:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF3FE40673; Sat, 28 Sep 2024 18:48:40 +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 29E8E4060A for ; Sat, 28 Sep 2024 18:48:33 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2068acc8b98so33838805ad.3 for ; Sat, 28 Sep 2024 09:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542112; x=1728146912; 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=PmRTbddZLG2JxQ2OFMT3a37iU/8U3GJd/GKLMFfTKa0=; b=0O/HMTwbAH+2T5UdCiT8AajGM6Ezc1LM2gU9ewljWjmNXJ6WLEORxTB1vEFd2HLRvp 4JtoHw3hR8O2Pib/WHDp1SeXT+jxr24hj79XVrtkgxZWeKgNDL/PpW/2mM78tYO/C63u 8n3Hg2SspQq74gdH/ztNbBU2CffgzYpLInkK8R4MCzdjhjlIkkgsIxTQPfbIxG81TAv7 6U+cczTKov9fY6jbZzwRDQy77UYrT4WzhULiJalOpoIK4QlSN6B+apjcpPLAUNcO5Muw +A1hoz89tJGwXToVPRHRPUtvF7xVvADlVE+HxBSERFtyN53AqAevQX+Es1N+9yJXJ0hV mNzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542112; x=1728146912; 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=PmRTbddZLG2JxQ2OFMT3a37iU/8U3GJd/GKLMFfTKa0=; b=HwCo8YHW5Ru0BZx3Ej/QrJO2DBvuFLYclt2zhi/9tpwZGozvNmHiQpYRIczB5z69x/ /6QRcVEyjc9bmq4mX+aSL35tjI0vb+VyHTcWmjchVOEYIqBzEDJ8bKAl25SDItGJlouh TXwuatSdfqH+LcIxMA8ePhHDLEOvnJcZ1W4HqCuxlgyLW94/DytQF+lGygNx7z26NsNG sIuyFfpFP8+KPDc+m5+CT0ltE0kSadMPUc829K7f7einIKRW/TzNaL20WS2yJmsWWkDq 6+gz6UNiqcq6K/aLgWppFA9lr/Ydqa3B2ULm/w/4+fB9x7ozrU8NhSpdQYOcNbBLvt60 PDhw== X-Gm-Message-State: AOJu0YyLKl9QqnxoQ/rZALXJyU6CYX16DzyfB10qYR0zu/7qZcxkWMBE L3o3ibz3XvwYMu0EHx6+9574+l5CXrb5xmw9LAZctwE61aa8aydMQk4aSjEjqUv0lqZmi/wztoW j X-Google-Smtp-Source: AGHT+IGBx8QM/QJG+RSKmzGZHlTOcpyBtyv+9n6JZWcDoHw1sfW4BACkPFFrgwlwNP/MDXdxXwIs4g== X-Received: by 2002:a17:902:d2d2:b0:205:8a25:904b with SMTP id d9443c01a7336-20b37bcf765mr104068755ad.57.1727542112289; Sat, 28 Sep 2024 09:48:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Konstantin Ananyev , Ray Kinsella Subject: [PATCH v2 08/16] bpf: fix free mismatch if convert fails Date: Sat, 28 Sep 2024 09:47:16 -0700 Message-ID: <20240928164814.861933-9-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If conversion of cBF to eBPF fails then an object allocated with rte_malloc() would be passed to free(). [908/3201] Compiling C object lib/librte_bpf.a.p/bpf_bpf_convert.c.o ../lib/bpf/bpf_convert.c: In function ‘rte_bpf_convert’: ../lib/bpf/bpf_convert.c:559:17: warning: ‘free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc] 559 | free(prm); | ^~~~~~~~~ ../lib/bpf/bpf_convert.c:545:15: note: returned from ‘rte_zmalloc’ 545 | prm = rte_zmalloc("bpf_filter", | ^~~~~~~~~~~~~~~~~~~~~~~~~ 546 | sizeof(*prm) + ebpf_len * sizeof(*ebpf), 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- lib/bpf/bpf_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bpf/bpf_convert.c b/lib/bpf/bpf_convert.c index d7ff2b4325..e7e298c9cb 100644 --- a/lib/bpf/bpf_convert.c +++ b/lib/bpf/bpf_convert.c @@ -556,7 +556,7 @@ rte_bpf_convert(const struct bpf_program *prog) ret = bpf_convert_filter(prog->bf_insns, prog->bf_len, ebpf, &ebpf_len); if (ret < 0) { RTE_BPF_LOG_LINE(ERR, "%s: cannot convert cBPF to eBPF", __func__); - free(prm); + rte_free(prm); rte_errno = -ret; return NULL; } From patchwork Sat Sep 28 16:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144600 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B55645A50; Sat, 28 Sep 2024 18:49:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B8A740687; Sat, 28 Sep 2024 18:48:42 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id 02B904060F for ; Sat, 28 Sep 2024 18:48:33 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-20afdad26f5so40141515ad.1 for ; Sat, 28 Sep 2024 09:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542113; x=1728146913; 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=z4ivJFh4i+sS5Kt3NFIojkEwQfvp829B9cFV3HoaYyY=; b=bS1HAk9gro+uNyidhFeILTuLtL2q7syw1LShbSg4BFfZGLEvde46tR+TkBOGSVQ95o eZb5eZvr3Rezh+IVkwNXBAUyiuS+djvTUo/du3Qo6jBHgznq/OnjFUOvr1pYALYgE8JK bmTEMqPAoozihu6Zq7Wg/mePgHPXZqz8YNwgWZqV6cytp7wbrgtemxYXcVvDzlFwrlYq NH4nXOr/9Q9z6Sqtofp4DrdpRvG2HZ5GKHoaG6az6VowdCAy0H0KL+6sfzIKulNKKJ3T 35Gfsygc7hnMmUK8PxgSeToeM7qOA0hDzdJ9aPecxwZC9p5WXVtAgQZpqkRKuP+70+A9 OL5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542113; x=1728146913; 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=z4ivJFh4i+sS5Kt3NFIojkEwQfvp829B9cFV3HoaYyY=; b=CInqAeu+gmeXhLdSqSt/LXtgKFqiApE56PMU3acLe7x0L5ZAqgd0sc4rsuH2K8OzZV 85dOQGJftMfDvcPXHmQ9Wczt4yK0thBy0YKnNBDUdAW3kEPe+v7UjpG+4RetTsteR57W ItFkIJU2fJlfJs5rpiMGh5wyafmeXGB/OcrMw87Y6sQawvY2tdOQQDByU1siEnVoNveG ykwnEfnm1e9OdOHMdino+DGYLGl1HVvSVHYIHaX4mbt2nHGpkJYdrbTqK/jj+v9NNm8z ZzXkOkjGe/6+mfSnRw81Zbj6nNxw64adQSLsVLovW49qEQNy06ai+SP4fWjwQvleKNLy 9lNA== X-Gm-Message-State: AOJu0YwC28h19asvDNcskts6GG24h58P2NBCwwRs/cQWWlM2dU6vjCHo PlDodWL1nLpUvpSjD3bZS+QwkiTyPfJMgvSrShbhPXIFLlJEUuXi8yvVFgb8/Ezs3EUNpjeEnoW s X-Google-Smtp-Source: AGHT+IEIDE0c/bxLw3KL+h2WWVMhGUKH2x3vGX4DXtU5zvSYMq4hbtrHR+Kvy6CC26YthJpr4VTk7w== X-Received: by 2002:a17:902:f688:b0:207:15d0:8b0a with SMTP id d9443c01a7336-20b367d5b27mr119197275ad.10.1727542113191; Sat, 28 Sep 2024 09:48:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:32 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , wei.zhao1@intel.com, stable@dpdk.org Subject: [PATCH v2 09/16] net/e1000: fix use-after-free Date: Sat, 28 Sep 2024 09:47:17 -0700 Message-ID: <20240928164814.861933-10-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The driver cleanup code was freeing the filter object then dereferencing it. Bugzilla ID: 1550 Fixes: 6a4d050e2855 ("net/igb: flush all the filter") Cc: wei.zhao1@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/e1000/igb_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 095be27b08..973d0d2407 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -3907,11 +3907,11 @@ igb_delete_2tuple_filter(struct rte_eth_dev *dev, filter_info->twotuple_mask &= ~(1 << filter->index); TAILQ_REMOVE(&filter_info->twotuple_list, filter, entries); - rte_free(filter); E1000_WRITE_REG(hw, E1000_TTQF(filter->index), E1000_TTQF_DISABLE_MASK); E1000_WRITE_REG(hw, E1000_IMIR(filter->index), 0); E1000_WRITE_REG(hw, E1000_IMIREXT(filter->index), 0); + rte_free(filter); return 0; } @@ -4348,7 +4348,6 @@ igb_delete_5tuple_filter_82576(struct rte_eth_dev *dev, filter_info->fivetuple_mask &= ~(1 << filter->index); TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries); - rte_free(filter); E1000_WRITE_REG(hw, E1000_FTQF(filter->index), E1000_FTQF_VF_BP | E1000_FTQF_MASK); @@ -4357,6 +4356,7 @@ igb_delete_5tuple_filter_82576(struct rte_eth_dev *dev, E1000_WRITE_REG(hw, E1000_SPQF(filter->index), 0); E1000_WRITE_REG(hw, E1000_IMIR(filter->index), 0); E1000_WRITE_REG(hw, E1000_IMIREXT(filter->index), 0); + rte_free(filter); return 0; } From patchwork Sat Sep 28 16:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144601 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 089E045A50; Sat, 28 Sep 2024 18:49:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD1BC40691; Sat, 28 Sep 2024 18:48:43 +0200 (CEST) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id DCDA740615 for ; Sat, 28 Sep 2024 18:48:34 +0200 (CEST) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20aff65aa37so26323235ad.1 for ; Sat, 28 Sep 2024 09:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542114; x=1728146914; 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=AWtNO2OBtYWxx0dUrqnpcWt4hXt0bjrxhYc0+b3GRJQ=; b=W/XOD9sHCflT0KUmrXpRid/oE7d7BTwfch2ZkwtfqmdluQc1CV+Ds73ot+x1aIPTVu CecX5CNFdl2aMZgs1+GOj25co3MwCTLAWVd2gztMpYppx+o9me0hyoZc4IRF/IEhcVUO tFSCmE1PnAHLpc/PfE5wqvsR0kIjMsjO69OnieS8jyrFzUwds5aGAEBacaY0OUJDwlPc i5u/NkqUeHflb2N2hw8h4QQD24T8sd4XQz18b4pmoPw1pjTZLCjYRmckrnLorw4hro3X gRVLKLCM3hEaQz4TGasYPANs/sqV94gwR8ah9fBp4a2tpqiJs9vMzKRCb2tOzVk8U56y Ww0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542114; x=1728146914; 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=AWtNO2OBtYWxx0dUrqnpcWt4hXt0bjrxhYc0+b3GRJQ=; b=fsbD3VzHhOKfd54Um5lQ/8KVoSoAXyVgFhhwTJPWV9S6HjeEEAb2RNypHyuQmVDKNE KImKzqnkt+7nAlmLZnsbFJ1iSBs3mtfzf6Do8cjda5nHGyE9Ez2B5uA/QeyUibkmi8Li DNwDQMXuQkQtd+2M2717HDR1w3eT4rV1r2D5kKNzpd/dafbREP3KE4raM/qNRbQOnOBP oGyKmSxXRQDVlLKidIhYTouTBUzBlYIx7gxxenK+eS2H5+xdiBzrcV5GgASH83ruf/fu q46PpynnulaqLGsWngXckeN0JYZzGEaGapWExiNFBoPyr4TfYyxjaGEk9qd8fjm9WrGc FptQ== X-Gm-Message-State: AOJu0YyE7rhBy9zELr0F5u66HMzFOKQS0MEaKb6gUD8zqvDOOBzXmDPu SnHko5bGXY+HxXcwi/8YDHnSgx95rqj+Vnh+Bmq5OnAYJc7uiHE4ujXk2WJtmJlY9+738h4N4bT m X-Google-Smtp-Source: AGHT+IEreCOI7WorDacLx1DZKycA6fIF9CsDLO5uzIIzcgN5YG9WcRe2e27zkCZWxvkN45p8+j34EA== X-Received: by 2002:a17:902:e802:b0:20b:6773:a00 with SMTP id d9443c01a7336-20b67730cb8mr19460345ad.32.1727542114060; Sat, 28 Sep 2024 09:48:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:33 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Ivan Malov , Andrew Rybchenko , Andy Moreton Subject: [PATCH v2 10/16] net/sfc: fix use-after-free warning messages Date: Sat, 28 Sep 2024 09:47:18 -0700 Message-ID: <20240928164814.861933-11-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If compiler detection of use-after-free is enabled then this drivers debug messages will cause warnings. Change to move debug message before the object is freed. Bugzilla ID: 1551 Fixes: 55c1238246d5 ("net/sfc: add more debug messages to transfer flows") Signed-off-by: Stephen Hemminger Reviewed-by: Ivan Malov --- drivers/net/sfc/sfc_flow_rss.c | 4 ++-- drivers/net/sfc/sfc_mae.c | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/net/sfc/sfc_flow_rss.c b/drivers/net/sfc/sfc_flow_rss.c index e28c943335..8e2749833b 100644 --- a/drivers/net/sfc/sfc_flow_rss.c +++ b/drivers/net/sfc/sfc_flow_rss.c @@ -303,9 +303,9 @@ sfc_flow_rss_ctx_del(struct sfc_adapter *sa, struct sfc_flow_rss_ctx *ctx) TAILQ_REMOVE(&flow_rss->ctx_list, ctx, entries); rte_free(ctx->qid_offsets); - rte_free(ctx); - sfc_dbg(sa, "flow-rss: deleted ctx=%p", ctx); + + rte_free(ctx); } static int diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 60ff6d2181..8f74f10390 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -400,9 +400,8 @@ sfc_mae_outer_rule_del(struct sfc_adapter *sa, efx_mae_match_spec_fini(sa->nic, rule->match_spec); TAILQ_REMOVE(&mae->outer_rules, rule, entries); - rte_free(rule); - sfc_dbg(sa, "deleted outer_rule=%p", rule); + rte_free(rule); } static int @@ -585,9 +584,8 @@ sfc_mae_mac_addr_del(struct sfc_adapter *sa, struct sfc_mae_mac_addr *mac_addr) } TAILQ_REMOVE(&mae->mac_addrs, mac_addr, entries); - rte_free(mac_addr); - sfc_dbg(sa, "deleted mac_addr=%p", mac_addr); + rte_free(mac_addr); } enum sfc_mae_mac_addr_type { @@ -785,10 +783,10 @@ sfc_mae_encap_header_del(struct sfc_adapter *sa, } TAILQ_REMOVE(&mae->encap_headers, encap_header, entries); + sfc_dbg(sa, "deleted encap_header=%p", encap_header); + rte_free(encap_header->buf); rte_free(encap_header); - - sfc_dbg(sa, "deleted encap_header=%p", encap_header); } static int @@ -983,9 +981,8 @@ sfc_mae_counter_del(struct sfc_adapter *sa, struct sfc_mae_counter *counter) } TAILQ_REMOVE(&mae->counters, counter, entries); - rte_free(counter); - sfc_dbg(sa, "deleted counter=%p", counter); + rte_free(counter); } static int @@ -1165,9 +1162,8 @@ sfc_mae_action_set_del(struct sfc_adapter *sa, sfc_mae_mac_addr_del(sa, action_set->src_mac_addr); sfc_mae_counter_del(sa, action_set->counter); TAILQ_REMOVE(&mae->action_sets, action_set, entries); - rte_free(action_set); - sfc_dbg(sa, "deleted action_set=%p", action_set); + rte_free(action_set); } static int @@ -1401,10 +1397,10 @@ sfc_mae_action_set_list_del(struct sfc_adapter *sa, sfc_mae_action_set_del(sa, action_set_list->action_sets[i]); TAILQ_REMOVE(&mae->action_set_lists, action_set_list, entries); + sfc_dbg(sa, "deleted action_set_list=%p", action_set_list); + rte_free(action_set_list->action_sets); rte_free(action_set_list); - - sfc_dbg(sa, "deleted action_set_list=%p", action_set_list); } static int @@ -1667,9 +1663,8 @@ sfc_mae_action_rule_del(struct sfc_adapter *sa, sfc_mae_outer_rule_del(sa, rule->outer_rule); TAILQ_REMOVE(&mae->action_rules, rule, entries); - rte_free(rule); - sfc_dbg(sa, "deleted action_rule=%p", rule); + rte_free(rule); } static int From patchwork Sat Sep 28 16:47:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144602 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 196B045A50; Sat, 28 Sep 2024 18:49:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4AA66406B4; Sat, 28 Sep 2024 18:48:45 +0200 (CEST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id D3E9640647 for ; Sat, 28 Sep 2024 18:48:35 +0200 (CEST) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-205659dc63aso29493145ad.1 for ; Sat, 28 Sep 2024 09:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542115; x=1728146915; 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=5rIUygztSKBo8hXRl59YcTQfr34c1sPRuIObTaqdxdQ=; b=igv7H2LGr40PrX5C7PPQvmJLSQgVopDkrd4Lp94/mVsEuSHk7J3J1l3r6pPSf+c1Na Z3mAZnc43sPH2XnlIRpp20mRbSHrv9jbhoPxJvVOKMrf7Yv867fthB/pY2x0IvnsqQ7w OBERIkaKNT5G4tpgeSK0KS8lXac0l3M4PhibZVAmz4R+L8yOqaOtdBPTGHUEgGyIfUPz qacPN7H2PhvzwfcK19290Cv0xbvao0inebZZZpsLZR3UlYoGuICR80AONjGvm1K8OGSj 6rO2mmJWIQNFXqEZteA85cUgqo8A6VGaxk8lHjsGFLIb+z3n0ts+45V3Da5bm8jMk5Ud ly/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542115; x=1728146915; 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=5rIUygztSKBo8hXRl59YcTQfr34c1sPRuIObTaqdxdQ=; b=ompuZYQJIXtEehnRJnJkvA31a8KhaKKT1qvE42Cnun2OUKYec6nF7ErLfLuByj31zx uI5tyhjucDeV6PWS/VryGfXq+nVk+sa0Dqo88f1aHWmmKopfZXV4QYVZcqEm44HabO35 bEtt7RzNvs7x1XSB0ksA1AEIjHi3yF7LLOziI5Fsu5NS8nVJBDT4H0qErX/rdWG7ZbMK 3ricS0BJAmGX4W7U5Nsl3I9Mayn+Y1NRC3Wed6MXwiERcQAf24NeB8hQRUlhh4arOykJ aTVamG0BM5eWGOA3sgXUvWqxHoT7SBRnlbPfM6bl6IYZ37T60TvvGfEAXYJ7UnigyLBg WFNw== X-Gm-Message-State: AOJu0Yx4Zwn8I1t9S5bv0MdutHoMMeBCfQn7CXYJWrmoPUAE9WP1tHAT pfvJIJjKOds3sunS/RN6ltgCTaTV5ElAS2doM1IrpbUJj3K+8xf3yzUaSHfu4Ljin9iHz8Zb6Pd J X-Google-Smtp-Source: AGHT+IH/qgzXbp8zuaPZc0ETJFx23qPLhwFdw7wySEEWkn7GBMDnYY0desEFfbO/hbeCz7bn3/BlDQ== X-Received: by 2002:a17:902:d4c2:b0:207:13a3:a896 with SMTP id d9443c01a7336-20b369d605fmr95182015ad.23.1727542115024; Sat, 28 Sep 2024 09:48:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:34 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , wenjing.qiao@intel.com, stable@dpdk.org, Qi Zhang Subject: [PATCH v2 11/16] net/cpfl: fix free of nonheap object Date: Sat, 28 Sep 2024 09:47:19 -0700 Message-ID: <20240928164814.861933-12-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org With proper annotation, GCC discovers that this driver is calling rte_free() on an object that was not allocated (it is part of array in another object). In function ‘cpfl_flow_js_mr_layout’, inlined from ‘cpfl_flow_js_mr_action’ at ../drivers/net/cpfl/cpfl_flow_parser.c:848:9, inlined from ‘cpfl_flow_js_mod_rule’ at ../drivers/net/cpfl/cpfl_flow_parser.c:908:9, inlined from ‘cpfl_parser_init’ at ../drivers/net/cpfl/cpfl_flow_parser.c:932:8, inlined from ‘cpfl_parser_create’ at ../drivers/net/cpfl/cpfl_flow_parser.c:959:8: ../drivers/net/cpfl/cpfl_flow_parser.c:740:9: warning: ‘rte_free’ called on pointer ‘*parser.modifications’ with nonzero offset [28, 15479062120396] [-Wfree-nonheap-object] 740 | rte_free(js_mod->layout); | ^~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 6cc97c9971d7 ("net/cpfl: build action mapping rules from JSON") Cc: wenjing.qiao@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/cpfl/cpfl_flow_parser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/cpfl/cpfl_flow_parser.c b/drivers/net/cpfl/cpfl_flow_parser.c index 40569ddc6f..30abaad7c8 100644 --- a/drivers/net/cpfl/cpfl_flow_parser.c +++ b/drivers/net/cpfl/cpfl_flow_parser.c @@ -737,7 +737,6 @@ cpfl_flow_js_mr_layout(json_t *ob_layouts, struct cpfl_flow_js_mr_action_mod *js return 0; err: - rte_free(js_mod->layout); return -EINVAL; } From patchwork Sat Sep 28 16:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144603 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 87E4745A50; Sat, 28 Sep 2024 18:49:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 973EB406BA; Sat, 28 Sep 2024 18:48:46 +0200 (CEST) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id F218840656 for ; Sat, 28 Sep 2024 18:48:36 +0200 (CEST) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2053616fa36so40455475ad.0 for ; Sat, 28 Sep 2024 09:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542116; x=1728146916; 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=aBYpM1ABa9i52itRxAsY1yKqaNfS+h1U5AU5hu6gdcM=; b=Cl/xmvmuM8MgQUF/5FKMFRUeRMUZkVAG9/rOByyWO4bs8XW16mkYt37eYeIgXRvDAV 1ISMA2sz3gRMiBz9Mo4G57Gn2VM2xjitg1eqxiUKLUmxZM9T+LmheCG/HH0JFzWtAZ0+ MBHwqKv4Sy4gmuCS+dpIu8j99mbj3Uj23+beZQkjcbwnYt0N1SvEQSCXEUePIBqBEbX3 +YSTcnL/5RHOJLq/Tm21Vq/zZ1HlAgn30+iGq2WfnaDvP4ayDcTlRqoJu+RkNbsbLf3a cRU9Le+FzIo//xZQ2z9g3wEaN6TB5g6KHpqK7t5dXkRf45spfswEmyD3H+VttMoplXxv vUmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542116; x=1728146916; 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=aBYpM1ABa9i52itRxAsY1yKqaNfS+h1U5AU5hu6gdcM=; b=kkoZk043uRnluM3dLabMfom3LUALj8e8ba7R7O3b6kg9AWM/LO9b3TrSK0ppuLhw0Q k7LWeQ0pg8cxHN/XLdIaZR+xcX+KHGa/Qt+JZdo68DJgmcFSPDJh9lYFao+5VCoF8eoq cCMHOhSKRct9fN+njAtpNIkFc0t35Jl0jXhQ1hQZfWOJUzgcXkQTm19NBBCpqLg4fCZF nrzNEIqASWG0B0pMwb38MsbkejSKerydCihgLbRKyN/7490wdKWDeEYzC3N7yP+mm57f cCsMR7ioEoYNkJf0MlFeQb7bUXEDayRy13nulFMKs+kKXIAoUiHVzppcO1rll6ozINpU Qe8g== X-Gm-Message-State: AOJu0Ywz8yfnxbGM2HK2fVIBzprbDBvjNgDVho0aihG75Hh7bceexgL0 cD3swBmmpNE/1s/f/9Js1H1y97NVVBKsxfdqBPckTQEGtLEZIgCfdHIwdznxWs1OV1tr0mXI9/5 A X-Google-Smtp-Source: AGHT+IECqzAnE5SF4oX+xIpsn+Ih/TevdrNmihGL3khtbvtjwOifI7DICZppgJw933TsV28dp2L9CA== X-Received: by 2002:a17:903:228b:b0:207:3fd0:13ec with SMTP id d9443c01a7336-20b367e9354mr120612035ad.17.1727542116079; 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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , chaoyong.he@corigine.com, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v2 12/16] net/nfp: fix duplicate call to rte_free Date: Sat, 28 Sep 2024 09:47:20 -0700 Message-ID: <20240928164814.861933-13-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Calling rte_free twice on same object will corrupt the heap. Warning is: In function 'nfp_pre_tun_table_check_del', inlined from 'nfp_flow_destroy' at ../drivers/net/nfp/flower/nfp_flower_flow.c:5143:9: ../drivers/net/nfp/flower/nfp_flower_flow.c:3830:9: error: pointer 'entry' used after 'rte_free' [-Werror=use-after-free] 3830 | rte_free(entry); | ^~~~~~~~~~~~~~~ ../drivers/net/nfp/flower/nfp_flower_flow.c:3825:9: note: call to 'rte_free' here 3825 | rte_free(entry); | ^~~~~~~~~~~~~~~ Bugzilla ID: 1555 Fixes: d3c33bdf1f18 ("net/nfp: prepare for IPv4 UDP tunnel decap flow action") Cc: chaoyong.he@corigine.com Signed-off-by: Stephen Hemminger --- drivers/net/nfp/flower/nfp_flower_flow.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index 0078455658..64a0062c8b 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -3822,7 +3822,6 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr, goto free_entry; } - rte_free(entry); rte_free(find_entry); priv->pre_tun_cnt--; From patchwork Sat Sep 28 16:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144604 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B9C8845A50; Sat, 28 Sep 2024 18:49:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F138340A67; Sat, 28 Sep 2024 18:48:47 +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 BE53B40665 for ; Sat, 28 Sep 2024 18:48:37 +0200 (CEST) Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2dee9d86f4dso2767365a91.3 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=QXr4WyxTOBGKH2ZVGgj88tlm7kqegZAlk2NCMcZ1VK83WF7RkWJZykIJOosrsD5TRY QrQZ0E0GYTYCCGCfgtO3G1x/95tPi71An+TPIgP0VTC/YxBZmj8KVHPm9rm2QBJ4VcYS 7qTuwBmlbVehIwhhErbsUmwMi3fEK8Oq10gT+D7bCrrZUvxQCJsN5r3HVyj9ztTH2O0N ivS7ToxEvDNnKTSKXnnYprEWnS5DJHZ3q6AuWuZDCHMGiQUSqrDU2zgbmkBMyJqcwd3M BA6i9S1YfDwDL0ephdFE3iLJidJX8b8umOqII9lCrlZbiycK4ny1bOIyGbjG8o72OsHt hslg== X-Gm-Message-State: AOJu0YzC5nwHju0Diqwc0pzSvg+BUkVCTF31t5j2y6VRW7DKd9430Dzq 4DIfkWz1GmXA/UU6HieroxWjisIzbRYjt4XdOXj/qHNANwhQVxaOvSsmbjRLIjQMsqKFXJh3p74 / 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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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); } From patchwork Sat Sep 28 16:47:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144605 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D785345A50; Sat, 28 Sep 2024 18:49:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C73C40A6D; Sat, 28 Sep 2024 18:48:49 +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 8FECA40657 for ; Sat, 28 Sep 2024 18:48:38 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-206aee4073cso34929575ad.1 for ; Sat, 28 Sep 2024 09:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542118; x=1728146918; 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=CeP4jlg/nwoX9BqyloYvigRPb4ZdUkxrz0ArQrEvutk=; b=r6VkJ92mBLUEs6ASZ/C5jiwDh9VNT1k7ZVgRfmsZ+TFlOtscfDlwwU/winkEVJXjwd s0vznS8gykYabhvuz3Zte+dXLYP3XYyiA+Tpi2Jh3KQGzSyVW/WR4eKfITYhJfgWiyD5 NTKi8ctLVqdyZS1hyMOybK93eh0wHuh6samF8nEp85YTjAWE1IuP6kRv7cIAWazyQiuX rEAeiSS8apucBkWyLmgAwc6h0+72eSCGbGphcNIrmailHzasna05e2MDwsQTwbqAeBwK 5IsTBm/hqw1Tof7FBqKkRQG62w3ABk1gOL1MLQEPx84sREWdSYLZG/OfllIiJN+YWuub VZFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542118; x=1728146918; 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=CeP4jlg/nwoX9BqyloYvigRPb4ZdUkxrz0ArQrEvutk=; b=lnLcflWa/bXzbKCTjIft7U6DtZ7yFtoIFVkqD32E7XMGF6jpe6cLAaQgKH6OS73Fvo nb//fBmNddagFUfto/6z94EWJKQQvFaHZ6Poknl2wGZ98xPwGtWVKiTMeFutSTnLwPRg aJPq1Hjp7cNvUK2IuRWIJUAxlvI8Dw6QTX++r8XMFS5VzX3t53XJTzHJiiA+G36ji13Z lM03OF2Z196vqeerbR73OruZDNuORcZ1R/5nSGhEcCiSe2oDfg9kBFUVOCTEa8X/mGMH daffUqapMtIMyZjQ21SmskTzjtaB53DJkq6jH+ho3EaSUnnTjrYmgWOJtm75aq0L3F7L FFnA== X-Gm-Message-State: AOJu0YySddjfpN9a00wkBjwxuVEv1LSn8E9Zd0AeUXLRhjSLo6tePiZ6 qZWWITmVWhlHdaFgo+0rxZx2AQJd7qF54YcVnDwwXXxE2x6KSqRzs3PTKuOngr20rx8x0slUi+f Q X-Google-Smtp-Source: AGHT+IFwRSopIx6mTyy100L1Bt42MEI/3JnNcp0IVpZcSx0YxeeJXwjdWrUD+eraGbXqqwaJWpjBjw== X-Received: by 2002:a17:902:e882:b0:202:3a49:acec with SMTP id d9443c01a7336-20b367d02bemr123168655ad.11.1727542117792; Sat, 28 Sep 2024 09:48:37 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:37 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , arkadiuszx.kusztal@intel.com, Kai Ji , Ciara Power Subject: [PATCH v2 14/16] common/qat: fix use after free Date: Sat, 28 Sep 2024 09:47:22 -0700 Message-ID: <20240928164814.861933-15-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Checking return value of rte_memzone_free() is pointless and if it failed then it was because the pointer was null. Fixes: 7b1374b1e6e7 ("common/qat: limit configuration to primary process") Cc: arkadiuszx.kusztal@intel.com Signed-off-by: Stephen Hemminger --- drivers/common/qat/qat_device.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c index 4a972a83bd..bca88fd9bd 100644 --- a/drivers/common/qat/qat_device.c +++ b/drivers/common/qat/qat_device.c @@ -390,11 +390,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev) return qat_dev; error: rte_free(qat_dev->command_line); - if (rte_memzone_free(qat_dev_mz)) { - QAT_LOG(DEBUG, - "QAT internal error! Trying to free already allocated memzone: %s", - qat_dev_mz->name); - } + rte_memzone_free(qat_dev_mz); return NULL; } From patchwork Sat Sep 28 16:47:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144606 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 25B9D45A50; Sat, 28 Sep 2024 18:49:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D174B40A76; Sat, 28 Sep 2024 18:48:50 +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 8E2B840657 for ; Sat, 28 Sep 2024 18:48:39 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-206b9455460so23379015ad.0 for ; Sat, 28 Sep 2024 09:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542119; x=1728146919; 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=XsAhH0ZX3ddPj6j1bm6B9FX9Jp/gzrG8giI4aV5Q6Us=; b=oy2gX4AQGp3dE/5/vvLahAWWcUnXctpR1y2WUPi+YlYw5Auq9jOmJOP/dP6S81272n Z0xeRWbiIb4ZfZgU1OADTjX6+STwAYamOceW5bmDtcIxM+B+G6kOL4zxYBel6jvql4xx /DcXGxYETYInaMbRPitTeWi3ILr58q1R0YN7guw5StyDFlp/O7wh4y/EYU9on+C/wyu9 7IkuwSgPp/up7nY8MzExX1OEXJsgjFX3/SqTs/drTBa6k3FeuDNdBvCpQTHx+BHKGxC/ Fspt9GpEbZpj8H6SUZry2SQ5CWumjo3EWWPcSlY3ehSd2WeztXz70qPlhairGTgJxMCY Zanw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542119; x=1728146919; 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=XsAhH0ZX3ddPj6j1bm6B9FX9Jp/gzrG8giI4aV5Q6Us=; b=eW959IBKuOVHrEVD77m0T3FS7VjV1coKdBQwiUUKK+ipkaVOef5TqLqiQIYxiHvxQ/ QMXAhI52hSQD+CWCQLaZEQanUpLVuU8+mFxKTdgGzgb6LSnMqayMHpRMmRQvPdDHZ62v DlUNzR1Lf5DGdCkrXwsUCUZjvjO7ewHdunks1MEA5/s/mcbTtvyUTH5Hjaz56VLC2TzJ NRqEaE8Nf0IuSv18nVKAPplhgvPZRdoHiZ06Mii3n2KaiLQoJgse5jFoGKJoHAWhfBpw ByUetV6FHkrSmeWiLwr4Zt0FB6pQRi2kPqw+eD6thyoBVapUpdD4Q6ErHC6DtRO7DhHq K+Ew== X-Gm-Message-State: AOJu0YyWaPXlusgxRPK1I1PDFhYVp3V0wi/emoSq5Hr7DVXXqHxOJK7b jHwvm4fpVoWyYld3lURs2pPFi5hZwyVwdkCLxFhfHNsLJFUT/1foptnO0HLEB5P5qIju4rLShN4 6 X-Google-Smtp-Source: AGHT+IFkTqzJNipSI9slbdLR5DnmMUSg9IQ7G52CHU9qeqUNr/E+diW/GwfnDq50Loq0xYQ8yo8PNg== X-Received: by 2002:a17:902:d486:b0:206:aa47:adc0 with SMTP id d9443c01a7336-20b19cb8b17mr165219575ad.24.1727542118710; Sat, 28 Sep 2024 09:48:38 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:38 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , hkalra@marvell.com, stable@dpdk.org, Rosen Xu , Hyong Youb Kim , David Marchand Subject: [PATCH v2 15/16] drivers/ifpga: fix free function mismatch Date: Sat, 28 Sep 2024 09:47:23 -0700 Message-ID: <20240928164814.861933-16-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The raw ifpga driver redefines malloc to be opae_malloc and free to be opae_free; which is a bad idea. This leads to case where interrupt efd array is allocated with calloc() and then passed to rte_free. The workaround is to allocate the array with rte_calloc() instead. Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle") Cc: hkalra@marvell.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/raw/ifpga/ifpga_rawdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index a972b3b7a4..86558c7b9b 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -1499,7 +1499,7 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int port_id, nb_intr = rte_intr_nb_intr_get(*intr_handle); - intr_efds = calloc(nb_intr, sizeof(int)); + intr_efds = rte_calloc("ifpga_efds", nb_intr, sizeof(int), 0); if (!intr_efds) return -ENOMEM; @@ -1508,7 +1508,7 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int port_id, ret = opae_acc_set_irq(acc, vec_start, count, intr_efds); if (ret) { - free(intr_efds); + rte_free(intr_efds); return -EINVAL; } } @@ -1517,13 +1517,13 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int port_id, ret = rte_intr_callback_register(*intr_handle, handler, (void *)arg); if (ret) { - free(intr_efds); + rte_free(intr_efds); return -EINVAL; } IFPGA_RAWDEV_PMD_INFO("success register %s interrupt\n", name); - free(intr_efds); + rte_free(intr_efds); return 0; } From patchwork Sat Sep 28 16:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 144607 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D188E45A50; Sat, 28 Sep 2024 18:49:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2EAC840A7A; Sat, 28 Sep 2024 18:48:52 +0200 (CEST) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id 67B9E40673 for ; Sat, 28 Sep 2024 18:48:40 +0200 (CEST) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2e06f5d4bc7so2775953a91.2 for ; Sat, 28 Sep 2024 09:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542119; x=1728146919; 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=R8Ok1+kq8bi6yHExAh8y81w0B9yxmLJ61X/1EwvijG0=; b=arvwDYY32TRMO7oNesERqDIfhALo5TyJDrGaAUHa2czwLVYemEkOQwE/6Zo/98vdBK SEkAxvgbLcZmN6ChgpKe3tlv0zNAhWYJJpkgCZEZxqY9BS6HkU/OtT3xp05F/YZaZS6x fNBdF8DpdU0Dw+IUtoSkGptdnhRha6DvBFX6M94smOXY5SoOjLA6sT5qPN+oY/LMktNz JIFdEmwOa2xqV3eEgb3IuyUbUXot1vqY4pEuaBMrRSY+5FGc7LdxPgjbR9XC5Jtml8ZC Izh+PekhpBbh3Mh5HaXOQuGzDDkhtZpdHYz+NtNR1u+JZXa7sUbEk24qFPILV7noFJyz u30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542119; x=1728146919; 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=R8Ok1+kq8bi6yHExAh8y81w0B9yxmLJ61X/1EwvijG0=; b=TidhsPuJkjlverWFj2iZoTkfX6jy9H6p85syuvKl5YjJfmOakguNN3Z67YFBUlULRU hDlcBnMieQt6eITPQ9dzaynpDxODhgj9V8JP2Lavk5EJu2U2U3gget5ZECVHM0kngfpK GovycNymkK27hClYLwxzno/FD8BuZD8Q1k88VU9W06hnIdY2lRbQ+CHTCiOIxUYTe5RO pdJEyvTTrYAUcwOtSUMdcA4vJOBiHchafvKW8BgHQeu9eBKHJMz0cDX75lICA2kISefY 1/t7mgO7ZqetcaPsgxHiw4l/PEKNQNYEzPf1uTTVpqfaveVa/yJwFoGnS6k7GxIODduC c4zg== X-Gm-Message-State: AOJu0YwnDBHe37rc04diIqdC2EZU3JlMZ3cpbWbt9vVQ/2S7HhTVTRSc k4WgG7JrYhHVwDchkWzxpPMuDJJABPzUYPv0gFyAJgsTbGQta49PdEYgoV62jA6wv8BCIvP9E2g D X-Google-Smtp-Source: AGHT+IGgyL903meO4QX42v9HMy5W+ZQN7yML0o2XcRsgWcSU352kJq6I0ZMT34XjHl6Nw/pJnEKSqw== X-Received: by 2002:a17:90b:d98:b0:2d3:d063:bdb6 with SMTP id 98e67ed59e1d1-2e0b89a2d65mr8409498a91.4.1727542119545; Sat, 28 Sep 2024 09:48:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:39 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov , Tyler Retzlaff Subject: [PATCH v2 16/16] eal: add alloc_function attribute to rte_malloc Date: Sat, 28 Sep 2024 09:47:24 -0700 Message-ID: <20240928164814.861933-17-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use the GCC function attribute to detect cases where memory is allocated with rte_malloc and freed incorrectly with libc version of free (and vice versa). Also will detect some other pointer mismatches. Signed-off-by: Stephen Hemminger --- doc/guides/rel_notes/release_24_11.rst | 8 ++++ lib/eal/include/rte_malloc.h | 55 +++++++++++++++----------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index 0ff70d9057..f27a37eac4 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -55,6 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Hardened rte_malloc and related functions.** + + * Added function attributes to ``rte_malloc`` and similar functions + that can catch some obvious bugs at compile time (with GCC 11.0 or later). + Examples: calling ``free()`` on pointer that was allocated with ``rte_malloc`` + (and vice versa); freeing the same pointer twice in the same routine; + freeing an object that was not created by allocation; etc. + Removed Items ------------- diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h index cf3c174022..c7af96fcba 100644 --- a/lib/eal/include/rte_malloc.h +++ b/lib/eal/include/rte_malloc.h @@ -31,6 +31,22 @@ struct rte_malloc_socket_stats { size_t heap_allocsz_bytes; /**< Total allocated bytes on heap */ }; + +/** + * Frees the memory space pointed to by the provided pointer. + * + * This pointer must have been returned by a previous call to + * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behaviour of + * rte_free() is undefined if the pointer does not match this requirement. + * + * If the pointer is NULL, the function does nothing. + * + * @param ptr + * The pointer to memory to be freed. + */ +void +rte_free(void *ptr); + /** * This function allocates memory from the huge-page area of memory. The memory * is not cleared. In NUMA systems, the memory allocated resides on the same @@ -55,7 +71,8 @@ struct rte_malloc_socket_stats { void * rte_malloc(const char *type, size_t size, unsigned align) __rte_alloc_size(2) - __rte_alloc_align(3); + __rte_alloc_align(3) + __rte_alloc_func(rte_free, 1); /** * Allocate zeroed memory from the heap. @@ -83,7 +100,8 @@ rte_malloc(const char *type, size_t size, unsigned align) void * rte_zmalloc(const char *type, size_t size, unsigned align) __rte_alloc_size(2) - __rte_alloc_align(3); + __rte_alloc_align(3) + __rte_alloc_func(rte_free, 1); /** * Replacement function for calloc(), using huge-page memory. Memory area is @@ -111,7 +129,8 @@ rte_zmalloc(const char *type, size_t size, unsigned align) void * rte_calloc(const char *type, size_t num, size_t size, unsigned align) __rte_alloc_size(2, 3) - __rte_alloc_align(4); + __rte_alloc_align(4) + __rte_alloc_func(rte_free, 1); /** * Replacement function for realloc(), using huge-page memory. Reserved area @@ -136,7 +155,8 @@ rte_calloc(const char *type, size_t num, size_t size, unsigned align) void * rte_realloc(void *ptr, size_t size, unsigned int align) __rte_alloc_size(2) - __rte_alloc_align(3); + __rte_alloc_align(3) + __rte_alloc_func(rte_free, 1); /** * Replacement function for realloc(), using huge-page memory. Reserved area @@ -163,7 +183,8 @@ rte_realloc(void *ptr, size_t size, unsigned int align) void * rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket) __rte_alloc_size(2) - __rte_alloc_align(3); + __rte_alloc_align(3) + __rte_alloc_func(rte_free, 1); /** * This function allocates memory from the huge-page area of memory. The memory @@ -191,7 +212,8 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket) void * rte_malloc_socket(const char *type, size_t size, unsigned align, int socket) __rte_alloc_size(2) - __rte_alloc_align(3); + __rte_alloc_align(3) + __rte_alloc_func(rte_free, 1); /** * Allocate zeroed memory from the heap. @@ -221,7 +243,8 @@ rte_malloc_socket(const char *type, size_t size, unsigned align, int socket) void * rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket) __rte_alloc_size(2) - __rte_alloc_align(3); + __rte_alloc_align(3) + __rte_alloc_func(rte_free, 1); /** * Replacement function for calloc(), using huge-page memory. Memory area is @@ -251,22 +274,8 @@ rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket) void * rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, int socket) __rte_alloc_size(2, 3) - __rte_alloc_align(4); - -/** - * Frees the memory space pointed to by the provided pointer. - * - * This pointer must have been returned by a previous call to - * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behaviour of - * rte_free() is undefined if the pointer does not match this requirement. - * - * If the pointer is NULL, the function does nothing. - * - * @param ptr - * The pointer to memory to be freed. - */ -void -rte_free(void *ptr); + __rte_alloc_align(4) + __rte_alloc_func(rte_free, 1); /** * If malloc debug is enabled, check a memory block for header