crypto: skcipher - Unmap pages after an external error
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 6 Sep 2019 03:13:06 +0000 (13:13 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Oct 2019 16:20:52 +0000 (18:20 +0200)
commitcd8e0a5d94fba7c6032484ac89254940bad9b537
treee2a8ee199b1ce9ac242c76f338b2cb4c68368d48
parent9349108ae499b352ce1605076a9b74ec450bbb75
crypto: skcipher - Unmap pages after an external error

commit 0ba3c026e685573bd3534c17e27da7c505ac99c4 upstream.

skcipher_walk_done may be called with an error by internal or
external callers.  For those internal callers we shouldn't unmap
pages but for external callers we must unmap any pages that are
in use.

This patch distinguishes between the two cases by checking whether
walk->nbytes is zero or not.  For internal callers, we now set
walk->nbytes to zero prior to the call.  For external callers,
walk->nbytes has always been non-zero (as zero is used to indicate
the termination of a walk).

Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Fixes: 5cde0af2a982 ("[CRYPTO] cipher: Added block cipher type")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
crypto/skcipher.c