smb: client: Clear sensitive stack data in smb1encrypt.c

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>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
This commit is contained in:
Thomas Huth
2026-08-12 15:01:51 +02:00
committed by Paulo Alcantara
parent 1a6bd74a27
commit 2f9af06e30

View File

@@ -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;
}