Skip to content

fix insecure use of memset bugs

Stephen Hemminger dpdk-dev 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest15 patches 5 repliesIn review
  2. v817 patches 2 repliesSuperseded
  3. v716 patches 1 replySuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v611 patches2 repliesSuperseded
v511 patches7 repliesSuperseded
v412 patches1 replySuperseded
v311 patches3 repliesSuperseded
v28 patches0 repliesSuperseded

Patches in v9 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15eal: introduce new secure memory zerolib/eal/common/eal_common_string_fns.c lib/eal/include/rte_string_fns.h lib/eal/version.map+35 -03 replies
2/15app/test: remove unused variableapp/test/test_cmdline_cirbuf.c+0 -21 reply
3/15eal: add new secure free functionlib/eal/common/rte_malloc.c lib/eal/include/rte_malloc.h lib/eal/version.map+48 -60 replies
4/15app/test: use unit test runner for malloc testsapp/test/test_malloc.c+70 -960 replies
5/15app/test: add test for rte_free_sensitiveapp/test/test_malloc.c+52 -00 replies
6/15common/cnxk: remove unused variabledrivers/common/cnxk/roc_npc_utils.c+0 -40 replies
7/15crypto/qat: force zero of keysdrivers/crypto/qat/qat_sym_session.c+17 -160 replies
8/15crypto/qat: fix size calculation for memsetdrivers/crypto/qat/qat_sym_session.c+5 -50 replies
9/15crypto/qat: use secure free for keysdrivers/crypto/qat/qat_asym.c drivers/crypto/qat/qat_sym_session.c+5 -80 replies
10/15bus/uacce: remove memset before freedrivers/bus/uacce/uacce.c+0 -10 replies
11/15compress/octeontx: remove unnecessary memsetdrivers/compress/octeontx/otx_zip.c drivers/compress/octeontx/otx_zip_pmd.c+0 -30 replies
12/15test: remove unneeded memsetapp/test/test_cmdline_cirbuf.c+0 -20 replies
13/15net/ntnic: check result of mallocdrivers/net/ntnic/nthw/nthw_rac.c+3 -10 replies
14/15net/ntnic: remove unnecessary memsetdrivers/net/ntnic/nthw/core/nthw_hif.c drivers/net/ntnic/nthw/core/nthw_iic.c drivers/net/ntnic/nthw/core/nthw_pcie3.c +18 more+19 -780 replies
15/15devtools/cocci: add script to find problematic memsetdevtools/cocci/memset_free.cocci+9 -00 replies

Reviews trailers per patch

8 of 15 patches have a Reviewed-by or Acked-by.

PatchMorten BrørupBruce RichardsonChengwen Feng
1/15A-b
2/15
3/15A-b
4/15
5/15
6/15
7/15A-b
8/15A-b
9/15A-b
10/15A-b
11/15A-b
12/15A-b
13/15
14/15
15/15

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

Read the v9 thread

Cover letter [PATCH v9 00/15] fix insecure use of memset bugs

There is an issue where calls to bzero (memset(), etc) can be eliminated due to an optimizing compiler eliminating the call to bzero() (or memset(), etc) because the arguments to the call are not subsequently used by the function. The compiler can interpret this as "no side effects", and eliminate the call.

The origin source of issue to being brought to light with a security focus' is here: http://cwe.mitre.org/data/definitions/14.html

The issue was discovered in DPDK while looking at PVS Studio blog about bugs:

https://pvs-studio.com/en/blog/posts/cpp/1183/

In DPDK there are three types of anti-patterns:
1. trying to clear a key or sensitive data but using memset
2. being overly paranoid and always calling memset
3. unnecessary arrays (cut and paste?) that are memset

v9 - drop the standalone test for explicit zero
because testing that code is not optimized away requires some non-portable hacks using altstack and/or glibc setcontext hooks. Not worth the hassle doing this and maintaining, just trust that libc works as expected.

Stephen Hemminger (15):
eal: introduce new secure memory zero app/test: remove unused variable
eal: add new secure free function
app/test: use unit test runner for malloc tests app/test: add test for rte_free_sensitive common/cnxk: remove unused variable crypto/qat: force zero of keys
crypto/qat: fix size calculation for memset crypto/qat: use secure free for keys bus/uacce: remove memset before free compress/octeontx: remove unnecessary memset
test: remove unneeded memset
net/ntnic: check result of malloc
net/ntnic: remove unnecessary memset devtools/cocci: add script to find problematic memset

 app/test/test_cmdline_cirbuf.c                |   4 -
 app/test/test_malloc.c                        | 194 ++++++++++--------
 devtools/cocci/memset_free.cocci              |   9 +
 drivers/bus/uacce/uacce.c                     |   1 -
 drivers/common/cnxk/roc_npc_utils.c           |   4 -
 drivers/compress/octeontx/otx_zip.c           |   1 -
 drivers/compress/octeontx/otx_zip_pmd.c       |   2 -
 drivers/crypto/qat/qat_asym.c                 |   5 +-
 drivers/crypto/qat/qat_sym_session.c          |  51 ++---
 drivers/net/ntnic/nthw/core/nthw_hif.c        |   5 +-
 drivers/net/ntnic/nthw/core/nthw_iic.c        |   5 +-
 drivers/net/ntnic/nthw/core/nthw_pcie3.c      |   5 +-
 drivers/net/ntnic/nthw/core/nthw_rpf.c        |   5 +-
 drivers/net/ntnic/nthw/core/nthw_sdc.c        |   5 +-
 drivers/net/ntnic/nthw/core/nthw_si5340.c     |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_cat.c    |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_csu.c    |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_flm.c    |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_hfu.c    |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_hsh.c    |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_info.c   |   5 +-
 .../net/ntnic/nthw/flow_filter/flow_nthw_km.c |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_pdb.c    |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_qsl.c    |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_slc_lr.c |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c |   1 -
 .../ntnic/nthw/flow_filter/flow_nthw_tx_ins.c |   5 +-
 .../ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c |   5 +-
 .../net/ntnic/nthw/model/nthw_fpga_model.c    |   1 -
 drivers/net/ntnic/nthw/nthw_rac.c             |   4 +-
 lib/eal/common/eal_common_string_fns.c        |  14 ++
 lib/eal/common/rte_malloc.c                   |  30 ++-
 lib/eal/include/rte_malloc.h                  |  23 +++
 lib/eal/include/rte_string_fns.h              |  18 ++
 lib/eal/version.map                           |   4 +
 36 files changed, 251 insertions(+), 210 deletions(-)
 create mode 100644 devtools/cocci/memset_free.cocci
Signature · 1 line
2.47.2