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 4465545CFC; Thu, 14 Nov 2024 03:38:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB2A7427C7; Thu, 14 Nov 2024 03:37:55 +0100 (CET) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id 31B20427A3 for ; Thu, 14 Nov 2024 03:37:52 +0100 (CET) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-720be27db74so60464b3a.1 for ; Wed, 13 Nov 2024 18:37:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731551871; x=1732156671; 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=/lZZs7KTCpweplbVrUJRNOr4Rc8GfXwVjfu7o9KdgWE=; b=bWOAwuGgduIcApt9QsiXjWg0OEIXUAwj/bTCiTXzcs97fLaY6BCmtMR6GjYyWDCETj dsAPe5YTpmNMNWG/i3784YMT43SlTTM7YsHTLsNOIAs49sSZ+lZOGP1fc4ryNvfjGecQ I1gb+k160MyXBB76IsS9wjguzU31TkcpA/QmIs0G1Yk2Z7jJqbgDhm47TlS6B80vjwfG 2Au0nc5Al4EswRB4mfHi7JVtn8/i7PPBcqz8SWRmw1MYLz3DIpg51OEXS2eBAqb5fWAV iwl7yDoO9iNlQdwFcu2EkYUcCbWB5y2Mlina6PW4ohbAutlEoGB7pXKqPQWJf/za/u35 X0Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731551871; x=1732156671; 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=/lZZs7KTCpweplbVrUJRNOr4Rc8GfXwVjfu7o9KdgWE=; b=BSoD8CYKI2eHfZNA3ZqBBuNwee/mSIaSOM4iyVcTcIwfS+uv9F6CCsGX+Umm9p9ytF YIu4o3mfCAZh2/iIktCRWFvIA9RsFiAm+Vxs2+Rw0KNot5twWlaIEO4GRJ/SWO8ZyDtE mZrUuki7RowQ2aXS6P1qPleziYQNeYsRTlapGlf9GNJHR8BGvxmP2ancXw8ha9tumOkQ JszfaOeAnbvCZl9jeNqbv8+n5a5KSlyrflbXhH26q580+orL25tDizGu7q7Wxz1h61wQ KUoV2Z2jdTeXk25FKqomA0aGGhC0BBBKdfl7mEgv2+zv5UKe8MOprw8n91/Z9KoNllnS 9bJw== X-Gm-Message-State: AOJu0Yyw229aeJdEo3/h5IcSNu0CITNgp4YsdFO3YPYuPyT+WzaRgojk EtPhjmNw49+s2NnkDutBzrWcgvO/2fYWoBdDqk6XGFEvT/kqIJq7vrXQiRCsepP4gc/0UpYkMnB j X-Google-Smtp-Source: AGHT+IHDSq03FNQdyMzZYmS7EiQtwGWq2RwavHzA9PdbH33dCaaXQG+om9oI3UeKXodkmZbTl1ZEsw== X-Received: by 2002:a05:6a00:4503:b0:720:3092:e75f with SMTP id d2e1a72fcca58-724667cf579mr3012359b3a.8.1731551871319; Wed, 13 Nov 2024 18:37:51 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7246a5d2bb5sm150976b3a.29.2024.11.13.18.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 18:37:50 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Kai Ji Subject: [PATCH v3 03/11] crypto/qat: force zero of keys Date: Wed, 13 Nov 2024 18:35:52 -0800 Message-ID: <20241114023738.141821-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114023738.141821-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20241114023738.141821-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..2fce8fcb16 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_sensitive(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_sensitive(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_sensitive(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_sensitive(ipad, 0, block_size); + rte_memset_sensitive(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_sensitive(ipad, 0, block_size); + rte_memset_sensitive(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_sensitive(s, 0, qat_sym_session_get_private_size(dev)); } return 0; -- 2.45.2