From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 B0257476CC2 for ; Fri, 7 Aug 2026 12:59:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786107557; cv=none; b=LKZMSkGVLD2XYLD4IFlyTccZ8vH7D0cqwlm/8vtpDkfy7Coyg4T9dn59XBNt9bj/Q6KDckefm9P1rHIW5dK47F4TCQTQmJ8v6272kUlBayHG3HiQK+HVjmZ8IjjRXetz8G1A/Cfq53sYszQV3q41OqD2nkxRvGHQ+BNTrQoqyCc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786107557; c=relaxed/simple; bh=HY1fXOCc++pdACbCDsnbvo4DN0eMrHtPCYGnQ2C1K8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NVopg7rd6ESX1Bv9AJMIV1rMb8fp8Cqz5KI0Gh1ZeBZWwFGR9RX9JxsERd3hntqS1Q27NY1jeR9QaTwtDqHcFoP0fa3C4S8f2KLCtTfD++Ub6SRVDSZs0NCSrckhH0VZoB2QoBk1jeDmn5ty17F4XkshalWH1qob3oG7YS6cuOk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZesdjCg7; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZesdjCg7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786107545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EnK55USt5eYX4DKAb2D0n3Ly2M5DO0VV1eu2CGhl9ns=; b=ZesdjCg77ldIeWAflY7dZDpIB/yW/EoYqXG8oaL2pTIIvcq6JIcgh3bwwVH0o+XsMxs9PV OYi9rrObCsDwtHiSxRAq9S6ASk3kTTYxd4jjnOi1VknhuNXOdnmmWvONhgb/WyzzEDMiIG ZTiYtMxYh6YvHx/PG5bBJLg7Szx+O8E= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-357-sZsFBmd1O1Kh-2j3jyt2wg-1; Fri, 07 Aug 2026 08:59:02 -0400 X-MC-Unique: sZsFBmd1O1Kh-2j3jyt2wg-1 X-Mimecast-MFC-AGG-ID: sZsFBmd1O1Kh-2j3jyt2wg_1786107539 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 936481954B1B; Fri, 7 Aug 2026 12:58:58 +0000 (UTC) Received: from thuth-p1g4.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A88BB3000239; Fri, 7 Aug 2026 12:58:53 +0000 (UTC) From: Thomas Huth To: Eric Biggers , Steve French , Namjae Jeon Cc: Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , Sergey Senozhatsky , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH v2 2/6] smb: clear the aes_cmac_key and aes_cmac_ctx when done Date: Fri, 7 Aug 2026 14:58:39 +0200 Message-ID: <20260807125845.1477067-3-thuth@redhat.com> In-Reply-To: <20260807125845.1477067-1-thuth@redhat.com> References: <20260807125845.1477067-1-thuth@redhat.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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 From: Thomas Huth Clear the local crypto-related structures via __cleanup() functions when we're done with them to avoid that sensitive data could leak on the stack. Note: cmac_ctx in ksmbd_sign_smb3_pdu() gets cleared in aes_cmac_final() already, so this does not need a __cleanup() marker. Signed-off-by: Thomas Huth --- fs/smb/client/smb2transport.c | 4 ++-- fs/smb/server/auth.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c index 1143ee52470a7..d23566da2ac81 100644 --- a/fs/smb/client/smb2transport.c +++ b/fs/smb/client/smb2transport.c @@ -464,8 +464,8 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) unsigned char smb3_signature[SMB2_CMACAES_SIZE]; struct kvec *iov = rqst->rq_iov; struct smb2_hdr *shdr = (struct smb2_hdr *)iov[0].iov_base; - struct aes_cmac_key cmac_key; - struct aes_cmac_ctx cmac_ctx; + struct aes_cmac_key cmac_key __cleanup(aes_cmac_zeroize_key); + struct aes_cmac_ctx cmac_ctx __cleanup(aes_cmac_zeroize_ctx); struct smb_rqst drqst; u8 key[SMB3_SIGN_KEY_SIZE]; diff --git a/fs/smb/server/auth.c b/fs/smb/server/auth.c index 4e7b6f0e6b8cd..e8d1c068a43e8 100644 --- a/fs/smb/server/auth.c +++ b/fs/smb/server/auth.c @@ -509,7 +509,7 @@ void ksmbd_sign_smb2_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, void ksmbd_sign_smb3_pdu(struct ksmbd_conn *conn, char *key, struct kvec *iov, int n_vec, char *sig) { - struct aes_cmac_key cmac_key; + struct aes_cmac_key cmac_key __cleanup(aes_cmac_zeroize_key); struct aes_cmac_ctx cmac_ctx; int i; -- 2.55.0