From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B0D3C7EE29 for ; Thu, 25 May 2023 18:47:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242830AbjEYSrd (ORCPT ); Thu, 25 May 2023 14:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242643AbjEYSo6 (ORCPT ); Thu, 25 May 2023 14:44:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B6F6270E; Thu, 25 May 2023 11:41:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9236660F1A; Thu, 25 May 2023 18:40:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC1FBC433EF; Thu, 25 May 2023 18:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685040019; bh=UIgfD+CJU2peIF3JGv8Dm1hCT7GtVyCODo4EZkcaUMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqnH6nq6332FouwObYbndphqs1Br79qU0QJoTPgdiO2krvCHC52NrXYW7DrG/XcqI 9/AOhM5VS0EK8PuqILMKNjavKZ8L05azFkYG71t0ChOQvacXmygU8PZTpUskBkDss0 hXfa7YJYJunQpWMClj/RkAeXg3ouwfbSIA+xts1kD/15o12Xy+t12H7Fld8EXhdPS9 BpvrelQFISBNUQVKzFmY8e/c0PcUv33VPt07PYjg0zZQBMyso3LE08WQDLFjpNguPO S78C/aTporaIkbyFrwpfLQ6Meqkc5OaEoG2qjPUfKUCoKPQ2JVCEzHdW8EPbivwIfR TBpF150rdxiUw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Holger Dengler , Harald Freudenberger , Alexander Gordeev , Sasha Levin , hca@linux.ibm.com, gor@linux.ibm.com, linux-s390@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 25/43] s390/pkey: zeroize key blobs Date: Thu, 25 May 2023 14:38:36 -0400 Message-Id: <20230525183854.1855431-25-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230525183854.1855431-1-sashal@kernel.org> References: <20230525183854.1855431-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Holger Dengler [ Upstream commit 844cf829e5f33e00b279230470c8c93b58b8c16f ] Key blobs for the IOCTLs PKEY_KBLOB2PROTK[23] may contain clear key material. Zeroize the copies of these keys in kernel memory after creating the protected key. Reviewed-by: Harald Freudenberger Signed-off-by: Holger Dengler Signed-off-by: Alexander Gordeev Signed-off-by: Sasha Levin --- drivers/s390/crypto/pkey_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c index cf23ce1b11465..83b335f962c89 100644 --- a/drivers/s390/crypto/pkey_api.c +++ b/drivers/s390/crypto/pkey_api.c @@ -1286,6 +1286,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, return PTR_ERR(kkey); rc = pkey_keyblob2pkey(kkey, ktp.keylen, &ktp.protkey); DEBUG_DBG("%s pkey_keyblob2pkey()=%d\n", __func__, rc); + memzero_explicit(kkey, ktp.keylen); kfree(kkey); if (rc) break; @@ -1419,6 +1420,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, kkey, ktp.keylen, &ktp.protkey); DEBUG_DBG("%s pkey_keyblob2pkey2()=%d\n", __func__, rc); kfree(apqns); + memzero_explicit(kkey, ktp.keylen); kfree(kkey); if (rc) break; @@ -1545,6 +1547,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, protkey, &protkeylen); DEBUG_DBG("%s pkey_keyblob2pkey3()=%d\n", __func__, rc); kfree(apqns); + memzero_explicit(kkey, ktp.keylen); kfree(kkey); if (rc) { kfree(protkey); -- 2.39.2