From patchwork Thu Feb 13 22:16:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151479 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BCF684621D; Thu, 13 Feb 2025 23:18:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F099340608; Thu, 13 Feb 2025 23:18:33 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id 1D1E2402EF for ; Thu, 13 Feb 2025 23:18:32 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2f9b91dff71so2087394a91.2 for ; Thu, 13 Feb 2025 14:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485111; x=1740089911; 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=xqVLAx5biK9uIXkfwAeH7h8x7zd3oHWqcf7QBwDDR7U=; b=BL2yTeNYwfQEpUYOYxGFUNm67VoLItzOho7ZD0oCa7o/UkNqLS94DdH6c80aZftXIl L9H8bSd/xqjJMxyYJf0OnLTtDr1VebMXeA9+SQTzUneaZLb+oDpqNdbxSONDp8aQEBP+ vIfovY1OR+iVz0sHDaGqoDlxzBhvhxx5gqy/bmpDOCdpESpYKDpVQuE7j/CCd+4z7Ro/ DyKvr2/Y/w+CZCclzJdJxjH24CCSgWAaMGGE+PG/U8lB53xuA72pYKD1C2i5dAVWrwhG Zrcj0OO/m1TcJkTLAWlkUsKu17UMttvtz4f0pUP1fnLfUOUVFbw24CHMMGIEb3jWYOqc mR3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485111; x=1740089911; 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=xqVLAx5biK9uIXkfwAeH7h8x7zd3oHWqcf7QBwDDR7U=; b=iMz/mFLlC//l8xzv6iJLLYWr5lSuQO5n/GFupmQv0TM4RSS08MGITaxPE0IObSwSPO jhqHDjcyyl8nSTB1wQCZZb25rp+aYZe7hAQQQOmuQA7XU+Davh6FbIAzJEccQKi9XqqZ UEumUEG3sv2fOuOsIK/8Z8yVhuvtsh1ZNKes2jwaFv8avWy1pVdxxtvUZoso2fpC5lJf hktrdhgT9XjzLnrEkH5nkeMm3uJ7exm36iLjGLycp1+cNFDpPXk9ELTjxgcl6SC77JiX CxevDfaBwh1hgYdbYHJuiu547OzMhm5KiQGeluQMnR7+0W9/ukQG97rlXNDrEQxj6Eed Bs3Q== X-Gm-Message-State: AOJu0Ywx8LCPBO0wBQrJp9X58Jz7HxXBAHdYs7q7SIr3UH+LJ5wzGgDo g/XCRZclxSdKExGY/NZ785jmS+2E5h+KQvqr5RBnMfS7iyaeIho1LeDlLKjxbstKJakxcAbenHb 6 X-Gm-Gg: ASbGncv7IlOci2Db9IOBeDhzLqTmgQPbnUesq+x4XvYVwt+IHpD2Q+9Lvt7UwtZsId9 TAF4vXonJATUbZ654HrbASaJzlIkT0L2xdks084fe+BGEKSkd6pV3VDMf+kcMz4LryAYbaMFY87 1aTxw8LeBXBEI8/kNoI8s5JiTCgF7MNY5ipyyDBZX4hTyrIV8N9w5SXt5H6Nx8NpNZ/ExTYwtR+ AX0pqY/TZN30G6dgW582ROmVaGVjLrs8/G+CYBLZSjpbcl50TaFPTQ8X7xWEDGKeqjivFUmwrS3 7olDkPOVeQw4Fp9Vxb65tvGVnBQ4uzENjZYYTy9UoryZbXVr6521RBmvNcl7pS/QlzC4 X-Google-Smtp-Source: AGHT+IELEyXtMDuvTpDIzBYeVzIDjXsL8AEZWyMlfXuqUaLs4XAXM24IG7/Y6pMNgCoDl5IZCZjD9w== X-Received: by 2002:a17:90b:540f:b0:2ee:e317:69ab with SMTP id 98e67ed59e1d1-2fbf5ad2ab1mr15465704a91.0.1739485111276; Thu, 13 Feb 2025 14:18:31 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:30 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff Subject: [PATCH v6 01/11] eal: introduce new secure memory fill Date: Thu, 13 Feb 2025 14:16:14 -0800 Message-ID: <20250213221819.1856769-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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 is equivalent to the C23 memset_explicit function. Name ot the new function chosen to be similar to Linux kernel internal memzero_explicit(). Signed-off-by: Stephen Hemminger Acked-by: Morten Brørup --- lib/eal/include/rte_string_fns.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/eal/include/rte_string_fns.h b/lib/eal/include/rte_string_fns.h index 702bd81251..93aae66614 100644 --- a/lib/eal/include/rte_string_fns.h +++ b/lib/eal/include/rte_string_fns.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -149,6 +150,29 @@ rte_str_skip_leading_spaces(const char *src) return p; } +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Fill memory with with zero's (e.g. sensitive keys) + * Normally using memset() is fine. But in cases where clearing + * out local data before going out of scope or freeing, + * use rte_memzero_explicit() to preven the compiler from optimizing + * away the zeroing. + * + * @param dst + * target buffer + * @param sz + * number of bytes to fill + */ +__rte_experimental +static inline void +rte_memzero_explicit(void *dst, size_t sz) +{ + memset(dst, 0, sz); + rte_compiler_barrier(); +} + #ifdef __cplusplus } #endif From patchwork Thu Feb 13 22:16:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151480 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E21AD4621D; Thu, 13 Feb 2025 23:18:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2BD3D40613; Thu, 13 Feb 2025 23:18:35 +0100 (CET) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 6BBAE402F2 for ; Thu, 13 Feb 2025 23:18:33 +0100 (CET) Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2fa2eb7eb45so4146992a91.1 for ; Thu, 13 Feb 2025 14:18:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485112; x=1740089912; 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=LDJEmF/Kxqut4fqC01LqbnxieZQJdgOyhSVGx6oqKFA=; b=jasRuB5A2hsY0P11luvQsHLDal7OxCHsIFVqsolv99XtFuoJ6AOKKeznZGdrwcZ89P FTBnI6RcUp/wg5sdZTSH96VIwL/UuDR19dn0tR/zF9osRS92Lgr0UoTnVvwvnbJvSA4U z//+1iUYaNepo6/4od6ye5UYTO2B/kkY2/FaPbi1RNJmGxhg0c6NBKwJ/lpC2cO1cbmF ekXT9pjmjg0kBg10z2XHmMlmDyHo3JHCp72O7O7k1LDpAbUF+N5cn2RCD8Pm1Pdo7gU7 /iPQGeqpCrDLA2LndoktW7SVMoEZQReNYljrcjNraiMhx5f3XhsEtrNHBU9DIG5jbZY8 1uAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485112; x=1740089912; 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=LDJEmF/Kxqut4fqC01LqbnxieZQJdgOyhSVGx6oqKFA=; b=QhL6zcASikJXu51Gw6IPZjcy9Xp1jCYJr6F12JSpSv6fgTPTmNsr3RUwJ/U7yKUsax xxBKqL8VuhzIhmyNrFeo4phe1XMhF3DGY0WIkbEHQ9N+rWVdZD2hvZ3j9U6bZkvU3uPB eeW+C7TiqFZu/df0JAi5+r7DZrvJ6G8PuEE/EjEriMG120nefC1QcQlFwb+lVOoFyP22 +QFchDLqKqu+tJ2H+YYX6ORHCMkrjyS9+Kp79MjXu0Mdt7hT4oQQY8nsfGgGTK0BLofn kWSIjiMbSDfz92b4bGXyVIdGNMULWyiFUzU1ifpd2FqCS0Ze1rlVnR/9fXQI8953l238 S+Lw== X-Gm-Message-State: AOJu0Yx/QRDKJHokY58PZq0+6BvP48g0elk17kCM1agCmmnd8abr9Rz3 R+nqsQLJVFE+ZPQIT7Ab/XeJsuxNti2jBCQAMdvb0inVyDJSLWEzgrAY2Ej3lvg9nsPMd3+KZpY H X-Gm-Gg: ASbGnctATZsCugCGEOoba8rK6utSbA6ScsSl5ZHdwe4UyDHi5zvO91URmbOf9WZGj0O SY3RGp7LJ3OSxF0Fc8lDz+hIuUQZpzhPiOlNBw5NlBAT22dU8Irrws4fuVDzcnlnMC3sfuNJy8k ib4V4HZIJDdWtNsSe91WGiyEw4zFhVJ6QjUuMP+1636Rab8dL2c0evLGBCefhHDKtMY6RppFVVv /Lln++EzG+2TOkoQNUycLK/rvzeKE2pi1D9/WB1CMf8W/uLcI6OhWnsQ0PDY92mqYKF7Lq+H6Ds N4SHmrjK50FRo/F6owVnoDt6bL+VnI5bdnYAPY8OcoxSV7awewRwd9+Y6Z6m1wZUgysU X-Google-Smtp-Source: AGHT+IFFozhayyUOAbId64lwn3gjdR5+DXMMweEhqo4FeTtJcT1K26hs9IeQoYdPzQkL5ylPJRrfJw== X-Received: by 2002:a17:90b:3c0a:b0:2fa:603e:905c with SMTP id 98e67ed59e1d1-2fc0f92452cmr7752784a91.2.1739485112575; Thu, 13 Feb 2025 14:18:32 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:32 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov , Tyler Retzlaff Subject: [PATCH v6 02/11] eal: add new secure free function Date: Thu, 13 Feb 2025 14:16:15 -0800 Message-ID: <20250213221819.1856769-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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 Acked-by: Morten Brørup --- lib/eal/common/rte_malloc.c | 30 ++++++++++++++++++++++++------ lib/eal/include/rte_malloc.h | 20 ++++++++++++++++++++ lib/eal/version.map | 3 +++ 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/lib/eal/common/rte_malloc.c b/lib/eal/common/rte_malloc.c index 3eed4d4be6..fc2d2ae3f1 100644 --- a/lib/eal/common/rte_malloc.c +++ b/lib/eal/common/rte_malloc.c @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -27,27 +28,44 @@ /* Free the memory space back to heap */ -static void -mem_free(void *addr, const bool trace_ena) +static inline void +mem_free(void *addr, const bool trace_ena, bool zero) { + struct malloc_elem *elem; + if (trace_ena) rte_eal_trace_mem_free(addr); - if (addr == NULL) return; - if (malloc_heap_free(malloc_elem_from_data(addr)) < 0) + if (addr == NULL) + return; + + elem = malloc_elem_from_data(addr); + if (zero) { + size_t data_len = elem->size - MALLOC_ELEM_OVERHEAD; + + rte_memzero_explicit(addr, data_len); + } + + if (malloc_heap_free(elem) < 0) EAL_LOG(ERR, "Error: Invalid memory"); } void rte_free(void *addr) { - mem_free(addr, true); + mem_free(addr, true, false); +} + +void +rte_free_sensitive(void *addr) +{ + mem_free(addr, true, true); } void eal_free_no_trace(void *addr) { - mem_free(addr, false); + mem_free(addr, false, false); } static void * diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h index c8836de67c..69c965099d 100644 --- a/lib/eal/include/rte_malloc.h +++ b/lib/eal/include/rte_malloc.h @@ -51,6 +51,26 @@ struct rte_malloc_socket_stats { void rte_free(void *ptr); + +/** + * 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 + * be used for security keys and other sensitive data. + * + * This pointer must have been returned by a previous call to + * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behaviour of + * rte_free() is undefined if the pointer does not match this requirement. + * + * If the pointer is NULL, the function does nothing. + * + * @param ptr + * The pointer to memory to be freed. + */ +__rte_experimental +void +rte_free_sensitive(void *ptr); + /** * This function allocates memory from the huge-page area of memory. The memory * is not cleared. In NUMA systems, the memory allocated resides on the same diff --git a/lib/eal/version.map b/lib/eal/version.map index a20c713eb1..fa67ff44d5 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -398,6 +398,9 @@ EXPERIMENTAL { # added in 24.11 rte_bitset_to_str; rte_lcore_var_alloc; + + # added in 25.03 + rte_free_sensitive; }; INTERNAL { From patchwork Thu Feb 13 22:16:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151481 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44ABF4621D; Thu, 13 Feb 2025 23:18:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7DF540651; Thu, 13 Feb 2025 23:18:38 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id C05364060B for ; Thu, 13 Feb 2025 23:18:34 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2fc20e0f0ceso1266797a91.3 for ; Thu, 13 Feb 2025 14:18:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485114; x=1740089914; 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=ryB8gYuMivydFfpfOBP5OdqnuMeQySFS+zV15pplPDA=; b=wpla1Sf/4sfbKpPYe3/nuIbgduSDlI+oHcZPljl/QzbqPAOFLdJ1RXslz+CrxTcT8S JqMXVvkuHuFQ0xIUvrcWLijJVvMcSYk99RWPtuqcY5Ks5WDqWl6XLkLFBF5baAePX1nr UyzRXzzgJdmLqRgDcWaNQ5CEyqAaTIWmredNwJaOzNNYNVCLE7/ZisLzoLxPczeELPCf TKQfH/EKFXmVeRGwBCcU43udestpqvl30QeG2esHEG4VviCHSY+qc3MZPE4n5QFkdPEu SOBJxyGGJ2AGuRJKNcBdK+PEFSZ0RroA07Nb3msWwTEqRunF5MZ4OWHD1kR+9QFV4bXR Be7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485114; x=1740089914; 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=ryB8gYuMivydFfpfOBP5OdqnuMeQySFS+zV15pplPDA=; b=PAwwOoeGfJ72krDM+yAiyC9xHjaCDY8DabEa/V2co3+W1FDS7o0jXNgn+gVxS/onoB m2FUgi+vkj/AS3wA75dNl/ezhvl1lQIcKbMBJgB8mTrVxLq91vG3V/g+8aKv/1Mc1IZl vYFCn1ul32lW5o+0u6Fwqt79jkLcQ/J1eMi7lI8uyjd2Jn/Y/2T0Yn2484UwyBlCqV6b YkzUkSp4hyRh5cr0tf148sPW95Q+w+SVbKHC+txVSpUhkG6YyxzfgxyKUr+ur/gS2wI6 97+bfrPfgHLBjnVwIFnD/zSKIS2hXr6kXjhRRl6HQAAoxnKu1y51Gsaftge6RA05nIil C4Gw== X-Gm-Message-State: AOJu0YxyFJv0R3HVI6NvPq9WeZvGXcNfaguUM9XZf7Z18iOgessJNlOM +qnYKRRthGdQMEpUdfZrQ7ArAqzZ88E9dBam15Pj/z1VQZj3zZccgr+IDRpg379j9ShN0DbDwcF R X-Gm-Gg: ASbGncsNU9pCT7hTGVct4AEGzSLX1gOZiaRcEQicpTHuAmKSs1DUle/Flo19Aw8PSdw Cm6J666TKi4phJzmMMt1qecPa6Q2ddgSjKsiFlS4BG4IGQYJ1FPA3zUyaDd2m2zNO9grMaIYDlS MzHrGmjP+8L1vnBKf6jfSw+tduI11fOVZirb7G9DgBXhKy9q2GkR2PUG/Jg3QnZwUnczmkoggyA gFgrnWB/PvDOElm21ZjwTUaLlyIf9ARqW1yfXiOOXqbuWtal3gVYuDjnLHx1SjIRJGU1zDH34Ph YlARKwdf+VcBSkW4aU6p/WQf8x2IvxJquh+VmGGemu18JXz1XVI0BrcHMPYpQoySw4dC X-Google-Smtp-Source: AGHT+IHhId6WTz4O/tMhDTbMDja5NuP6fm6ffDg27uO+JavGH5FRdxWD68kvhF/v64Ygrk15bCYKnQ== X-Received: by 2002:a17:90b:2d44:b0:2ef:114d:7bf8 with SMTP id 98e67ed59e1d1-2fbf5baed84mr11729536a91.6.1739485113893; Thu, 13 Feb 2025 14:18:33 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:33 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Kai Ji Subject: [PATCH v6 03/11] crypto/qat: force zero of keys Date: Thu, 13 Feb 2025 14:16:16 -0800 Message-ID: <20250213221819.1856769-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index 9b26f8a89b..3564a33484 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "qat_logs.h" #include "qat_sym_session.h" @@ -1621,7 +1622,7 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, if (AES_set_encrypt_key(auth_key, auth_keylen << 3, &enc_key) != 0) { - rte_free(in); + rte_free_sensitive(in); return -EFAULT; } @@ -1633,9 +1634,9 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, aes_cmac_key_derive(k0, k1); aes_cmac_key_derive(k1, k2); - memset(k0, 0, ICP_QAT_HW_AES_128_KEY_SZ); + rte_memzero_explicit(k0, ICP_QAT_HW_AES_128_KEY_SZ); *p_state_len = ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ; - rte_free(in); + rte_free_sensitive(in); goto out; } else { static uint8_t qat_aes_xcbc_key_seed[ @@ -1666,11 +1667,11 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, if (AES_set_encrypt_key(auth_key, auth_keylen << 3, &enc_key) != 0) { - rte_free(in - - (x * ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ)); - memset(out - - (x * ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ), - 0, ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ); + rte_free_sensitive(in - + (x * ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ)); + rte_memzero_explicit(out - + (x * ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ), + ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ); return -EFAULT; } AES_encrypt(in, out, &enc_key); @@ -1678,7 +1679,7 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, out += ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ; } *p_state_len = ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ; - rte_free(in - x*ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ); + rte_free_sensitive(in - x*ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ); goto out; } @@ -1698,7 +1699,7 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, return -ENOMEM; } - memset(in, 0, ICP_QAT_HW_GALOIS_H_SZ); + rte_memzero_explicit(in, ICP_QAT_HW_GALOIS_H_SZ); if (AES_set_encrypt_key(auth_key, auth_keylen << 3, &enc_key) != 0) { return -EFAULT; @@ -1707,7 +1708,7 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, *p_state_len = ICP_QAT_HW_GALOIS_H_SZ + ICP_QAT_HW_GALOIS_LEN_A_SZ + ICP_QAT_HW_GALOIS_E_CTR0_SZ; - rte_free(in); + rte_free_sensitive(in); return 0; } @@ -1757,8 +1758,8 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, } /* don't leave data lying around */ - memset(ipad, 0, block_size); - memset(opad, 0, block_size); + rte_memzero_explicit(ipad, block_size); + rte_memzero_explicit(opad, block_size); out: return 0; } @@ -2006,8 +2007,8 @@ static int qat_sym_do_precomputes_ipsec_mb(enum icp_qat_hw_auth_algo hash_alg, out: /* don't leave data lying around */ - memset(ipad, 0, block_size); - memset(opad, 0, block_size); + rte_memzero_explicit(ipad, block_size); + rte_memzero_explicit(opad, block_size); free_mb_mgr(m); return ret; } @@ -3240,7 +3241,7 @@ qat_security_session_destroy(void *dev __rte_unused, if (s->mb_mgr) free_mb_mgr(s->mb_mgr); #endif - memset(s, 0, qat_sym_session_get_private_size(dev)); + rte_memzero_explicit(s, qat_sym_session_get_private_size(dev)); } return 0; From patchwork Thu Feb 13 22:16:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151482 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9BA474621D; Thu, 13 Feb 2025 23:18:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F151B4066D; Thu, 13 Feb 2025 23:18:39 +0100 (CET) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id 4015C4064C for ; Thu, 13 Feb 2025 23:18:36 +0100 (CET) Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2fbfc9ff0b9so2303949a91.2 for ; Thu, 13 Feb 2025 14:18:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485115; x=1740089915; 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=c8mVx65OZgwlPD3YqCSP4AJR4DoGBjJVIPIjf98KaNw=; b=tc+yaQ42SswzZDOuGdOj6T6TdKjNyQJ5PfL5FElXpzTVGp0feokb1QcJG+jDfLlWxE doty9oLGkCkpUwKpEp/0deKVqjmPEMzuE09gj75vir8AAoiwTs1fpVciirVQR/SuAsbd mdp25EYcbwieTDtaAc/CvTppmAQNRhX6wg5lLg5wC3acxG1IBmF5KouzR1h5lefNunBa w0NQGIbIZY/UKB62Wg4PuYqBUcPrA6TaDRcOgdHbbWuX1foKvBEBecEBvdpmzqqHTKxx kUy5hC9VcHb7KQTzYHhMxCUhQXLW4nPKDFDNNhtGe3/f9VCNo9aZetkeyVV3jt7QXcGs iuHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485115; x=1740089915; 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=c8mVx65OZgwlPD3YqCSP4AJR4DoGBjJVIPIjf98KaNw=; b=fOJWlq1T+1rcVvpOyr8ImabM1WzxhiL3N1FOKjYTKe7ti4Zt0Qg9sivpoNbMzyAWML a5UrHNXeVyqUlvOgsuWM9NltqkWv16RS9RTnRBmwc0RLop3JjjQnpxtbEAySjHBURilw ZBnvm9+VbININPdFVy4P2WFUeIpdrJCvN4diA+1+mLZQIqwIOq5GlexhVRjyw0I2ocPU cqFrjZDxnjOHJkRk0x+QRvN7Hqcc8b1Ox/0fyXPMWqsDMhgL20uFIFyxrxvs14hmJpbE 9hHSkvHK4rSmj6AkibGid9GIiJjw0Cffp/Wt6NXDI7ZuEx57eG16uArN2OfebBix/OLi pLbQ== X-Gm-Message-State: AOJu0Ywe+7tf0OLsWDlrxMky8W9qVyyjj2CEgFZuI38Bsu+aPD3WNcqy yLYDsUaj64Hk+7KC/mzKPIuO8nTraeq5IJLhBOzd4pXYVk/cqpS65ypMi9CPrJf+jzn91KUvw9u O X-Gm-Gg: ASbGncvZAlGZDZ37yFbnn3/gXCLyYVeLDWJ/lbbdRro9s9ebRtWLf98d/XiQpt4bDpq uVz8x2AmFvUzUcaTJYxpzQxMXiv6b3Y/dGDp7w8g6zlS7Xv5ho1pbTABFrs5s3GOIsRWPWoxZNN pxQR/mrgg2UgaKs89aQKh9hNZYG1b8Ur+s1Jh04q9KVSCwBeH1WhFaNN82WiaCCA9Hy5tH7s41X abFALdJYkpslHsrxKzieTfhyx6PQfyA74H8IEmngEpqOpnnUNRRqdI4sN7wXDs2u1h7DZsOMZzi TsXlQPHBTaAbjl4KfCrer/SpWHVimticLWb6awCIbCx7xfEd9c6FzXYxdfsasucbeex4 X-Google-Smtp-Source: AGHT+IHGmF45iplnwNNiVTX8hw4D7Up7BycBF7+GrYuTOQCD8WNia2AW7CrGdi8d4kogyid+I4NnQA== X-Received: by 2002:a17:90a:e70d:b0:2ee:4b8f:a5b1 with SMTP id 98e67ed59e1d1-2fc0f09f09fmr7219647a91.24.1739485115438; Thu, 13 Feb 2025 14:18:35 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:35 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Bruce Richardson , Kai Ji , Ciara Power , Fan Zhang Subject: [PATCH v6 04/11] crypto/qat: fix size calculation for memset Date: Thu, 13 Feb 2025 14:16:17 -0800 Message-ID: <20250213221819.1856769-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- drivers/crypto/qat/qat_sym_session.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index 3564a33484..7836c95064 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -2347,7 +2347,7 @@ int qat_sym_cd_cipher_set(struct qat_sym_session *cdesc, return 0; } -int qat_sym_cd_auth_set(struct qat_sym_session *cdesc, +static int qat_sym_cd_auth_set(struct qat_sym_session *cdesc, const uint8_t *authkey, uint32_t authkeylen, uint32_t aad_length, @@ -2620,27 +2620,27 @@ int qat_sym_cd_auth_set(struct qat_sym_session *cdesc, break; case ICP_QAT_HW_AUTH_ALGO_SHA3_224: /* Plain SHA3-224 */ - memset(cdesc->cd_cur_ptr, 0, state1_size); state1_size = qat_hash_get_state1_size( cdesc->qat_hash_alg); + memset(cdesc->cd_cur_ptr, 0, state1_size); break; case ICP_QAT_HW_AUTH_ALGO_SHA3_256: /* Plain SHA3-256 */ - memset(cdesc->cd_cur_ptr, 0, state1_size); state1_size = qat_hash_get_state1_size( cdesc->qat_hash_alg); + memset(cdesc->cd_cur_ptr, 0, state1_size); break; case ICP_QAT_HW_AUTH_ALGO_SHA3_384: /* Plain SHA3-384 */ - memset(cdesc->cd_cur_ptr, 0, state1_size); state1_size = qat_hash_get_state1_size( cdesc->qat_hash_alg); + memset(cdesc->cd_cur_ptr, 0, state1_size); break; case ICP_QAT_HW_AUTH_ALGO_SHA3_512: /* Plain SHA3-512 */ - memset(cdesc->cd_cur_ptr, 0, state1_size); state1_size = qat_hash_get_state1_size( cdesc->qat_hash_alg); + memset(cdesc->cd_cur_ptr, 0, state1_size); break; case ICP_QAT_HW_AUTH_ALGO_AES_XCBC_MAC: state1_size = ICP_QAT_HW_AES_XCBC_MAC_STATE1_SZ; From patchwork Thu Feb 13 22:16:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151483 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3FD7D4621D; Thu, 13 Feb 2025 23:19:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 314CB40673; Thu, 13 Feb 2025 23:18:41 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id 8B5A940612 for ; Thu, 13 Feb 2025 23:18:37 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2f42992f608so2339125a91.0 for ; Thu, 13 Feb 2025 14:18:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485117; x=1740089917; 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=HNJHgWrp7PrghusG1EGUIcrHmq1efQC46Cm2w7NVkN8=; b=xEUs+i9r5WyaPpj53a+xwrF1oUVOLwEkU2WX/VBu/7k0cf+fi3GYLLSeVTWWerwD6H AU0sayWJ8JXe8CseYsJg23tQD2DBbYMuRO1f7oBpClUPuYqtCZOIVshlVszwhaKp2+RN JBiBkCDvHuFAT/nFsLrZjVuYkhpz0jC9rFeEK7dIbYBZS1m2hA4vJuy6Q3X0O7lcRg5s x6gs2qKemi0PnIwWEpTfFEjgY/8ESPUcmn4tfPgTM0Lq01qpipE+dYxBAXxpNLMEFS6o jfLuQof1HoNKPafpLWay8hYNF0WkOaM56DVMCrvlqZhgYoO5UQN0HDhJbOcax13rr7hB /stA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485117; x=1740089917; 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=HNJHgWrp7PrghusG1EGUIcrHmq1efQC46Cm2w7NVkN8=; b=Ex2tC74TNq5xgF3ZanRgCjOutmeFy//QC5b7VV6wauKYlSllU9TMXPDLSb3Yrg1LkU YpxlOqyVWfVJPgUpQdx7VuCwSh81Pu/U59F/ZKGUbEaiWpxS6L9kjDWwpN4GgNAgUa1X wm4izeZiZTFVBu8uyrjtG/MH9FkYkNZmoq4Ycxge6+QrUVtaOkyzT/ipojuqP3PG1Fmg da/bEGcr/PFzFkP0T9U4fnI9fziiDXBWq2iC8JtmZb5F1JBVSRsR4NUKaT+Q5be0Br4/ BmAjCEz5bq1ol67OxrBaWUVbydUM8Q6LP7qCmlDdpsc/eK13Kl4T5EVdRbwPcOjQoHNd D+yA== X-Gm-Message-State: AOJu0YxyG+jykgQrdVeBFIVHz0ozAiRWDkLek8uTO8tXYK02eXmeZnGR tQxE6BOEogd8wazxEJ6rQbKHkdFPmDu3r8HjorebxXoHNrOFLunt6VJBIFWTukBhawxjfSWuXhA Q X-Gm-Gg: ASbGncvM/eIubhnWEswNUZ59LDdlpHHwstwCDMu7sANk8rrji8hTqnlj9EZNWUKqd/d G7EU3GI7NU2VV6IdtLQvkOjLTxVGLEgL4CIHK+bwAe4O07wDDFJXbvCeCpg8JIeiMjYTWK5Szzv UtcwSAiF3r0EERVG1l5sXHmUx8jMMTfeLoKgjqES2lHU4AJDSGWh8h7m8WB9eJgDnr7bye0v0Po ndW2zE+T+IjBmRY5tpaMYmeBqaED3tD9K+ZN8hcpWeuFjskSXpnUFoK+/qyiaGc1spWkwNY+O97 fcnI57RBeaVUn5awCVzsFtfbVhUd329yPjPmOyOcE7jCKVUvNqbj5rc+SjotN2Ru6Trn X-Google-Smtp-Source: AGHT+IGchBI3CLWZrtl6mUF1o54OtuvE/3QbgjZtrggt+a6GBrlPN7XxtnV41bGk5e6OOKVRqiiz3Q== X-Received: by 2002:a17:90b:1d8e:b0:2f4:4500:bb4d with SMTP id 98e67ed59e1d1-2fc0e7a307bmr6599893a91.20.1739485116763; Thu, 13 Feb 2025 14:18:36 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:36 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Kai Ji Subject: [PATCH v6 05/11] crypto/qat: use secure memset Date: Thu, 13 Feb 2025 14:16:18 -0800 Message-ID: <20250213221819.1856769-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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/qat_asym.c b/drivers/crypto/qat/qat_asym.c index f5b56b2f71..d8a1406819 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -102,10 +102,7 @@ static const struct rte_driver cryptodev_qat_asym_driver = { curve.p.data, curve.bytesize) #define PARAM_CLR(what) \ - do { \ - memset(what.data, 0, what.length); \ - rte_free(what.data); \ - } while (0) + rte_free_sensitive(what.data) static void request_init(struct icp_qat_fw_pke_request *qat_req) From patchwork Thu Feb 13 22:16:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151484 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8083C4621D; Thu, 13 Feb 2025 23:19:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5585C4067B; Thu, 13 Feb 2025 23:18:42 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id BF55E4065A for ; Thu, 13 Feb 2025 23:18:38 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2f9f6a2fa8dso2096243a91.1 for ; Thu, 13 Feb 2025 14:18:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485118; x=1740089918; 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=4eCQHxeqtnmJwnbM+apidP+XqcqCydmDyWVcC/qwE90=; b=CSaSRG0E/z03hwa/iwf1i0AVCC2Vaij3Qk8uO2UCzwZZ3Q/7v3WGvPSkJse/sxUJrz 9NMWHZXtLMn/C/XQvcczq8WRMmc1j2AY+qcCTGNpve2sjLfxP5Hjenk1UUbadSGu0dKk /GMe4hhSHUQt5KAhrG6EUzrI5d6eYaW1qcTiazvKF7EfjWV6FbWKuFH1xgufqb2OzoK8 6OXaomc6PpDcpbH+ah8JXBiQETMYhBwouBplbiTU3ePDW++YxaulmjiwXAFB22Y1qehp VDA2+sR/UHT6MFyWTyIoGsWGjxurqOiB07O07gqZmDCCyaOqWHr1N777riqKxGi7lBLx wgqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485118; x=1740089918; 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=4eCQHxeqtnmJwnbM+apidP+XqcqCydmDyWVcC/qwE90=; b=WhDC4NKKRVyI/4oFWcKHhee/irc0mn79/E3vNK1uOZ1jAh0pk3dz2zbMJocPo/xbVs QptEy3tLTHs1Geyl2XwT3RzqPjmnJxUtJLOwKUGCAcAeqYWdqWIpu+bKdFfOGTeqcZ8o BTOP3KtmH4d7pdRoeMr4aMGMy7B3gt+J7R/QehX4If+RcamQ+l8v8BL4jEuOnA79OQlJ 6wDZEXm9d4cznX/N9AIFP+mfKHImb7HmJZifsPI/BaDpTOOnmJo1hlvJVicK2Wn8TYWb ZO46+4YwanOT1BLDB0sI0MxwdedCGUZkiE8E7k5B8vTLO5XO7QHn9zu9cVcYvg8joH3+ LqmQ== X-Gm-Message-State: AOJu0YztZYpgR1MmfQxvWe8Sn1mwuYFtAs2zYxx7rc2kvlVSxbA2lDAo 22XG6JqpN2imRY3a4LpbtPK+OsrWOK2J93BSvLON+NmMRmA3bkySCRsKQm1A/wuRIxrL+nuCaTn 8 X-Gm-Gg: ASbGncsK3NG98XUBMFhKrT86GofREgVAf/AiszUPJiqkyIi0UyPBmI7CKCeU9YRQclg VhBvACArqkRAzIpL6h11LPY7KfynCXoYNf0y1wpUVzxjRTcy8Nh9lT2ytRJyAFjR4hskVi82qGC f1OCcbdA5BlOxQCAXFte8180tzpUT+B+FEnWcH8NndzoGF1zPTgZsp0AxT6AeX2JwQh9ystCbQh abrKwN4nshuSEl9MYWpEFQj1NwUwHkfnHiocML9V3I+tkCbIH/NVtKoEGspKIwqrdHZMkeq0rmW yTMTE2Tz3ra6UiZs0maHOEyCBEJneeS5b+cQXo7c7iLV0deDeXuLgcuipjBOdi0a/UHy X-Google-Smtp-Source: AGHT+IGOAjHk2vC4vhzW8yqZ96uMcKSaWxD26flwsqsCAKGvkQKEhHfBL3j9cUXT6SbC07GIqt8TeQ== X-Received: by 2002:a17:90b:520f:b0:2f1:30c8:6e75 with SMTP id 98e67ed59e1d1-2fbf5c6b7fcmr11968729a91.32.1739485118010; Thu, 13 Feb 2025 14:18:38 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:37 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Chengwen Feng Subject: [PATCH v6 06/11] bus/uacce: remove memset before free Date: Thu, 13 Feb 2025 14:16:19 -0800 Message-ID: <20250213221819.1856769-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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/drivers/bus/uacce/uacce.c b/drivers/bus/uacce/uacce.c index 9ca048122d..cc1e42d56a 100644 --- a/drivers/bus/uacce/uacce.c +++ b/drivers/bus/uacce/uacce.c @@ -454,7 +454,6 @@ uacce_cleanup(void) dev->device.driver = NULL; free: - memset(dev, 0, sizeof(*dev)); free(dev); } From patchwork Thu Feb 13 22:16:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151485 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4D98C4621D; Thu, 13 Feb 2025 23:19:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C6904067D; Thu, 13 Feb 2025 23:18:43 +0100 (CET) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id 1EFE84066F for ; Thu, 13 Feb 2025 23:18:40 +0100 (CET) Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2fa44590eebso2835138a91.3 for ; Thu, 13 Feb 2025 14:18:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485119; x=1740089919; 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=AZmRfVHuNAu8WwJa8G2gVzrRUKoolZ9gQmZARtWp9Nw=; b=ViWkYfp3Qq3fH/i0GY/S/a46oaOM1jgIuE/K0AqvmOvQXYDLDaQH3kidr1fKDnPxuQ Ui/A+A3dUZJDUmifsG0s2arJWm4UsLiVEYkGkG2867oG7TN5olC6RjUqGSzLc+95F6OE +KvUnqvrmNyK+vjMVFHGQtfQM8Cc3AtheLlgQ/Y18SoHabfmPReXTFjrQb5MoMQ385V2 AKjT6vnQBJ0LgL3um3+A844LhahVyP3VDQjbNap1Q+CM8dFMZ9dKfCc+usEa9IPy8pAp n4yg57D4OARnmqUXhCN0gTImwlq1CCff0wscRbLd+OCBAcZwhF1D4fBrxFn/C9O107Ct wd2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485119; x=1740089919; 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=AZmRfVHuNAu8WwJa8G2gVzrRUKoolZ9gQmZARtWp9Nw=; b=acfC2sMBXKDWRJRkY5IeCbxFxIJo/bR8+5UhjzsxtMhL2/n6gXEoPIr5E1YRyTkEeW fFsMoTLtqa5NsT5a8tJIlvuPaV0v9TG++a/tLj4rLHBRM9Fc5k/oPN4Z76d1YXBZXK1N r/mUL2mtKLCmrPAbC86W6eosrRenIkRODLJE61ooN6aq2p6aBueN3CpnOWVOntxRHjNi IgelrnPz/xpnTgqcIelxNWS30bH0C/UWJLyxWY0wv8g4s4KftrUQmzKSU2g+kbr0FbSM ecw5aX8pHN3CfFUFJ5kUqnIX4YyWO+M6b+IAF9PWxE8Bix+rdDmqDsJzdtrqMMc6hQa+ l1QA== X-Gm-Message-State: AOJu0YwfkrHI7CLNg3O57ltyQCPt2/X42/LsGEk337pJBP11999HjbHa WPYUA2lNejH5QoL/CRzUl2rogGOVK+xZ3+gPWoiq7oYrY3QdAl7AZHOt1QUGRVS5gcBjZMrpW6Z Q X-Gm-Gg: ASbGnctu+NzOnc1C2uXqjDWR4xv+d96c7zKnslRWq2JcDwzkbpN0U/daPPfGuMNrceR 0D/XHCpaf0dEixXG2VbYCO4g7WnSHiWlv2RrqMyoR91Lhsm8tNOleGeJBgoUXdDoK/7pCtQ+G5S pNj3YFR4/Es1rlXi6PQi1FCWPII9RsQ6JM0gHwMg1nGcfXBNtJzFqModpfU4dObcOaDisl4HBIS uCfc4TetaXRcl9Wfv4J9JfFTRcDGePQdTZ5G39flrDQCEgs8PvFKWwSYmkWULgGjoaZEqEN03UX tCt4xaogT3QJBSIltysQvCeBQfglMYiUgghtRxQDS7sHoSa1OaUh9jnkhf+b1o7W83hs X-Google-Smtp-Source: AGHT+IGkgR+4IeQdNZJLMX4fo9hT0x8AvZht0HxCXA14TVXmz8MG8Ry/+2KQ/tvvU7AOC/MEAFI+Xg== X-Received: by 2002:a17:90b:2692:b0:2fa:1851:a023 with SMTP id 98e67ed59e1d1-2fc0f0fef42mr7040560a91.35.1739485119321; Thu, 13 Feb 2025 14:18:39 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:38 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Ashish Gupta , Fan Zhang Subject: [PATCH v6 07/11] compress/octeontx: remove unnecessary memset Date: Thu, 13 Feb 2025 14:16:20 -0800 Message-ID: <20250213221819.1856769-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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/octeontx/otx_zip.c | 1 - drivers/compress/octeontx/otx_zip_pmd.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/compress/octeontx/otx_zip.c b/drivers/compress/octeontx/otx_zip.c index 11471dcbb4..331d2d9475 100644 --- a/drivers/compress/octeontx/otx_zip.c +++ b/drivers/compress/octeontx/otx_zip.c @@ -81,7 +81,6 @@ zipvf_q_term(struct zipvf_qp *qp) struct zip_vf *vf = qp->vf; if (cmdq->va != NULL) { - memset(cmdq->va, 0, ZIP_MAX_CMDQ_SIZE); rte_free(cmdq->va); } diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c index c8f456b319..74e3e942ad 100644 --- a/drivers/compress/octeontx/otx_zip_pmd.c +++ b/drivers/compress/octeontx/otx_zip_pmd.c @@ -479,8 +479,6 @@ zip_pmd_stream_free(struct rte_compressdev *dev, void *stream) (void *)&(z_stream->bufs[0]), (MAX_BUFS_PER_STREAM * ZIP_BURST_SIZE)); - /* Zero out the whole structure */ - memset(stream, 0, sizeof(struct zip_stream)); rte_free(stream); return 0; From patchwork Thu Feb 13 22:16:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151486 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5CCB4621D; Thu, 13 Feb 2025 23:19:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0AE1340696; Thu, 13 Feb 2025 23:18:45 +0100 (CET) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id 3B96B40677 for ; Thu, 13 Feb 2025 23:18:42 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2fa8ada664fso2284721a91.3 for ; Thu, 13 Feb 2025 14:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485121; x=1740089921; 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=lTtX4AHkbt56cyz6ePjfJ2NXdYZ+Ear04KnwLkajDA0=; b=ui4KATQqjthOd6ShqkSSAjJ/moVrnEk+kHs6bbYWWw2yU5kKiNi4e9d+udkfW475J8 EoKaxDQHvTDiSf8cdAJ4SeE5qqtlUViII1F5arcHprMYltuqE7mTUW8CBdUNWpuTdBic fmmf6m4LW0aW9X321HybXX82ErnhnQ4UplmT7j38EGE+IplY81Xip2/4loycZZnXIx7o LUfCLQcQRUvxGUPIzxNo3qNKoWrTZQkakh2XQYkMj2OKBDnQABUyG37oo8FKm3erR+DB lkisbGkDX/u2aicZ8mY8v8VZmUKIVyFgFmC7HE/UtDCW2fOCJagCARzAs6STyUWk6cz0 WKUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485121; x=1740089921; 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=lTtX4AHkbt56cyz6ePjfJ2NXdYZ+Ear04KnwLkajDA0=; b=WaofCFy9Ei1FTiCbDtGoWWaIAKwn2BNWINmwVLeZPei4/M04nMlQvXdMG2J2KyMQzp oYlYKic+5bgdget73YVJTVbHKCkIpskMjg2mPhvTez4PKOnfQdiRoJy5xKG5tx+YKdk5 x/me1z4EqGVS3KYLqoaNqwnK/l8h/jHzjs4Mn1y/WUjY6T9Er8yi80FUXXGPHi4V3tuA XvwWoag6PGY4oukcZhUCRwcikr15EAM30SYXDP63cB/VqgjhqGao/MnGbbSodZ0TbN0Y Pqo6lDB/9rIxe/o7GMzdVqfb2mA/+ss1XP2ZNMhDx4RAiyZ+Mjw3Ti7gpph+Az8wuQt3 tf0w== X-Gm-Message-State: AOJu0Yyy/lXNfMM5Obj9GJDoZQ6yhLOrxV43K2OETd1jTBmjiL/UaDbz 3fiV/7Ab81Sfcwxn0yPaTQ8zu1drY8v/y5p2JRqrYqigQwJx7urhNZaXbEUyzXOFXeZaeOVFHle L X-Gm-Gg: ASbGncsj4O7pAPhS5Cv0K44Qlurfcwdx1WhbL3rsRsmy3JS3MSy291rHMt0pcc99tUs 9OHQpAd5pcBfoZHWZL6Sd2dFlVD0UPfnQM67hG/Bmb+vxU7KwKXuly+ZGWflnkePj8FpomFvmna sBiVCkYKHpiI3z5twpc+0SjAlFG8ZooHmVYIaQfjdySywwHVNB9Xu2Y0ic3ZAgcNjZ0o8MyuwAd 2tvLYttjee0RlajoVXsbe5xmN26lREconJpVdx0Wc4wOBIsr7xCC7Ka4XJTkMaT/kKZTaK/8DGK rDu2mR+U14ksOrjFC79AgSCOsqmYFS3mosUs7jIX/2HuBFhu345IyP3x6zVOb9mKjvw2 X-Google-Smtp-Source: AGHT+IGGvmGNN267d7rVUdQsw3aCkxG3LAezro+VNXH5fOVJl3Lg4SoWcln4uJhhvyF6u/w8+pNnVw== X-Received: by 2002:a17:90b:4d0f:b0:2ee:ad18:b30d with SMTP id 98e67ed59e1d1-2fbf5bb2fe4mr11731041a91.6.1739485121442; Thu, 13 Feb 2025 14:18:41 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:40 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson Subject: [PATCH v6 08/11] test: remove unneeded memset Date: Thu, 13 Feb 2025 14:16:21 -0800 Message-ID: <20250213221819.1856769-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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 changed, 2 deletions(-) diff --git a/app/test/test_cmdline_cirbuf.c b/app/test/test_cmdline_cirbuf.c index 8ac326cb02..1be357abf6 100644 --- a/app/test/test_cmdline_cirbuf.c +++ b/app/test/test_cmdline_cirbuf.c @@ -281,8 +281,6 @@ test_cirbuf_string_add_del_reverse(void) printf("Error: buffer should have been empty!\n"); return -1; } - /* clear tmp buffer */ - memset(tmp, 0, sizeof(tmp)); /* * reinitialize circular buffer From patchwork Thu Feb 13 22:16:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151487 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3DDF74621D; Thu, 13 Feb 2025 23:19:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 648A1406BC; Thu, 13 Feb 2025 23:18:46 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 9DA2740685 for ; Thu, 13 Feb 2025 23:18:43 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2fa7465baceso2881770a91.0 for ; Thu, 13 Feb 2025 14:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485123; x=1740089923; 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=BWlABOBDjT+D93lC4xk3UAjMk4KNQQKjBPILflrvYnM=; b=mgCvXLTZt2sgwG7/klMhftm00EawyTSd4vAGCLmmHCNHa0Hisz2o0JW3fbLw7BOIds HpqyNN8rsLgPbZ6hxZ0a7gBuLMN8vvIIHykWPUqcWloMfHVhCZa7bLTTD0eJWAdPjhho wcmhY1Lvx3yvx4l0tKxO67ts4wZj4L8GIKyxnzJ87Ktpe6baPyjZ8Zbea9D4rF9rPqyW wp+qf5hLFLqA3MHRKc5ALAc54VM12/5Fvl4VXhvuGxHNcHqPFnZcbdupT9oK1JBWx/ig o93H5MYr3nWyIroP4pQqwFfVKbpGwVv5e3uQEGkvO93V2mUDCnYR/6i1n+AU/Vtu3tNg RlyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485123; x=1740089923; 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=BWlABOBDjT+D93lC4xk3UAjMk4KNQQKjBPILflrvYnM=; b=For93NBIUBPLv+pE2mZ5CMKl3lm/Iukl/YGFk/ohLH3gm8Mj+3ZOOK83m3aYzSDiFG g0j/mcaB25EyA6h0XCyWD5wsAxyN/3iHT6FInU872uW8SRI1reeoaN9MWfoo5Urjj27o WAT8WD+/PWWKkNt8bvfuxZdlZPEU+PAAuoR2SB29aSLzvlAwBTnrlizM7EZcGbPGVSmj mCv4elA4QAgOI/yFEZjzi8IBqKeF/qcc2yB51i1st+9dm3RHW97vmHKoXPUYjKj5ruqA fK0Pn79WDF9xIyO/yvm7hiHJ9/J2dlXIS1DBsiX0+J1VfYMD6lDCeBqQKiG5+EE7w9PW Rxsg== X-Gm-Message-State: AOJu0YyDyGjf6fvwp3Sa6KGe+AMTMUHngLHm6DHsBL36sbmJ984ZAacC pth9HtpqVLdKn9nNxx+RzBiM6AP62ycjIgfnm0/Ijq5CVcLZTSf3UiuchpOxFHB+rklGqP7TUKY g X-Gm-Gg: ASbGnctuN+1J97fTkZ01RplRv4ioRvNY9o6CGghi89YnY59nCoNTHJnWE95emMvT+8d RmafkQsyvdGvOI0QbEcJZhtlUiUVO64/lLw6Q7GfdmJ07mgZa6gqK9CjsyghznRVukHOcYJzZnK T3svHiIDzGOmv1TFqRo3S+4FuUOx7nEUOWHA0nJyOHfioL8+8TKH39J+9pz54M+TAZv9zKN7Qh9 odCoabvoV4cdSXNYnVgJIsKeJ18X1p/ZSApIirr6iLE06D7u4h3MbyT6rFUYO9I5ibXSVT0LrNv oZkZGevFObxZfdy2b8q6w0NOc3x+ta7AvbJgLir5gqsHEJt+bhzEo1fvrupK/OOq+jxP X-Google-Smtp-Source: AGHT+IHWpZ9hvmldZjMe1EFjreCJQ2C2OpQSk9yoqqLwI/+eWpF4aGpjHzWRtJkCZnvXATgiNxzE7w== X-Received: by 2002:a17:90b:3f05:b0:2ee:b8ac:73b0 with SMTP id 98e67ed59e1d1-2fc0ded15admr7824105a91.2.1739485122827; Thu, 13 Feb 2025 14:18:42 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:42 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org, Christian Koue Muf , Serhii Iliushyk , Ferruh Yigit Subject: [PATCH v6 09/11] net/ntnic: check result of malloc Date: Thu, 13 Feb 2025 14:16:22 -0800 Message-ID: <20250213221819.1856769-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/ntnic/nthw/nthw_rac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ntnic/nthw/nthw_rac.c b/drivers/net/ntnic/nthw/nthw_rac.c index ca6aba6db2..f275e64da3 100644 --- a/drivers/net/ntnic/nthw/nthw_rac.c +++ b/drivers/net/ntnic/nthw/nthw_rac.c @@ -31,7 +31,9 @@ nthw_rac_t *nthw_rac_new(void) { nthw_rac_t *p = malloc(sizeof(nthw_rac_t)); - memset(p, 0, sizeof(nthw_rac_t)); + + if (p) + memset(p, 0, sizeof(nthw_rac_t)); return p; } From patchwork Thu Feb 13 22:16:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151488 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E33AC4621D; Thu, 13 Feb 2025 23:19:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E78F40678; Thu, 13 Feb 2025 23:18:47 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 1203640697 for ; Thu, 13 Feb 2025 23:18:45 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2f9b9c0088fso2233552a91.0 for ; Thu, 13 Feb 2025 14:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485124; x=1740089924; 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=Im45Wreomm3zRQ/zODQEb4h64DQAwYWmd5YzkwMj5Sc=; b=lThWmBo1V7S7lc6o5T7BiC5GF1ItQXCt6UM6vYQ5fbEbOborg0S+1HEB3oomF0ohAV MJIjijlWbpGAhwjf6gteUR6v9lfFKFneriY8UY6S/vbXxYFQtCbd8L7EnuaJ1IeFUrkr htuAzMubS/fviKskPQkLBiMN54+Ge3bGf2I9ndWKeEKzR8Yb/3mGCkm/o1D3m30gqKBX uqyQm86nSbUQQ2WKczFvjKcDZSCF7dsBnKgqikDw0nTg6Y6560AwLj25JHhAptDPHzAO ypeWfPY9+dNbTYgdiPGKSqH6Jv7UsWr8lX5mtJtoFlIu2ZnzWMM927jvJQDOsAMDX9O6 aCOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485124; x=1740089924; 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=Im45Wreomm3zRQ/zODQEb4h64DQAwYWmd5YzkwMj5Sc=; b=gvALihT4kw+cuQp/kb2NvsxezCECJn/Uzm06TWeAT0OieaVHk8gOHn+nxlBBhoWtw9 4QCgpXLBxMJi6m5rH+baZnrZwdIu+Sczj9FTwy/fpVBKZinFxuLgY6pWxqDevAD+9ieg 2dBMZifl6H5pj7yvaZyDkRv4mernsr4XVQNl0vQncpMEuJz5IHDqHAszpAi9QvaBgBl5 n50CU4Nc2+znWRM6DzIJ2Zcav4dWRzsUcqAsm2P4Pa0vkKqdcF3WiJmFb/OPTR8E6MLw +iD51QzcZP2A4+s4KG3jfYESysZKIzAmLRYjRyARxouGWJhUkfKjYigflSD7wirXkkIc yXDA== X-Gm-Message-State: AOJu0YzY9gFuW9K0Sn/duVZLcXJeth62hKxtI7ppk69fYt1gvAl5/IGI bxehIvbrn5k6GphLz/8IDnpcSov0pH8TQEI8DTEEkwlbKuIRMibisdf2OgThap0fsMHPK10DSlQ L X-Gm-Gg: ASbGnctDLuoyezjzbcDBF6VitXu7v6zVlKxF70F9oRh3H0qzYxWmvLypfvQ2DGUjGMm YHC8nzL1HEiXqjPzOxkWw7GTR4/yX1wmQGxmTYDkMWpgB9UlyCqC4/eqPBddBD3lDQb1aBlQJ74 bWrklpdHYObWYHctSzDeFAtBiKR36U0dgd7ZXaxMYzByTxukIhOZ8LBTXq/xrsf2OlFAyymI01c vK9kJj8opxZYFMRvv9RMJnpV6zNXunqEuERrkJfZ6H2AbpZPCekKXVQZ5KSv5irNefvdpsLM88D BriFgDlzEq67Nry2HQLQ3e9o43Djk3miKYKpjx3mVMUwKws1oGsH43Xkp0AbrhbJXmFH X-Google-Smtp-Source: AGHT+IGiObUyw0age8OhEj+5eHqH2vBXwyxbntwQI8A5O2Fihwz63RykMSlNqF4jgrUO+yQA5M94zg== X-Received: by 2002:a17:90b:384d:b0:2fa:2c61:3e5a with SMTP id 98e67ed59e1d1-2fc0f9967damr7454068a91.10.1739485124208; Thu, 13 Feb 2025 14:18:44 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:43 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Christian Koue Muf , Serhii Iliushyk Subject: [PATCH v6 10/11] net/ntnic: remove unnecessary memset Date: Thu, 13 Feb 2025 14:16:23 -0800 Message-ID: <20250213221819.1856769-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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/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 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c | 1 - drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c | 5 +---- drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c | 5 +---- drivers/net/ntnic/nthw/model/nthw_fpga_model.c | 1 - 21 files changed, 19 insertions(+), 78 deletions(-) diff --git a/drivers/net/ntnic/nthw/core/nthw_hif.c b/drivers/net/ntnic/nthw/core/nthw_hif.c index 9f699e4f94..d702257d76 100644 --- a/drivers/net/ntnic/nthw/core/nthw_hif.c +++ b/drivers/net/ntnic/nthw/core/nthw_hif.c @@ -23,10 +23,7 @@ nthw_hif_t *nthw_hif_new(void) void nthw_hif_delete(nthw_hif_t *p) { - if (p) { - memset(p, 0, sizeof(nthw_hif_t)); - free(p); - } + free(p); } int nthw_hif_init(nthw_hif_t *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/core/nthw_iic.c b/drivers/net/ntnic/nthw/core/nthw_iic.c index 269754c24a..a98ec659c4 100644 --- a/drivers/net/ntnic/nthw/core/nthw_iic.c +++ b/drivers/net/ntnic/nthw/core/nthw_iic.c @@ -253,10 +253,7 @@ int nthw_iic_init(nthw_iic_t *p, nthw_fpga_t *p_fpga, int n_iic_instance, void nthw_iic_delete(nthw_iic_t *p) { - if (p) { - memset(p, 0, sizeof(nthw_iic_t)); - free(p); - } + free(p); } int nthw_iic_set_retry_params(nthw_iic_t *p, const int n_poll_delay, const int n_bus_ready_retry, diff --git a/drivers/net/ntnic/nthw/core/nthw_pcie3.c b/drivers/net/ntnic/nthw/core/nthw_pcie3.c index 5997ebb419..a5833e166c 100644 --- a/drivers/net/ntnic/nthw/core/nthw_pcie3.c +++ b/drivers/net/ntnic/nthw/core/nthw_pcie3.c @@ -24,10 +24,7 @@ nthw_pcie3_t *nthw_pcie3_new(void) void nthw_pcie3_delete(nthw_pcie3_t *p) { - if (p) { - memset(p, 0, sizeof(nthw_pcie3_t)); - free(p); - } + free(p); } int nthw_pcie3_init(nthw_pcie3_t *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/core/nthw_rpf.c b/drivers/net/ntnic/nthw/core/nthw_rpf.c index 1ed4d7b4e0..d5c19e312b 100644 --- a/drivers/net/ntnic/nthw/core/nthw_rpf.c +++ b/drivers/net/ntnic/nthw/core/nthw_rpf.c @@ -22,10 +22,7 @@ nthw_rpf_t *nthw_rpf_new(void) void nthw_rpf_delete(nthw_rpf_t *p) { - if (p) { - memset(p, 0, sizeof(nthw_rpf_t)); - free(p); - } + free(p); } int nthw_rpf_init(nthw_rpf_t *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/core/nthw_sdc.c b/drivers/net/ntnic/nthw/core/nthw_sdc.c index fc73e6957c..e32d87b967 100644 --- a/drivers/net/ntnic/nthw/core/nthw_sdc.c +++ b/drivers/net/ntnic/nthw/core/nthw_sdc.c @@ -22,10 +22,7 @@ nthw_sdc_t *nthw_sdc_new(void) void nthw_sdc_delete(nthw_sdc_t *p) { - if (p) { - memset(p, 0, sizeof(nthw_sdc_t)); - free(p); - } + free(p); } int nthw_sdc_init(nthw_sdc_t *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/core/nthw_si5340.c b/drivers/net/ntnic/nthw/core/nthw_si5340.c index 05cadc0bf4..ceaa58e0f7 100644 --- a/drivers/net/ntnic/nthw/core/nthw_si5340.c +++ b/drivers/net/ntnic/nthw/core/nthw_si5340.c @@ -44,10 +44,7 @@ int nthw_si5340_init(nthw_si5340_t *p, nthw_iic_t *p_nthw_iic, uint8_t n_iic_add void nthw_si5340_delete(nthw_si5340_t *p) { - if (p) { - memset(p, 0, sizeof(nthw_si5340_t)); - free(p); - } + free(p); } /* diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c index d3213593e1..ff316065f3 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_cat.c @@ -25,10 +25,7 @@ struct cat_nthw *cat_nthw_new(void) void cat_nthw_delete(struct cat_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } void cat_nthw_set_debug_mode(struct cat_nthw *p, unsigned int n_debug_mode) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c index c1b73179a8..ddb11edf7c 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_csu.c @@ -29,10 +29,7 @@ struct csu_nthw *csu_nthw_new(void) void csu_nthw_delete(struct csu_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int csu_nthw_init(struct csu_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c index 8855978349..0b2f97ff01 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_flm.c @@ -26,10 +26,7 @@ struct flm_nthw *flm_nthw_new(void) void flm_nthw_delete(struct flm_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } void flm_nthw_set_debug_mode(struct flm_nthw *p, unsigned int n_debug_mode) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c index 4a8b17101d..3170c363dc 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hfu.c @@ -29,10 +29,7 @@ struct hfu_nthw *hfu_nthw_new(void) void hfu_nthw_delete(struct hfu_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int hfu_nthw_init(struct hfu_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c index 80ead2729a..17381ddea6 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_hsh.c @@ -30,10 +30,7 @@ struct hsh_nthw *hsh_nthw_new(void) void hsh_nthw_delete(struct hsh_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int hsh_nthw_init(struct hsh_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c index 8e0b24dd9a..7a17d36f6d 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_info.c @@ -30,10 +30,7 @@ struct info_nthw *info_nthw_new(void) void info_nthw_delete(struct info_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int info_nthw_init(struct info_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c index edc8f58759..88f3900caf 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_km.c @@ -39,10 +39,7 @@ struct km_nthw *km_nthw_new(void) void km_nthw_delete(struct km_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int km_nthw_init(struct km_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c index 4a9713965b..b0b3f41027 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_pdb.c @@ -30,10 +30,7 @@ struct pdb_nthw *pdb_nthw_new(void) void pdb_nthw_delete(struct pdb_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int pdb_nthw_init(struct pdb_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c index c887fe25e2..9b1dddb3a8 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_qsl.c @@ -30,10 +30,7 @@ struct qsl_nthw *qsl_nthw_new(void) void qsl_nthw_delete(struct qsl_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int qsl_nthw_init(struct qsl_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c index e69a1ca823..3b7380b52f 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_rpp_lr.c @@ -29,10 +29,7 @@ struct rpp_lr_nthw *rpp_lr_nthw_new(void) void rpp_lr_nthw_delete(struct rpp_lr_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int rpp_lr_nthw_init(struct rpp_lr_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c index e062a700eb..9083455051 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_slc_lr.c @@ -30,10 +30,7 @@ struct slc_lr_nthw *slc_lr_nthw_new(void) void slc_lr_nthw_delete(struct slc_lr_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int slc_lr_nthw_init(struct slc_lr_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c index ee85a1c61b..c0e26f9186 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_cpy.c @@ -31,7 +31,6 @@ void tx_cpy_nthw_delete(struct tx_cpy_nthw *p) { if (p) { free(p->m_writers); - (void)memset(p, 0, sizeof(*p)); free(p); } } diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c index 47af44945f..40581c51ca 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_ins.c @@ -29,10 +29,7 @@ struct tx_ins_nthw *tx_ins_nthw_new(void) void tx_ins_nthw_delete(struct tx_ins_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int tx_ins_nthw_init(struct tx_ins_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c index c40857db0f..3786089326 100644 --- a/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c +++ b/drivers/net/ntnic/nthw/flow_filter/flow_nthw_tx_rpl.c @@ -29,10 +29,7 @@ struct tx_rpl_nthw *tx_rpl_nthw_new(void) void tx_rpl_nthw_delete(struct tx_rpl_nthw *p) { - if (p) { - (void)memset(p, 0, sizeof(*p)); - free(p); - } + free(p); } int tx_rpl_nthw_init(struct tx_rpl_nthw *p, nthw_fpga_t *p_fpga, int n_instance) diff --git a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c index 9eaaeb550d..0fb525d34f 100644 --- a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c +++ b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c @@ -183,7 +183,6 @@ nthw_fpga_mgr_t *nthw_fpga_mgr_new(void) void nthw_fpga_mgr_delete(nthw_fpga_mgr_t *p) { - memset(p, 0, sizeof(nthw_fpga_mgr_t)); free(p); } From patchwork Thu Feb 13 22:16:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151489 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B1C484621D; Thu, 13 Feb 2025 23:19:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 40D5240A70; Thu, 13 Feb 2025 23:18:49 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id 2F705406B7 for ; Thu, 13 Feb 2025 23:18:46 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2fa2eb7eb45so4147181a91.1 for ; Thu, 13 Feb 2025 14:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739485125; x=1740089925; 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=4njUr5dkOHDc4bLiHbc9hRxitSjOZs14bwKzJu4y3NM=; b=pbZ2FECuBL8ztZkcczs1288nj6wJBVVOYUQ9rm2ghq+2Iv5TNG5P3CzMgCV/fhXuTR e5qs2VrwcZhgfTWriltIf5CqM1OWe/BXWtuE487Qr/2rrFnRsdXh0aL0gWWl5e5wT1Ty SOju0nlZjoqrooobBLYY6gWaFPdbN7+lQFQn32o05pgYywTYQ8+Sqkxk4PvrgBA4pFBL B48/uMcv9UsEDcPP23z2u82eIQdfvIfDKkhesu2Gwg1RDKIFhz550TWR1wmEubi2LgaN 0Ruu2zJPqBPnh5ijckfcLGtOkiBTV8Cp0v3wbAcxBLwo1o5ha+OJV6SD2sc5khSG2IbA bILw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739485125; x=1740089925; 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=4njUr5dkOHDc4bLiHbc9hRxitSjOZs14bwKzJu4y3NM=; b=reDTFfWjw7x5wh+aitV2AQ6v/cFulNlOVmLJGY0THkm8y65IBTGctUdVQ29vLIN+ha KpztnAbBK4vCRGFkBH/LQmc+ezfhIwJL2VenyWqvqfg6GINxH0cirQumc80cJT6F9yEu SjrD8i6PT1os/FC7Dd119icULHEF5D09PR7YSSV8MAHgr4ISFquM4bJH5g6LjQc7IVE7 zYmyL42R6sDjn43trYfBGUxck36qbke47d4Juw49yvbAoyBRR5pUGvBXX4uF6wGDURMR Z2fIQRPehyd7q6RBpgEtDVp9zxHN6H0WHQA1zz0AvCvhRgCVJuAdTSljo79TVHI/xfuy sofA== X-Gm-Message-State: AOJu0Yxt7oxJEI9+kTohXR5SEKV5wMV/0Fkl6+d/fL1pj3TZZoTT2oG1 as2otVjsfCv2OG0SxYuHyB7O9g462XwmnAT2l/Pm6iJIS+nvT7JirB/k4dkChEE8gvIxogClkYL O X-Gm-Gg: ASbGnctk8s9umh4k3PuVcCl/m6scHW3KlpgZXXJZ03rh/jHIioPnr7Ml6RvYeslELrE SDdAUGwpOQdC6041vONubhZFntTTIVrayU3Xpresb7e2MjJXqbw7iw1pqNIb63Nd4EjBm4R/iEn evlYWWkBVdJ+uGBn1W3RIyuNM1M0zY4UPNLvRCHm+Luj91m3PWv8aZiQF2aiElgfzMrq5ItLowF HSLN0eEpj99w14X60Km+bTxQizkU3E3wJtoL+eFCnRUcqJy7vyWNCEES11AfcxFPujCcM3dU7F0 8f/p9OKFyflD7kRJ8InxtUbxYoTajBPqn21mgMWAI1Je9tB8pbgwX5lNw1fo+e7VR+0U X-Google-Smtp-Source: AGHT+IF46HT0dlaUJs7+praPZpZC47H0lQvR3RaoB+I8cdL9BTzguWRcqJyMGoAODouDRjwA4eBSlw== X-Received: by 2002:a17:90b:1b0b:b0:2fa:1c09:3cee with SMTP id 98e67ed59e1d1-2fc0f9827d4mr7063572a91.9.1739485125361; Thu, 13 Feb 2025 14:18:45 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad726bsm1706826a91.28.2025.02.13.14.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 14:18:45 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 11/11] devtools/cocci: add script to find problematic memset Date: Thu, 13 Feb 2025 14:16:24 -0800 Message-ID: <20250213221819.1856769-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213221819.1856769-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20250213221819.1856769-1-stephen@networkplumber.org> MIME-Version: 1.0 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 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 --git a/devtools/cocci/memset_free.cocci b/devtools/cocci/memset_free.cocci new file mode 100644 index 0000000000..96334dc8c0 --- /dev/null +++ b/devtools/cocci/memset_free.cocci @@ -0,0 +1,9 @@ +// Replace calls to memset before free +@@ +expression E, size; +@@ +( +- memset(E, 0, size); +- rte_free(E); ++ rte_free_sensitive(E); +)