Skip to content

Use malloc function attribute to uncover bugs

Stephen Hemminger dpdk-dev 9 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest17 patches 5 repliesIn review
  2. v817 patches 2 repliesSuperseded
  3. v716 patches 5 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v617 patches3 repliesSuperseded
v517 patches2 repliesSuperseded
v417 patches7 repliesSuperseded
v318 patches8 repliesSuperseded
v216 patches0 repliesSuperseded
v116 patches4 repliesSuperseded

Patches in v9 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17memzone: fix use after free in tracinglib/eal/common/eal_common_memzone.c+2 -10 replies
2/17cryptodev/bcmfs: fix mis-matched freedrivers/crypto/bcmfs/bcmfs_device.c+2 -20 replies
3/17dma/ixd: fix incorrect free function in cleanupdrivers/dma/idxd/idxd_pci.c+1 -10 replies
4/17event/cnxk: fix free of non-heap in cleanup codedrivers/event/cnxk/cnxk_eventdev.c+1 -11 reply
5/17examples/vhost: fix free function mismatchexamples/vhost_blk/vhost_blk.c+1 -11 reply
6/17net/cnxk: fix use-after-freedrivers/net/cnxk/cnxk_ethdev_sec.c+1 -10 replies
7/17bpf: fix free mismatch if convert failslib/bpf/bpf_convert.c+1 -10 replies
8/17net/e1000: fix use-after-freedrivers/net/e1000/igb_ethdev.c+2 -20 replies
9/17net/sfc: fix use-after-free warning messagesdrivers/net/sfc/sfc_flow_rss.c drivers/net/sfc/sfc_mae.c+11 -160 replies
10/17net/cpfl: fix free of nonheap objectdrivers/net/cpfl/cpfl_flow_parser.c+0 -10 replies
11/17net/nfp: fix duplicate call to rte_freedrivers/net/nfp/flower/nfp_flower_flow.c+0 -10 replies
12/17raw/ifpga/base: fix use after freedrivers/raw/ifpga/base/opae_intel_max10.c+9 -20 replies
13/17common/qat: fix use after freedrivers/common/qat/qat_device.c+1 -50 replies
14/17drivers/ifpga: fix free function mismatchdrivers/raw/ifpga/ifpga_rawdev.c+4 -40 replies
15/17baseband/la12xx: prevent use after freedrivers/baseband/la12xx/bbdev_la12xx.c+1 -00 replies
16/17common/idpf: fix use after free duedrivers/common/idpf/base/idpf_osdep.h drivers/common/idpf/idpf_common_device.c+9 -40 replies
17/17eal: add function attributes for allocation functionsdoc/guides/rel_notes/release_24_11.rst lib/eal/include/rte_common.h lib/eal/include/rte_malloc.h+78 -230 replies

Reviews trailers per patch

8 of 17 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchChengwen FengAnatoly BurakovAjit KhapardeBruce RichardsonIvan MalovAndrew RybchenkoHemant AgrawalPavan NikhileshChenbo XiaKonstantin AnanyevWathsala Vithanage
SeriesSeries-Acked-by A-b
1/17A-b A-b
2/17A-b
3/17R-b
4/17A-b
5/17A-b R-b
6/17
7/17
8/17
9/17R-b A-b
10/17
11/17
12/17
13/17
14/17
15/17R-b
16/17
17/17A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 11 reviewers.

Read the v9 thread

Cover letter [PATCH v9 00/17] Use malloc function attribute to uncover bugs

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.

v9 - correct the event/cnxk patch

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 free of non-heap in cleanup code 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        |  2 +-
 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, 124 insertions(+), 66 deletions(-)
Signature · 1 line
2.45.2