crypto: algif_aead - fix reference counting of null skcipher
authorEric Biggers <ebiggers@google.com>
Tue, 28 Nov 2017 07:23:05 +0000 (23:23 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Dec 2017 09:10:16 +0000 (10:10 +0100)
commit96c2dfaebe1a8eba95d43732a1413c777469128c
treeb5a6ed54395c421c89dd142c0422bd3537fee014
parent3d27b022022a88e189c0e9d63c4ac01af354735f
crypto: algif_aead - fix reference counting of null skcipher

commit b32a7dc8aef1882fbf983eb354837488cc9d54dc upstream.

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: 72548b093ee3 ("crypto: algif_aead - copy AAD from src to dst")
Reported-by: syzbot <syzkaller@googlegroups.com>
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
crypto/algif_aead.c