Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp129976lqn; Thu, 11 Apr 2024 16:52:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNmIOv446GLJsdR5TKGktJDc8r1lV3QegCRIr3FDAlp7mhRDLt90IqZnb8MyasyvdzTMV2K6YUpdHOZlt6Qt3JG7dYq0jqqG9fWL1mwQ== X-Google-Smtp-Source: AGHT+IG95y1cLbiAe/1PTAqj2+J9AK5ImhNZp5tCrkdiZ9vmDqyQl0RVDu2GvFScwcvKOKzr2Rj8 X-Received: by 2002:a05:620a:4589:b0:78d:73bc:36ea with SMTP id bp9-20020a05620a458900b0078d73bc36eamr1639507qkb.50.1712879568851; Thu, 11 Apr 2024 16:52:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712879568; cv=pass; d=google.com; s=arc-20160816; b=JbOKIlbWJBkpciSpk5Le5xmcll1D1b36doIL8jrkGNDaZ6XgIOjlGrqtAuArUpQoy9 Jgb2kgg46dPvSBQGHGUZ9Zk5HM0NG2G+yNtSnrJTDETt65nsU48t0rjJm4elPyZJKCBt EE9+9UyMKcCVe8gAUSTOMegogmI+bv5hJOE1CvyHfJLEyjTri4tTqyfcyiEcw1FN4mqW 1J56UiJQ5B0HrCeKWp7WAHvXMQrtPa6joKXrczjvOriJtQcpYjrbhqEpooS25ObOedId Vv2gVIQiICqcCUsEvqLCjgFzfK8XClYS4jzlh8ZMLCGGuOrMrOPCRnJ/UebNIMsCuBRS 58qQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mtc9r2f7czZp3fCdnpNtJVrBS0On253euj+fC9lQLNA=; fh=Kluj/MylNIXEG5rJpxtpN4YJevqV8u2hV1nVSqkCTUM=; b=IAA6m+FcpKoBnCrzUBomRYCShIbq/lUcAE76koQUhzZ1qc1usKMhYvmsFy8mS5OpYj jv+yN2+RzJjAJjzYy07ArwaJp5Y/1U4Yq0fathAYW6bbCMYYHSAVcCdPY+6u5Z4p2zxF ZPycrP/yKFhh46HlinPuZHGc3RMdwJWunG2gHBDRC4kcNyhuhPXNGshaP3uj8ccWsnYp 27i+jGuis39qsBZLXQQcBkSegPk5758XV4QqCmz0QkgPOjtS66LrkiTyKDn8YiD9wUzo 3TZGWFodABKkK16WaGAfCTprgbl4GJrwzKQbHoFMHclzGohNPuMyEZXGeUuSMjA4LOtX zuTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="MbC/XBCL"; arc=pass (i=1 spf=pass spfdomain=amazon.com dkim=pass dkdomain=amazon.com dmarc=pass fromdomain=amazon.com); spf=pass (google.com: domain of linux-crypto+bounces-3486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v9-20020a05620a0a8900b0078d5f69597asi2550904qkg.187.2024.04.11.16.52.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 16:52:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="MbC/XBCL"; arc=pass (i=1 spf=pass spfdomain=amazon.com dkim=pass dkdomain=amazon.com dmarc=pass fromdomain=amazon.com); spf=pass (google.com: domain of linux-crypto+bounces-3486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 92C281C212FE for ; Thu, 11 Apr 2024 23:52:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5509C4C624; Thu, 11 Apr 2024 23:52:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="MbC/XBCL" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp-fw-52002.amazon.com (smtp-fw-52002.amazon.com [52.119.213.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E510487BE; Thu, 11 Apr 2024 23:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.119.213.150 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712879560; cv=none; b=bO6sYfink+WXFBWao/4xf8Jthq2eH9MC0NDD3PcwfNH3yhZARu8UgBiPlifxnFMLc/YuJ3oWsGALcen6mnOA0KJkBB6RBaeVdyC7bSY54U3xlsaLOwoYUFHTqnyKr8XwDoio73V5qLCygx4udpqWnH7U6uqrzGtfQKRH5CnsIJk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712879560; c=relaxed/simple; bh=igqiBoT9oOC7/5UOi4xVEVveH1WybSGI8pA91Wn0hto=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D1N8p59nS7ynh3x29GcuGoCeIpzwheftHm4bl5ye0/KYe5i5wAgqVQLuUSFb9auSWXa+fHNtPHbmJi/5oTO/vXeTW8OYhD6yIKXeVo7M1/aWJPV5EO+e8QPSB5rZCSfTXWllLWFSK7TuddBFHgBslxYK1VVgqaUkF8hLzpAbdQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=MbC/XBCL; arc=none smtp.client-ip=52.119.213.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1712879559; x=1744415559; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mtc9r2f7czZp3fCdnpNtJVrBS0On253euj+fC9lQLNA=; b=MbC/XBCLGsiwi+EonyHnHTS+O/kOafCs+ott5pYEGmh/tjufe2hetAOU mcpYJ4Q5H2MYWS34L4kMGyhlv45DMqtPHawkxJ0P5yHZ2lWzzJbuGFl0B INBIXPkIERGVgQtIlHYNC/G5UdSZhWePLsAGJDJ/RDJ28QCkf7g7zwb4P 0=; X-IronPort-AV: E=Sophos;i="6.07,194,1708387200"; d="scan'208";a="625962786" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-52002.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 23:52:38 +0000 Received: from EX19MTAUWA001.ant.amazon.com [10.0.21.151:21716] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.6.244:2525] with esmtp (Farcaster) id 54fd211d-c7f9-4311-8906-0b68a417a83a; Thu, 11 Apr 2024 23:52:36 +0000 (UTC) X-Farcaster-Flow-ID: 54fd211d-c7f9-4311-8906-0b68a417a83a Received: from EX19D046UWA001.ant.amazon.com (10.13.139.112) by EX19MTAUWA001.ant.amazon.com (10.250.64.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Thu, 11 Apr 2024 23:52:33 +0000 Received: from EX19MTAUWC001.ant.amazon.com (10.250.64.145) by EX19D046UWA001.ant.amazon.com (10.13.139.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Thu, 11 Apr 2024 23:52:33 +0000 Received: from dev-dsk-hailmo-2b-4e49cd2f.us-west-2.amazon.com (172.16.42.153) by mail-relay.amazon.com (10.250.64.145) with Microsoft SMTP Server id 15.2.1258.28 via Frontend Transport; Thu, 11 Apr 2024 23:52:33 +0000 Received: by dev-dsk-hailmo-2b-4e49cd2f.us-west-2.amazon.com (Postfix, from userid 13307802) id AD61941829; Thu, 11 Apr 2024 23:52:33 +0000 (UTC) From: Hailey Mothershead To: CC: , , , Subject: [PATCH 2/2] crypto: aead,cipher - zeroize key buffer after use Date: Thu, 11 Apr 2024 23:51:57 +0000 Message-ID: <20240411235157.19801-2-hailmo@amazon.com> In-Reply-To: <20240411235157.19801-1-hailmo@amazon.com> References: <20240411235157.19801-1-hailmo@amazon.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain I.G 9.7.B for FIPS 140-3 specifies that variables temporarily holding cryptographic information should be zeroized once they are no longer needed. Accomplish this by using kfree_sensitive for buffers that previously held the private key. Signed-off-by: Hailey Mothershead --- crypto/aead.c | 2 +- crypto/cipher.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/aead.c b/crypto/aead.c index 16991095270d..2592d5375de5 100644 --- a/crypto/aead.c +++ b/crypto/aead.c @@ -36,7 +36,7 @@ static int setkey_unaligned(struct crypto_aead *tfm, const u8 *key, memcpy(alignbuffer, key, keylen); ret = crypto_aead_alg(tfm)->setkey(tfm, alignbuffer, keylen); memset(alignbuffer, 0, keylen); - kfree(buffer); + kfree_sensitive(buffer); return ret; } diff --git a/crypto/cipher.c b/crypto/cipher.c index b47141ed4a9f..efb87fa417e7 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -35,7 +35,7 @@ static int setkey_unaligned(struct crypto_cipher *tfm, const u8 *key, memcpy(alignbuffer, key, keylen); ret = cia->cia_setkey(crypto_cipher_tfm(tfm), alignbuffer, keylen); memset(alignbuffer, 0, keylen); - kfree(buffer); + kfree_sensitive(buffer); return ret; } -- 2.40.1