Re: [PATCH 4/5] smb: client: Clear sensitive stack data in smb1encrypt.c
Namjae Jeon <[email protected]>
| Newsgroups | org.kernel.vger.linux-cifs,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAKYAXd8SbS9W1UniQF9xgMyOf5azGfkZ8QyE31xkSLu-bjoxcA@mail.gmail.com> |
On Tue, Aug 18, 2026 at 3:33 PM Thomas Huth <[email protected]> wrote: > > On 18/08/2026 07.58, Namjae Jeon wrote: > > On Wed, Aug 12, 2026 at 10:13 PM Thomas Huth <[email protected]> wrote: > >> > >> From: Thomas Huth <[email protected]> > >> > >> 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 <[email protected]> > >> --- > >> 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); > > The MD5 context in cifs_calc_signature() may remain uncleared when > > __cifs_calc_signature() fails. > > > > rc = __cifs_calc_signature(...); > > ┃ > > memzero_explicit(&ctx, sizeof(ctx)); > My plan was to handle that via a __cleanup() function, too, but I need to > get that merged first: > > https://lore.kernel.org/lkml/[email protected]/ Okay. Thanks.