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 4/5] smb: client: Clear sensitive stack data in smb1encrypt.c
Date: Wed, 12 Aug 2026 15:01:51 +0200 [thread overview]
Message-ID: <20260812130152.2861834-5-thuth@redhat.com> (raw)
In-Reply-To: <20260812130152.2861834-1-thuth@redhat.com>
From: Thomas Huth <thuth@redhat.com>
Make sure to not leak signature data via the stack, clear it
with memzero_explicit() before leaving the function.
To avoid that we have to introduce "goto"-cleanup here, we re-arrange
the code a little bit (and drop the commented cifs_dump_mem debug
code that looks like a leftover from very early days).
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
fs/smb/client/smb1encrypt.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/fs/smb/client/smb1encrypt.c b/fs/smb/client/smb1encrypt.c
index bf10fdeeedcab..c9eb68f04e7b0 100644
--- a/fs/smb/client/smb1encrypt.c
+++ b/fs/smb/client/smb1encrypt.c
@@ -81,6 +81,7 @@ int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
else
memcpy(cifs_pdu->Signature.SecuritySignature, smb_signature, 8);
+ memzero_explicit(smb_signature, sizeof(smb_signature));
return rc;
}
@@ -126,15 +127,13 @@ int cifs_verify_signature(struct smb_rqst *rqst,
rc = cifs_calc_signature(rqst, server, what_we_think_sig_should_be);
cifs_server_unlock(server);
- if (rc)
- return rc;
-
-/* cifs_dump_mem("what we think it should be: ",
- what_we_think_sig_should_be, 16); */
-
- if (crypto_memneq(server_response_sig, what_we_think_sig_should_be, 8))
- return -EACCES;
- else
- return 0;
+ if (!rc) {
+ if (crypto_memneq(server_response_sig,
+ what_we_think_sig_should_be, 8))
+ rc = -EACCES;
+ }
+ memzero_explicit(what_we_think_sig_should_be,
+ sizeof(what_we_think_sig_should_be));
+ return rc;
}
--
2.55.0
next prev parent reply other threads:[~2026-08-12 13:02 UTC|newest]
Thread overview: 12+ 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 ` [PATCH 1/5] smb: client: Clear sensitive stack data in smb2transport.c Thomas Huth
2026-08-18 5:47 ` Namjae Jeon
2026-08-18 6:27 ` Thomas Huth
2026-08-18 7:48 ` Namjae Jeon
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 ` Thomas Huth [this message]
2026-08-18 5:58 ` [PATCH 4/5] smb: client: Clear sensitive stack data in smb1encrypt.c Namjae Jeon
2026-08-18 6:33 ` Thomas Huth
2026-08-18 7:47 ` Namjae Jeon
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-5-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
all inboxes | Powered by JetHome®