Skip to content

Commit

Permalink
sunrpc: use constant time memory comparison for mac
Browse files Browse the repository at this point in the history
Otherwise, we enable a MAC forgery via timing attack.

Signed-off-by: Jason A. Donenfeld <[email protected]>
Cc: "J. Bruce Fields" <[email protected]>
Cc: Jeff Layton <[email protected]>
Cc: Trond Myklebust <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Anna Schumaker <[email protected]>
  • Loading branch information
zx2c4 authored and amschuma-ntap committed Jul 13, 2017
1 parent 1ee48bd commit 15a8b93
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/sunrpc/auth_gss/gss_krb5_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

#include <crypto/algapi.h>
#include <crypto/hash.h>
#include <crypto/skcipher.h>
#include <linux/err.h>
Expand Down Expand Up @@ -927,7 +928,7 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, struct xdr_buf *buf,
if (ret)
goto out_err;

if (memcmp(pkt_hmac, our_hmac, kctx->gk5e->cksumlength) != 0) {
if (crypto_memneq(pkt_hmac, our_hmac, kctx->gk5e->cksumlength) != 0) {
ret = GSS_S_BAD_SIG;
goto out_err;
}
Expand Down

0 comments on commit 15a8b93

Please sign in to comment.