DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v3 00/18] Fix allocation bugs and add malloc hardening
Date: Sun, 29 Sep 2024 08:34:25 -0700	[thread overview]
Message-ID: <20240929154107.62539-1-stephen@networkplumber.org> (raw)
In-Reply-To: <20240927204742.546164-1-stephen@networkplumber.org>

Recent versions of Gcc have some additonal 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 patchset focuses on the key ones, and where problems
exist in current code base.

v3 - fix more broken devices
   - reorder patches

Stephen Hemminger (18):
  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/ipdf: fix use after free due
  eal: add function attributes for allocation functions
  eal: add alloc_function attribute to rte_malloc

 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              | 30 +++++++++++
 lib/eal/include/rte_malloc.h              | 63 ++++++++++++++---------
 21 files changed, 126 insertions(+), 66 deletions(-)

-- 
2.45.2


  parent reply	other threads:[~2024-09-29 15:41 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27 20:45 [PATCH 00/16] Fix allocation issues and add hardening Stephen Hemminger
2024-09-27 20:45 ` [PATCH 01/16] eal: add function attributes for allocation functions Stephen Hemminger
2024-09-27 22:09   ` David Marchand
2024-09-27 23:10     ` Stephen Hemminger
2024-09-27 20:45 ` [PATCH 02/16] memzone: fix use after free in tracing Stephen Hemminger
2024-09-27 20:45 ` [PATCH 03/16] cryptodev/bcmfs: fix mis-matched free Stephen Hemminger
2024-09-27 20:45 ` [PATCH 04/16] dma/ixd: fix incorrect free function in cleanup Stephen Hemminger
2024-09-27 20:45 ` [PATCH 05/16] event/cnxk: fix pointer mismatch " Stephen Hemminger
2024-09-27 20:45 ` [PATCH 06/16] examples/vhost: fix free function mismatch Stephen Hemminger
2024-09-27 20:45 ` [PATCH 07/16] net/cnxk: fix use-after-free Stephen Hemminger
2024-09-27 20:45 ` [PATCH 08/16] bpf: fix free mismatch if convert fails Stephen Hemminger
2024-09-27 20:45 ` [PATCH 09/16] net/e1000: fix use-after-free Stephen Hemminger
2024-09-27 20:45 ` [PATCH 10/16] net/sfc: fix use-after-free warning messages Stephen Hemminger
2024-09-28 11:52   ` Ivan Malov
2024-09-27 20:45 ` [PATCH 11/16] net/cpfl: fix free of nonheap object Stephen Hemminger
2024-09-27 20:45 ` [PATCH 12/16] raw/ifpga/base: fix use after free Stephen Hemminger
2024-09-27 20:45 ` [PATCH 13/16] common/qat: " Stephen Hemminger
2024-09-27 20:45 ` [PATCH 14/16] drivers/ifpga: fix free function mismatch Stephen Hemminger
2024-09-27 20:45 ` [PATCH 15/16] eal: add alloc_function attribute to rte_malloc Stephen Hemminger
2024-09-27 20:45 ` [PATCH 16/16] mempool: annotate mempool create Stephen Hemminger
2024-09-28 11:49   ` Morten Brørup
2024-09-28 16:47 ` [PATCH v2 00/16] Fix allocation bugs and add malloc hardening Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 01/16] eal: add function attributes for allocation functions Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 02/16] memzone: fix use after free in tracing Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 03/16] cryptodev/bcmfs: fix mis-matched free Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 04/16] dma/ixd: fix incorrect free function in cleanup Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 05/16] event/cnxk: fix pointer mismatch " Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 06/16] examples/vhost: fix free function mismatch Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 07/16] net/cnxk: fix use-after-free Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 08/16] bpf: fix free mismatch if convert fails Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 09/16] net/e1000: fix use-after-free Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 10/16] net/sfc: fix use-after-free warning messages Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 11/16] net/cpfl: fix free of nonheap object Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 12/16] net/nfp: fix duplicate call to rte_free Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 13/16] raw/ifpga/base: fix use after free Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 14/16] common/qat: " Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 15/16] drivers/ifpga: fix free function mismatch Stephen Hemminger
2024-09-28 16:47   ` [PATCH v2 16/16] eal: add alloc_function attribute to rte_malloc Stephen Hemminger
2024-09-29 15:34 ` Stephen Hemminger [this message]
2024-09-29 15:34   ` [PATCH v3 01/18] memzone: fix use after free in tracing Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 02/18] cryptodev/bcmfs: fix mis-matched free Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 03/18] dma/ixd: fix incorrect free function in cleanup Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 04/18] event/cnxk: fix pointer mismatch " Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 05/18] examples/vhost: fix free function mismatch Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 06/18] net/cnxk: fix use-after-free Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 07/18] bpf: fix free mismatch if convert fails Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 08/18] net/e1000: fix use-after-free Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 09/18] net/sfc: fix use-after-free warning messages Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 10/18] net/cpfl: fix free of nonheap object Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 11/18] net/nfp: fix duplicate call to rte_free Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 12/18] raw/ifpga/base: fix use after free Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 13/18] common/qat: " Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 14/18] drivers/ifpga: fix free function mismatch Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 15/18] baseband/la12xx: prevent use after free Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 16/18] common/ipdf: fix use after free due Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 17/18] eal: add function attributes for allocation functions Stephen Hemminger
2024-09-29 15:34   ` [PATCH v3 18/18] eal: add alloc_function attribute to rte_malloc Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240929154107.62539-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).