Skip to content

Commit

Permalink
cifs: use memzero_explicit to clear stack buffer
Browse files Browse the repository at this point in the history
When leaving a function use memzero_explicit instead of memset(0) to
clear stack allocated buffers. memset(0) may be optimized away.

This particular buffer is highly likely to contain sensitive data which
we shouldn't leak (it's named 'passwd' after all).

Signed-off-by: Giel van Schijndel <me@mortis.eu>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Reported-at: http://www.viva64.com/en/b/0299/
Reported-by: Andrey Karpov
Reported-by: Svyatoslav Razmyslov
Signed-off-by: Steve French <steve.french@primarydata.com>
  • Loading branch information
Giel van Schijndel authored and Steve French committed Jan 19, 2015
1 parent ec6f34e commit f99dbfa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/cifs/smbencrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16,
}

rc = mdfour(p16, (unsigned char *) wpwd, len * sizeof(__le16));
memset(wpwd, 0, 129 * sizeof(__le16));
memzero_explicit(wpwd, sizeof(wpwd));

return rc;
}
Expand Down

0 comments on commit f99dbfa

Please sign in to comment.