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 D674A45A50; Sat, 28 Sep 2024 18:48:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 535A04027F; Sat, 28 Sep 2024 18:48:27 +0200 (CEST) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mails.dpdk.org (Postfix) with ESMTP id DA1C940273 for ; Sat, 28 Sep 2024 18:48:25 +0200 (CEST) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-20afdad26f5so40140425ad.1 for ; Sat, 28 Sep 2024 09:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727542105; x=1728146905; 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=aTR/P5WWsHzMyw76Ks3eGRcIYv1NoFSgfg3NX0MCBJo=; b=i1jmskNXWzAlQo8uswOGTzvabmzhQWZQRPWBqKkx2AY7+2gteTHbHhYxavtMIs4sy+ 2hWurIdwUWl7RyPE4yjnsET0Rwtr2psh+GuCQJttOQ7PeDSedCNzvRI/7pt7QKRdqVib fPM9Aqvpeakle7OkkAtCT53GYiLKlM0oC58PW4XIR0mPuWHN4+ADqy2P6ZsL1ExPkvuE LA2C7L8z3p/FCWayiVgxgGfTN1mIiAPYmj9i6KOSZW4G7XfBf5GHalHuOODxdDYrFO55 JYRcE2rwDGA9bWeBfuVRjuHJcOf77mWsr14jBd/yV4jfjNcldSaVc66LNr2avqCBtuYZ JcPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727542105; x=1728146905; 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=aTR/P5WWsHzMyw76Ks3eGRcIYv1NoFSgfg3NX0MCBJo=; b=prE6XhLm8L6822orRZbfWY0JJvhEPmYUFl2X0AFDbRhMj/35iXzT1hpoOYbA8uU8a2 dovMx0nnqJehznH/h4xNdsAJz6veaJV7N6n+1XCs9ebtQkjzmwaQLEdFXslH+enFxXPl LJxAmoEfMXb/KdtCmxOPafbSwRi6Qyv8hjk9Iqnt7sjeLMCbSLX0Lv3TFg/skBgQVDLz zVHpZHcCDkvaDi/Ez+O5P5Dus1/eRvVL+Nh0N7q6fIlJE9n30aANbIsB4Hvr7FbrY3Io Sk1Hz2OpL0ZBlxyrhOF4l0Y0QrZ62Gtk8K+Gg2y/lf1cOKQX6tS+8HJvuV7NS7YQ33L1 Xf2Q== X-Gm-Message-State: AOJu0Yyf8tsDGf7knshx1OOqvD7x9jkhDnKHirIh9ZA+B2d93drmutjb G7zPYl9GWb0mBlB6aWQrWIxrU34ss1QKjno8HSJWUnqgv3sB20TRngjij6H6J9lrGeIo+L13SMz y X-Google-Smtp-Source: AGHT+IGPbfB021PUv6wJeVusmBeLegimxtDlY9r1/fQdTOjRfjlGY0AAw1I44cWFs22Hi+0AnFcNbQ== X-Received: by 2002:a17:902:c403:b0:206:b399:2f21 with SMTP id d9443c01a7336-20b37b79f11mr127969665ad.43.1727542104791; Sat, 28 Sep 2024 09:48:24 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 09:48:24 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v2 00/16] Fix allocation bugs and add malloc hardening Date: Sat, 28 Sep 2024 09:47:08 -0700 Message-ID: <20240928164814.861933-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 additonal function attributes tha 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 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. The same attributes could be added to lots more functions in DPDK, but this patchset 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. v2 - add release note - add fix for nfp device - drop mempool (will pick it up in later series) 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 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 eal: add alloc_function attribute to rte_malloc doc/guides/rel_notes/release_24_11.rst | 8 +++ 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 | 30 +++++++++++ lib/eal/include/rte_malloc.h | 63 ++++++++++++++--------- 18 files changed, 116 insertions(+), 62 deletions(-) -- 2.45.2