From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6D09945CFC; Thu, 14 Nov 2024 02:54:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 800FE427BB; Thu, 14 Nov 2024 02:54:22 +0100 (CET) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mails.dpdk.org (Postfix) with ESMTP id 017BC427A3 for ; Thu, 14 Nov 2024 02:54:19 +0100 (CET) Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2e9ecba5db0so101656a91.2 for ; Wed, 13 Nov 2024 17:54:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731549258; x=1732154058; 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=wKwTNgZd+/1/oit68tEd7YQShCTluw2kbaCttTfy3hU=; b=jpiU5PKspcgSPkbZjvXzEH2sViZ2JmOFywdXhRM4JO9ied0MNx4cd7YocaDb5uadiV JP/AKV5/AxFZD8/JwWRushVoJXpGE+PRxVJldiuvSBfGcSB2u11e4k+rQpbm//W76kqZ 4JcYX/NAJBMEtBDDULeqPQ2iq9GknXG6WSFncK9Y0nG2jAp9qBYvf8nGgMVK+gcibj3y MQHKJwiTIgc2bKPbkACxmYzEOfyMY5Ygz3Pf6JL6c+Ibn7y+Y6bkXO633FFZq22/sjRO MxQw4QAYZU5iBPZHB0GyMfCxJHW513y/D16dNsyLV0cCdLPEQnpshSrFPH2Qex+z/wpK stmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731549258; x=1732154058; 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=wKwTNgZd+/1/oit68tEd7YQShCTluw2kbaCttTfy3hU=; b=pP9xW69CbVtTV5zJOUz+W4bZClx+yF+SoFNJgxlnziZo/TJ7xvo5/Tnr2cmyvnNfIt obYhvfklPIyUr6Sld9DBLujREgova/iswmfpbMv8oAKwKUIa8p2owdfqh7wfTFB7vq/S cTMhqUlfd2HqLtxsUf5ZapiuU+BBnAaeyf4HGKLgYJSFF7GbUC0l38whDnLPkm7oSavq Sp01bZ3Lkcpsl+kEbKLJcnKngtBMvhtlgWiELxIU9zDju0z+IVoD6vBDKOT1TVxaN3V9 uumqPmZyQYPr9MxjV4l6vkLCqSDs+mR0msXEdkhMgVxeTDwYSvU9VfmvbHm8fsmPVKVa DMkA== X-Gm-Message-State: AOJu0YwO4avStnhsFheb/VzMFg5C5ydGT3ArLEVDPD4ZbrsABxNA1bws ixylHhcNWLnkOff4US8NGbICS8oHc+ybsd2+qz6jUu9wV351OfytipClySZjXrJ6Epv8GAUDyGZ q X-Google-Smtp-Source: AGHT+IGPYZXsugrvvUJ8U0XdLS6ekdcG6jqb6pUoK0yOe7KlG40/sKc+kPH9Riiv1IgWHFgeSHzs2w== X-Received: by 2002:a17:90b:2745:b0:2e2:e6c8:36a7 with SMTP id 98e67ed59e1d1-2ea06599e58mr456515a91.31.1731549258221; Wed, 13 Nov 2024 17:54:18 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea02496eedsm210050a91.18.2024.11.13.17.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 17:54:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Kai Ji Subject: [PATCH v2 3/8] crypto/qat: force zero of keys Date: Wed, 13 Nov 2024 17:52:17 -0800 Message-ID: <20241114015405.77060-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114015405.77060-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20241114015405.77060-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Need something with a barrier. Signed-off-by: Stephen Hemminger --- drivers/crypto/qat/qat_sym_session.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index 50d687fd37..4b4e9ccbab 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" @@ -1633,7 +1634,7 @@ 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_memset_sensative(k0, 0, ICP_QAT_HW_AES_128_KEY_SZ); *p_state_len = ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ; rte_free(in); goto out; @@ -1668,7 +1669,7 @@ static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, &enc_key) != 0) { rte_free(in - (x * ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ)); - memset(out - + rte_memset_sensative(out - (x * ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ), 0, ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ); return -EFAULT; @@ -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_memset_sensative(in, 0, ICP_QAT_HW_GALOIS_H_SZ); if (AES_set_encrypt_key(auth_key, auth_keylen << 3, &enc_key) != 0) { return -EFAULT; @@ -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_memset_sensative(ipad, 0, block_size); + rte_memset_sensative(opad, 0, 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_memset_sensative(ipad, 0, block_size); + rte_memset_sensative(opad, 0, block_size); free_mb_mgr(m); return ret; } @@ -3232,7 +3233,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_memset_sensative(s, 0, qat_sym_session_get_private_size(dev)); } return 0; -- 2.45.2