From: Thomas Huth <thuth@redhat.com>
To: Steve French <sfrench@samba.org>
Cc: Paulo Alcantara <pc@manguebit.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] smb: client: Clear sensitive stack data in smb2transport.c
Date: Wed, 12 Aug 2026 15:01:48 +0200 [thread overview]
Message-ID: <20260812130152.2861834-2-thuth@redhat.com> (raw)
In-Reply-To: <20260812130152.2861834-1-thuth@redhat.com>
From: Thomas Huth <thuth@redhat.com>
Sensitive data like keys that are stored in stack-local arrays could
be leaked via the stack to the calling functions. There is no known
vulnerability for this right now, but it's good security style to
explicitly zeroize this sensitive material as soon as possible to
avoid that it could be exploited together with other bugs later.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
fs/smb/client/smb2transport.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c
index 1143ee52470a7..fdc634d99da03 100644
--- a/fs/smb/client/smb2transport.c
+++ b/fs/smb/client/smb2transport.c
@@ -249,6 +249,8 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
if (!rc)
memcpy(shdr->Signature, smb2_signature, SMB2_SIGNATURE_SIZE);
+ memzero_explicit(key, sizeof(key));
+ memzero_explicit(&hmac_ctx, sizeof(hmac_ctx));
return rc;
}
@@ -283,6 +285,7 @@ static void generate_key(struct cifs_ses *ses, struct kvec label,
hmac_sha256_final(&hmac_ctx, prfhash);
memcpy(key, prfhash, key_size);
+ memzero_explicit(prfhash, sizeof(prfhash));
}
struct derivation {
@@ -482,6 +485,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
memset(shdr->Signature, 0x0, SMB2_SIGNATURE_SIZE);
rc = aes_cmac_preparekey(&cmac_key, key, SMB2_CMACAES_SIZE);
+ memzero_explicit(key, sizeof(key));
if (rc) {
cifs_server_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
return rc;
--
2.55.0
next prev parent reply other threads:[~2026-08-12 13:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 13:01 [PATCH 0/5] smb: client: Avoid leaking of sensitive data to the stack or heap Thomas Huth
2026-08-12 13:01 ` Thomas Huth [this message]
2026-08-12 13:01 ` [PATCH 2/5] smb: client: Clear sensitive stack and heap data in smb2ops.c Thomas Huth
2026-08-12 13:01 ` [PATCH 3/5] smb: client: Clear sensitive stack data in cifsencrypt.c Thomas Huth
2026-08-12 13:01 ` [PATCH 4/5] smb: client: Clear sensitive stack data in smb1encrypt.c Thomas Huth
2026-08-12 13:01 ` [PATCH 5/5] smb: client: Avoid leaking sensitive data to the heap in connect.c Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260812130152.2861834-2-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=bharathsm@microsoft.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox