]> git.baikalelectronics.ru Git - kernel.git/commit
sunrpc: remove incorrect HMAC request initialization
authorEric Biggers <ebiggers@google.com>
Wed, 28 Mar 2018 17:57:22 +0000 (10:57 -0700)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 3 Apr 2018 19:08:17 +0000 (15:08 -0400)
commitcf890862d5580692ea17bb34fc2033a9d4e816e3
treed9c68f712e66b11ab0073c87cbc22b58f2e073f2
parenta6180425f1e8755dc89a4d83a25fba669a58c70f
sunrpc: remove incorrect HMAC request initialization

make_checksum_hmac_md5() is allocating an HMAC transform and doing
crypto API calls in the following order:

    crypto_ahash_init()
    crypto_ahash_setkey()
    crypto_ahash_digest()

This is wrong because it makes no sense to init() the request before a
key has been set, given that the initial state depends on the key.  And
digest() is short for init() + update() + final(), so in this case
there's no need to explicitly call init() at all.

Before commit 72c6089ec0c6 ("crypto: hash - prevent using keyed hashes
without setting key") the extra init() had no real effect, at least for
the software HMAC implementation.  (There are also hardware drivers that
implement HMAC-MD5, and it's not immediately obvious how gracefully they
handle init() before setkey().)  But now the crypto API detects this
incorrect initialization and returns -ENOKEY.  This is breaking NFS
mounts in some cases.

Fix it by removing the incorrect call to crypto_ahash_init().

Reported-by: Michael Young <m.a.young@durham.ac.uk>
Fixes: 72c6089ec0c6 ("crypto: hash - prevent using keyed hashes without setting key")
Fixes: 5388eeb2524a ("gss_krb5: Add support for rc4-hmac encryption")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
net/sunrpc/auth_gss/gss_krb5_crypto.c