Commit 6978bd6a authored by Chuck Lever's avatar Chuck Lever

SUNRPC: Revert 561141dd

Scott reports an occasional scatterlist BUG that is triggered by the
RFC 8009 Kunit test, then says:

> Looking through the git history of the auth_gss code, there are various
> places where static buffers were replaced by dynamically allocated ones
> because they're being used with scatterlists.
Reported-by: default avatarScott Mayhew <smayhew@redhat.com>
Fixes: 561141dd ("SUNRPC: Use a static buffer for the checksum initialization vector")
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 9fe6e9e7
...@@ -921,8 +921,6 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, u32 len, ...@@ -921,8 +921,6 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, u32 len,
* Caller provides the truncation length of the output token (h) in * Caller provides the truncation length of the output token (h) in
* cksumout.len. * cksumout.len.
* *
* Note that for RPCSEC, the "initial cipher state" is always all zeroes.
*
* Return values: * Return values:
* %GSS_S_COMPLETE: Digest computed, @cksumout filled in * %GSS_S_COMPLETE: Digest computed, @cksumout filled in
* %GSS_S_FAILURE: Call failed * %GSS_S_FAILURE: Call failed
...@@ -933,19 +931,22 @@ u32 krb5_etm_checksum(struct crypto_sync_skcipher *cipher, ...@@ -933,19 +931,22 @@ u32 krb5_etm_checksum(struct crypto_sync_skcipher *cipher,
int body_offset, struct xdr_netobj *cksumout) int body_offset, struct xdr_netobj *cksumout)
{ {
unsigned int ivsize = crypto_sync_skcipher_ivsize(cipher); unsigned int ivsize = crypto_sync_skcipher_ivsize(cipher);
static const u8 iv[GSS_KRB5_MAX_BLOCKSIZE];
struct ahash_request *req; struct ahash_request *req;
struct scatterlist sg[1]; struct scatterlist sg[1];
u8 *iv, *checksumdata;
int err = -ENOMEM; int err = -ENOMEM;
u8 *checksumdata;
checksumdata = kmalloc(crypto_ahash_digestsize(tfm), GFP_KERNEL); checksumdata = kmalloc(crypto_ahash_digestsize(tfm), GFP_KERNEL);
if (!checksumdata) if (!checksumdata)
return GSS_S_FAILURE; return GSS_S_FAILURE;
/* For RPCSEC, the "initial cipher state" is always all zeroes. */
iv = kzalloc(ivsize, GFP_KERNEL);
if (!iv)
goto out_free_mem;
req = ahash_request_alloc(tfm, GFP_KERNEL); req = ahash_request_alloc(tfm, GFP_KERNEL);
if (!req) if (!req)
goto out_free_cksumdata; goto out_free_mem;
ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL);
err = crypto_ahash_init(req); err = crypto_ahash_init(req);
if (err) if (err)
...@@ -969,7 +970,8 @@ u32 krb5_etm_checksum(struct crypto_sync_skcipher *cipher, ...@@ -969,7 +970,8 @@ u32 krb5_etm_checksum(struct crypto_sync_skcipher *cipher,
out_free_ahash: out_free_ahash:
ahash_request_free(req); ahash_request_free(req);
out_free_cksumdata: out_free_mem:
kfree(iv);
kfree_sensitive(checksumdata); kfree_sensitive(checksumdata);
return err ? GSS_S_FAILURE : GSS_S_COMPLETE; return err ? GSS_S_FAILURE : GSS_S_COMPLETE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment