Skip to content

Commit 6978bd6

Browse files
committed
SUNRPC: Revert 561141d
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: Scott Mayhew <[email protected]> Fixes: 561141d ("SUNRPC: Use a static buffer for the checksum initialization vector") Signed-off-by: Chuck Lever <[email protected]>
1 parent 9fe6e9e commit 6978bd6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

net/sunrpc/auth_gss/gss_krb5_crypto.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,6 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, u32 len,
921921
* Caller provides the truncation length of the output token (h) in
922922
* cksumout.len.
923923
*
924-
* Note that for RPCSEC, the "initial cipher state" is always all zeroes.
925-
*
926924
* Return values:
927925
* %GSS_S_COMPLETE: Digest computed, @cksumout filled in
928926
* %GSS_S_FAILURE: Call failed
@@ -933,19 +931,22 @@ u32 krb5_etm_checksum(struct crypto_sync_skcipher *cipher,
933931
int body_offset, struct xdr_netobj *cksumout)
934932
{
935933
unsigned int ivsize = crypto_sync_skcipher_ivsize(cipher);
936-
static const u8 iv[GSS_KRB5_MAX_BLOCKSIZE];
937934
struct ahash_request *req;
938935
struct scatterlist sg[1];
936+
u8 *iv, *checksumdata;
939937
int err = -ENOMEM;
940-
u8 *checksumdata;
941938

942939
checksumdata = kmalloc(crypto_ahash_digestsize(tfm), GFP_KERNEL);
943940
if (!checksumdata)
944941
return GSS_S_FAILURE;
942+
/* For RPCSEC, the "initial cipher state" is always all zeroes. */
943+
iv = kzalloc(ivsize, GFP_KERNEL);
944+
if (!iv)
945+
goto out_free_mem;
945946

946947
req = ahash_request_alloc(tfm, GFP_KERNEL);
947948
if (!req)
948-
goto out_free_cksumdata;
949+
goto out_free_mem;
949950
ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL);
950951
err = crypto_ahash_init(req);
951952
if (err)
@@ -969,7 +970,8 @@ u32 krb5_etm_checksum(struct crypto_sync_skcipher *cipher,
969970

970971
out_free_ahash:
971972
ahash_request_free(req);
972-
out_free_cksumdata:
973+
out_free_mem:
974+
kfree(iv);
973975
kfree_sensitive(checksumdata);
974976
return err ? GSS_S_FAILURE : GSS_S_COMPLETE;
975977
}

0 commit comments

Comments
 (0)