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 970B545CFC; Thu, 14 Nov 2024 02:11:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B864942791; Thu, 14 Nov 2024 02:11:44 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id BA32B40A79 for ; Thu, 14 Nov 2024 02:11:42 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7eab7622b61so19442a12.1 for ; Wed, 13 Nov 2024 17:11:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731546702; x=1732151502; 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=DzXVy88sJeZb3BwLNcqIIUoOMm7Q0AJthIDMDxWB1+URgWV7CgLOu9Awqm0dVqtcKC plWCFqyIxUsanWbjjzoWuyfJ7MLwQsD8UzGiR54b6bLGHDpqJjhPx5FvrH1KsgRSDqRQ NQwjbKASb35kvUNdZwZ1kqqbf/oSd65o4jg1fL3bYIVRGpnyyG/X/Rf+Curv0WeCc1op RprhOXTomHQjQ03f30V6MJxXRG3N+G9c6TvvAnRWbZJmbW63H1/PaF1Y0O4R9zoMsuxn 4pN5ltxv5oW3N+z0CV/hz/Y3WjLy1ogoje4D7fs6AQxSHqsL70RUtZ51FnDNRqbBKaBL kmdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731546702; x=1732151502; 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=gzBVY5Bw/fe3Kcj97CjteYTRZZC2OixSBqxI/tTrTyq/VUmmTdrV3OPc25ywWzV8DS vX1U2h+0bZfPOfSpPcupqUN5RsMmhbKujX8/ioM0E6QUXTmgge+r6NQSeyU3LpiSUZnA 3T1UYi2zWEt+wolgYTAa2fHTITCPl+o1YhXgnHYhYDzc6gbBaZl/c8TQx9Blt/b0tX+4 GDp4R0MwVUf1Lj5HNS+rTGMrlwOOaxv5pRXnN9crxR4D2xy6PHR+1A3h07Jwuak6Zl1e hcCMy9Q+Vk2czRPGkkemMk6iHRWHE8r3ENwYI2tGK6rAUgI2trKujFqeUPpP6GOZYnSY 2Aww== X-Gm-Message-State: AOJu0YzSpDml+1ds82irNz5QExm9RNR/1+Sk71p/zBKujtpFqvbU4Eg3 1OPUELV9LZUkScKm0yLTyzauReK/AV8Lg5S9xPkue59QxP/d8Ca9o5+2Tlww+PiTzJ9o5buA9Ce a X-Google-Smtp-Source: AGHT+IFyWM8R/cXbc9MQqKGnBVKMgIJSHBh5GE5DRlk4jidF21MAUEHQUJF/TWeAq6zPa/HdFid3Wg== X-Received: by 2002:a05:6a20:748b:b0:1d9:c78f:4207 with SMTP id adf61e73a8af0-1dc2292c2a4mr30794924637.11.1731546701977; Wed, 13 Nov 2024 17:11:41 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7246a9a8102sm60950b3a.125.2024.11.13.17.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 17:11:41 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Kai Ji Subject: [PATCH 2/3] crypto/qat: use rte_memset_sensative Date: Wed, 13 Nov 2024 17:10:17 -0800 Message-ID: <20241114011129.451243-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114011129.451243-1-stephen@networkplumber.org> References: <20241114011129.451243-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