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 46D7645D07; Thu, 14 Nov 2024 19:45:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2244542EE5; Thu, 14 Nov 2024 19:45:09 +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 697DB42ED9 for ; Thu, 14 Nov 2024 19:45:05 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2e5a0177531so812170a91.2 for ; Thu, 14 Nov 2024 10:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731609904; x=1732214704; 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=+Wuq9V4cp+EoDaaGzIl6Sd8R2GRAR8DBx5q0sQFIxkw=; b=Mjiu1sIU1Ftc29Hl5WqKi1RQKaoUMQmPujU8d166Sx+/acWRgl9Es1o7vl5omD/CH/ UFBIbSZttODtiAtpt/B77BkTMMbTEUMoge34TT9Z2t4AmGa6WypTnpzfxMAs6Yzg4z4D aP8yqQqWZPrXrnPSAuSVru3234G8OdWZ8YUHaacpC0VmE05S/YvSpmNXi/5NreY7jaV8 3s84z5W1osVFJiD8lEGPAyTnq7aO3NGpIzYs5dorhdo/8i3kIQt/B0pL4OgefNP434ud SgnrvGlOiW/AYv7lKsYFwQer6FJ+r61wKGTSArrJEJhlQKG8x0g1GqUBNJ2ErksBGsly Fviw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731609904; x=1732214704; 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=+Wuq9V4cp+EoDaaGzIl6Sd8R2GRAR8DBx5q0sQFIxkw=; b=RpHd4P9q5ON1lvu6XQsGyaaf+hGM4H+bREKsopV3r7p1ZHU/FloALCGY4vdCk7o+u9 bTfKGDk8li7Yvh6KRtdlVgv/on3CbZSdlkopTkgG6TRW7Q1eto8xBs0i48//zlCwlhiE 0O61FgIBQl+xWLd2R5mL3WeAVE38fAesTwyyvxRcRvBWFadEHcckfoDfRH2W1MboXR2v Xdc2KkQnm9mhjLvhtkTiot2VNegeptfbwTo1/nikGYTLiEGIYBbTEyw6U/G6WTeD2URF 9jTKnKJW+d5BDufBmTZW4a+yjptNb3iSAt1rFdrgcxovksUSLWmTw4A+1uyBYtBU+NxN jyyw== X-Gm-Message-State: AOJu0YyjkTyU6uYYGyw5daI1I/qVKj3Bkctb5CkHzN9U8DWKl61H7mPH e8H6Ilf5HgRZF/ykKfNZ1WOheBgee30dGdSkMbCRx34qjToGvGpPhb9RGeK35yDWoZec/DDNoTt EiAc= X-Google-Smtp-Source: AGHT+IE3NIPBDbxjv41Iwi7F2oV86GEqO28KWcoYU6Lt/HupyX/UychMXV/oXn18rZEc+sJC5eeqpQ== X-Received: by 2002:a17:90b:4f43:b0:2e2:e82d:48cf with SMTP id 98e67ed59e1d1-2e9b1724271mr35254695a91.16.1731609904558; Thu, 14 Nov 2024 10:45:04 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea06ef71a6sm1517611a91.8.2024.11.14.10.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 10:45:04 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Kai Ji Subject: [PATCH v4 03/12] crypto/qat: force zero of keys Date: Thu, 14 Nov 2024 10:43:25 -0800 Message-ID: <20241114184452.31854-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114184452.31854-1-stephen@networkplumber.org> References: <20241114011129.451243-1-stephen@networkplumber.org> <20241114184452.31854-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 Acked-by: Bruce Richardson --- 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