Skip to content

Commit b32a7dc

Browse files
ebiggersherbertx
authored andcommitted
crypto: algif_aead - fix reference counting of null skcipher
In the AEAD interface for AF_ALG, the reference to the "null skcipher" held by each tfm was being dropped in the wrong place -- when each af_alg_ctx was freed instead of when the aead_tfm was freed. As discovered by syzkaller, a specially crafted program could use this to cause the null skcipher to be freed while it is still in use. Fix it by dropping the reference in the right place. Fixes: 72548b0 ("crypto: algif_aead - copy AAD from src to dst") Reported-by: syzbot <syzkaller@googlegroups.com> Cc: <stable@vger.kernel.org> # v4.14+ Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent d2890c3 commit b32a7dc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎crypto/algif_aead.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ static void aead_release(void *private)
487487
struct aead_tfm *tfm = private;
488488

489489
crypto_free_aead(tfm->aead);
490+
crypto_put_default_null_skcipher2();
490491
kfree(tfm);
491492
}
492493

@@ -519,7 +520,6 @@ static void aead_sock_destruct(struct sock *sk)
519520
unsigned int ivlen = crypto_aead_ivsize(tfm);
520521

521522
af_alg_pull_tsgl(sk, ctx->used, NULL, 0);
522-
crypto_put_default_null_skcipher2();
523523
sock_kzfree_s(sk, ctx->iv, ivlen);
524524
sock_kfree_s(sk, ctx, ctx->len);
525525
af_alg_release_parent(sk);

0 commit comments

Comments
 (0)