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 52D9645A9D; Wed, 2 Oct 2024 17:44:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7AE740268; Wed, 2 Oct 2024 17:44:40 +0200 (CEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id 0350E4025C for ; Wed, 2 Oct 2024 17:44:40 +0200 (CEST) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-718e6299191so3740105b3a.2 for ; Wed, 02 Oct 2024 08:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727883879; x=1728488679; 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=629ub43eu6YY/qsUkoh4ai/h7AZTL/0Ji7nHhqTVnvQ=; b=YDLfQ05IC88c24O/4azqbNZ/CDFPIzlNf4eskKw+ngSP8qzIIgZf0POTlYX2/wTIkJ 2xR/BFnawqKNiRzH7yw+ehjQ5Uz9ol8U7xTlYiSX8vfdQ0edIob+TNQdJ+fCRZ7hHk2L Vcyz44o8qPbUmr4R4B0wuOGiITQLw6Fb8emUjU45L4tlZaNiM13PiHbrEGHX8gnbsi1u O2EaF1i2/oRwROHw0BhO+7NBqbFtvKrt7yG5mK8uxQBSz4yaiNOSw7i1X6jAS8dfqHRt AJWRib/K/ZmwcANvdPOeen6pwMK9jr8y7wTxEqmocWdCya/8WsdGRyn4w3/8B0hZvTQR ncaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727883879; x=1728488679; 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=629ub43eu6YY/qsUkoh4ai/h7AZTL/0Ji7nHhqTVnvQ=; b=aBkcnJGJ4CTo3B50ZbTK5MYjxAUL96q2M/p03tUPH1LKRR49HYSfy8GvBmsxZXiZjD ZgW9TwoBW0FsiM2ueqFJjjSf2PRMX6VmD2FkPweWIYgLqE0GFlnAtUj8bI82WtPpUP9/ t2/cU9o3NYTjtbceSb1h2nWHFNw/n6lLvuK/jgchfH0EjKQ0EVN5qSgRBHvWaFfZQHNz MVl/YbTA13IoTRGkniowFbIFXvpxdn88FsU4BbjSUFh+ao/bt9HpnKNLVKKocroM9nBS pv8oacb4yqbaSR8k9aohUKXwEANjOOKcuv7E7PHR7b3KBYC/oroEaEAUQb4oH5VlknG1 YREA== X-Gm-Message-State: AOJu0YwY0+B6zZSPxNsTlpTLJJgczV3j+FqI8ziUE6Tl+eHC8S3btGE2 Fc06eUsBGz30YcSeLRCkp3eHmNFDq9h0dFh9vd4wIpv4O6Zf1yBYIkbqcn+Ufk74puKSCxfgYM0 R X-Google-Smtp-Source: AGHT+IHdPCuB4J3Y/jlBNQWAQyCu56SMJpaReB67SaA8mL+m1aWuuiZARfB1RVD0DISqOQKts6m5nQ== X-Received: by 2002:a05:6a00:3cd6:b0:714:1bcf:3d93 with SMTP id d2e1a72fcca58-71dc5c43500mr5625829b3a.5.1727883879003; Wed, 02 Oct 2024 08:44:39 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2927c7sm10247363a12.1.2024.10.02.08.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 08:44:38 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 00/17] Fix allocation related bugs and catch future bugs Date: Wed, 2 Oct 2024 08:42:44 -0700 Message-ID: <20241002154429.64357-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927204742.546164-1-stephen@networkplumber.org> References: <20240927204742.546164-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Recent versions of GCC have some additional function attributes that can help with DPDK performance and stability. The alloc_align attribute tells the compiler what the alignment of the allocation will be, and the optimizer can use this to produce better code (especially memcpy and structure copies). The malloc attribute tells compiler that object is not overlapping and potentially aliasing. It also as an additional variant in GCC 11 or later that allows for detecting all sorts of common errors like calling free() on memory allocated with rte_malloc(). In order to use the malloc attribute the free function prototype needs to be moved before the allocator/create function prototype so that the malloc attribute can refer to it. This uncovered at least 16 pre-existing bugs in DPDK, these should go to stable. This patch set is structured with: - fix any new warnings that were discovered - add macros for enable the macros - enable the attributes The same attributes could be added to lots more functions in DPDK, but this patch set focuses on the key ones, and where problems exist in current code base. v6 - more __rte_dealloc_free macro to rte_malloc.h Stephen Hemminger (17): memzone: fix use after free in tracing cryptodev/bcmfs: fix mis-matched free dma/ixd: fix incorrect free function in cleanup event/cnxk: fix pointer mismatch in cleanup examples/vhost: fix free function mismatch net/cnxk: fix use-after-free bpf: fix free mismatch if convert fails net/e1000: fix use-after-free net/sfc: fix use-after-free warning messages net/cpfl: fix free of nonheap object net/nfp: fix duplicate call to rte_free raw/ifpga/base: fix use after free common/qat: fix use after free drivers/ifpga: fix free function mismatch baseband/la12xx: prevent use after free common/idpf: fix use after free due eal: add function attributes for allocation functions doc/guides/rel_notes/release_24_11.rst | 8 +++ drivers/baseband/la12xx/bbdev_la12xx.c | 1 + drivers/common/idpf/base/idpf_osdep.h | 10 +++- drivers/common/idpf/idpf_common_device.c | 3 +- drivers/common/qat/qat_device.c | 6 +-- drivers/crypto/bcmfs/bcmfs_device.c | 4 +- drivers/dma/idxd/idxd_pci.c | 2 +- drivers/event/cnxk/cnxk_eventdev.c | 4 +- drivers/net/cnxk/cnxk_ethdev_sec.c | 2 +- drivers/net/cpfl/cpfl_flow_parser.c | 1 - drivers/net/e1000/igb_ethdev.c | 4 +- drivers/net/nfp/flower/nfp_flower_flow.c | 1 - drivers/net/sfc/sfc_flow_rss.c | 4 +- drivers/net/sfc/sfc_mae.c | 23 ++++----- drivers/raw/ifpga/base/opae_intel_max10.c | 11 ++++- drivers/raw/ifpga/ifpga_rawdev.c | 8 +-- examples/vhost_blk/vhost_blk.c | 2 +- lib/bpf/bpf_convert.c | 2 +- lib/eal/common/eal_common_memzone.c | 3 +- lib/eal/include/rte_common.h | 34 +++++++++++++ lib/eal/include/rte_malloc.h | 59 ++++++++++++++--------- 21 files changed, 126 insertions(+), 66 deletions(-) -- 2.45.2