crypto: algif_aead - fix uninitialized ctx->init
authorOndrej Mosnacek <omosnace@redhat.com>
Wed, 12 Aug 2020 12:58:25 +0000 (14:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:07:42 +0000 (13:07 +0200)
commitd54df8d8a84321238e6f8557dd32a1b0eef8aa5c
treeccfc1e4117e8c193cd8582314b2acb393a15f7fd
parent35a7872bebe83cb6d24b4f81fb6826ebadee1a22
crypto: algif_aead - fix uninitialized ctx->init

[ Upstream commit 21dfbcd1f5cbff9cf2f9e7e43475aed8d072b0dd ]

In skcipher_accept_parent_nokey() the whole af_alg_ctx structure is
cleared by memset() after allocation, so add such memset() also to
aead_accept_parent_nokey() so that the new "init" field is also
initialized to zero. Without that the initial ctx->init checks might
randomly return true and cause errors.

While there, also remove the redundant zero assignments in both
functions.

Found via libkcapi testsuite.

Cc: Stephan Mueller <smueller@chronox.de>
Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when ctx->more is zero")
Suggested-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
crypto/algif_aead.c
crypto/algif_skcipher.c