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 0E5E245A48; Fri, 27 Sep 2024 22:48:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9DDC140156; Fri, 27 Sep 2024 22:47:59 +0200 (CEST) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id 72DEB40144 for ; Fri, 27 Sep 2024 22:47:57 +0200 (CEST) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7e6ba3f93fdso1655675a12.1 for ; Fri, 27 Sep 2024 13:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727470076; x=1728074876; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WhwWCp/MuPLyTNTfE3I+AyY60GeRb9kCY9UMtLwIlcc=; b=o26ZXNdeVtnjUsmttWIcW5MyLuXEKCAegTgIC6OAv7lpcXeCkZLn55OCscnpLi0/dy cqUaGomalcLBKqlaiC8fqBADfhHnpnP2wgt7RIgCXymr/VLm3y7FIiI3ww+YAzVGmIlj W2VGQSc5D6Fie7gfysq/CW2SwJCw7Kj8D76EBIUZbYPcN5oxqCOUlsfnryQx6GHMAiu/ RWavXewEtL/nDAfe+G+STvSTdP7FnEefur7E6wbQqezDtel8OvEnzMddXm3/3tWKUHzH RNDwo0OSs69HKKAjIfpwRVR5SnQ1NJs5eeKcfF2kowApUPVt/jVwNXbIaDwi7hmhQbJ7 ApYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727470076; x=1728074876; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WhwWCp/MuPLyTNTfE3I+AyY60GeRb9kCY9UMtLwIlcc=; b=Ah8khfB8YzAKQ/r0t1vDb4+R2EKYhA7h42IH9i2Mi9KRDNY0n/oh3mYRdMuonS8MSU lG9tfjoN9X4rGHcX326EKKv2l91ZeFIMuSSVfBNedkA1RoNiG5y6MVy9ESDcOzw3estV VM8UdrmFN+DFa4Ip5MWoK8eBVDQWyRuXWeM26kel69aPUPGbJ3Hew3yvbRxKAI+qGU+u tG+lCbOOE1IJujzWnqQ6B7v2xxQQqa4B1J40DL2c2rZW751prpsHpDJzhg3ZPWWld0YI +I3XahIn/brtneEsZSKQoeaBpgkOrtAUB8lfpkqvTela5VFIUrVoOD2ufdBALzhlmd4+ LGxQ== X-Gm-Message-State: AOJu0YyPHSFmUVgMxZC7wHqvfW3v1WHZjvhQoQd+MZl3SEzNRrbA3NRs s0JYN/B4Z8dwf3cQHFKGoWK2/LXd2YP233V8b1QCQuyF/iB4fui3yZsfM2+HvikAm9Dach0rl6e W X-Google-Smtp-Source: AGHT+IGc4mpu3joyHci/IFem9IbtbP3WEdo4/HTJyyYSplHcCqhUgcbRjCeOT1qm8JrYKMtFkedC/w== X-Received: by 2002:a05:6a20:b493:b0:1d4:fd77:2d10 with SMTP id adf61e73a8af0-1d4fd772e0emr4424095637.5.1727470076298; Fri, 27 Sep 2024 13:47:56 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db294533sm2036531a12.12.2024.09.27.13.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:47:55 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH 00/16] Fix allocation issues and add hardening Date: Fri, 27 Sep 2024 13:45:36 -0700 Message-ID: <20240927204742.546164-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 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 can tell 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(). This patch set is structured with: - add macros for enable the macros - fix any new warnings that were discovered - 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. The fixes should be backported to stable (they are real bugs), but the macros common and the annotation in malloc should not. Stephen Hemminger (16): eal: add function attributes for allocation functions 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 raw/ifpga/base: fix use after free common/qat: fix use after free drivers/ifpga: fix free function mismatch eal: add alloc_function attribute to rte_malloc mempool: annotate mempool create 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/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 | 30 +++++++++++ lib/eal/include/rte_malloc.h | 63 ++++++++++++++--------- lib/mempool/rte_mempool.h | 41 ++++++++------- 17 files changed, 130 insertions(+), 80 deletions(-) -- 2.45.2