[PATCH v7 05/16] app/test: use unit test runner for malloc tests

2025-02-15 Thread Stephen Hemminger
There are several malloc tests and switching to the table driven unit test runner improves readability and makes adding new tests easier. Signed-off-by: Stephen Hemminger --- app/test/test_malloc.c | 166 + 1 file changed, 70 insertions(+), 96 deletions(-)

[PATCH v7 16/16] devtools/cocci: add script to find problematic memset

2025-02-15 Thread Stephen Hemminger
Script that converts memset before free into rte_memset_sensitive and memset before rte_free into rte_free_sensitive Signed-off-by: Stephen Hemminger --- devtools/cocci/memset_free.cocci | 9 + 1 file changed, 9 insertions(+) create mode 100644 devtools/cocci/memset_free.cocci diff --g

[PATCH v7 14/16] net/ntnic: check result of malloc

2025-02-15 Thread Stephen Hemminger
Need to check the result of malloc() before calling memset. This is only place in this driver that forgot, other code does check. Fixes: 0d9bca480e26 ("net/ntnic: add FPGA modules for initialization") cc: sta...@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/ntnic/nthw/nthw_rac.c | 4

[PATCH v7 15/16] net/ntnic: remove unnecessary memset

2025-02-15 Thread Stephen Hemminger
Calling memset before free() has no effect and will be flagged by security parsing tools as a potential bug. None of these data structures have sensitive information. Signed-off-by: Stephen Hemminger --- drivers/net/ntnic/nthw/core/nthw_hif.c| 5 + drivers/net/ntnic/nthw/core

[PATCH v7 13/16] test: remove unneeded memset

2025-02-15 Thread Stephen Hemminger
Since tmp is not used later in the function, this memset is unnecessary. Even though this is harmless, it causes tools that look for security issues around memset to flag this a bug. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- app/test/test_cmdline_cirbuf.c | 2 -- 1 file ch

[PATCH v7 08/16] crypto/qat: force zero of keys

2025-02-15 Thread Stephen Hemminger
Just doing memset() on keys is not enough, compiler can optimize it away. Use new rte_memzero_explicit() and rte_free_sensitive(). Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- drivers/crypto/qat/qat_sym_session.c | 33 ++-- 1 file changed, 17 insertion

[PATCH v7 12/16] compress/octeontx: remove unnecessary memset

2025-02-15 Thread Stephen Hemminger
Calling memset before rte_free not necessary, and could be removed by the compiler. In this case, the data is not security sensitive so the memset can be removed. Some security scanning tools will flag this. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- drivers/compress/octeon

[PATCH v7 11/16] bus/uacce: remove memset before free

2025-02-15 Thread Stephen Hemminger
Doing memset before free maybe removed by compiler, and is flagged by security scanning tools as potential problem. In this case the memset is unnecessary. Signed-off-by: Stephen Hemminger Acked-by: Chengwen Feng --- drivers/bus/uacce/uacce.c | 1 - 1 file changed, 1 deletion(-) diff --git a/d

[PATCH v7 10/16] crypto/qat: use secure free for keys

2025-02-15 Thread Stephen Hemminger
Regular memset maybe removed by compiler if done before a free function. Use new rte_free_sensitive instead. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- drivers/crypto/qat/qat_asym.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/crypto/qat/q

[PATCH v7 09/16] crypto/qat: fix size calculation for memset

2025-02-15 Thread Stephen Hemminger
The memset was always doing 0 bytes since size computed later. Link: https://pvs-studio.com/en/blog/posts/cpp/1179/ Fixes: 3a80d7fb2ecd ("crypto/qat: support SHA3 plain hash") Cc: sta...@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- drivers/crypto/qat/qat_sym_sessio

[PATCH v7 04/16] eal: add new secure free function

2025-02-15 Thread Stephen Hemminger
Although internally rte_free does poison the buffer in most cases, it is useful to have function that explicitly does this to avoid any security issues. Name of new API is chosen to be similar to Linux kernel kfree_sensitive() to make porting drivers easier. Signed-off-by: Stephen Hemminger Acke

[PATCH v7 07/16] common/cnxk: remove unused variable

2025-02-15 Thread Stephen Hemminger
A couple places in this code were generating warnings from PVS studio about memset potentially being ignored. This is because the ipv6_buf was declared but never used. Signed-off-by: Stephen Hemminger --- drivers/common/cnxk/roc_npc_utils.c | 4 1 file changed, 4 deletions(-) diff --git a/

[PATCH v7 06/16] app/test: add test for rte_free_sensitive

2025-02-15 Thread Stephen Hemminger
Similar to test for rte_memset_explicit, use a worker thread to free and then check the result. Signed-off-by: Stephen Hemminger --- app/test/test_malloc.c | 39 +++ 1 file changed, 39 insertions(+) diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c

[PATCH v7 03/16] app/test: add test for rte_memzero_explicit

2025-02-15 Thread Stephen Hemminger
Add a new test for rte_memzero_explcit. Test strategy is based of glibc bzero_explicit test which is based off a test in the OpenBSD regression test suite. Signed-off-by: Stephen Hemminger --- app/test/test_string_fns.c | 56 ++ 1 file changed, 56 insertions(+

[PATCH v7 01/16] eal: introduce new secure memory zero

2025-02-15 Thread Stephen Hemminger
When memset() is used before a release function such as free, the compiler if allowed to optimize the memset away under the as-if rules. This is normally ok, but in certain cases such as passwords or security keys it is problematic. Introduce a DPDK wrapper which uses the bzero_explicit function o

[PATCH v7 02/16] app/test: use unit test runner for string tests

2025-02-15 Thread Stephen Hemminger
Switching to unit test table makes it easier to add new tests. Signed-off-by: Stephen Hemminger --- app/test/test_string_fns.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/test/test_string_fns.c b/app/test/test_string_fns.c index 3b311325dc..ce07c17

[PATCH v7 00/16] Introduce secure memory zero functions

2025-02-15 Thread Stephen Hemminger
This series handles memset related bugs indentified by PVS Studio. The root cause is that Gcc and other compilers are free to optimize away memset called before free. This is handled in other libraries and OS's by the use of special versions of zeroing and free. v7 - use bzero_explicit - add st

RE: [PATCH v2 0/7] Introduce FOREACH_SAFE macros

2025-02-15 Thread Morten Brørup
> From: Stephen Hemminger [mailto:step...@networkplumber.org] > Sent: Friday, 14 February 2025 18.20 > > This series adds common macros for safe iteration over lists. > It is a subset copy of the macros from FreeBSD that are > missing from the Linux header sys/queue.h > > Chose this over several

RE: [PATCH v6 02/11] eal: add new secure free function

2025-02-15 Thread Morten Brørup
> + > +/** Missing: + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * > + * Frees the memory space pointed to by the provided pointer > + * and guarantees it will be zero'd before reuse. Since this > + * function is slower than simple rte_free() it should only > + *

RE: [PATCH v6 01/11] eal: introduce new secure memory fill

2025-02-15 Thread Morten Brørup
> From: Stephen Hemminger [mailto:step...@networkplumber.org] > Sent: Thursday, 13 February 2025 23.16 > > When memset() is used before a release function such as free, > the compiler if allowed to optimize the memset away under > the as-if rules. This is normally ok, but in certain cases such > a

RE: [PATCH v2 3/7] bus/fslmc: fix use after free

2025-02-15 Thread Hemant Agrawal
Acked-by: Hemant Agrawal