Thread (18 messages) 18 messages, 3 authors, 2021-05-21

Re: [PATCH v3 1/7] crypto: handle zero sized AEAD inputs correctly

From: Eric Biggers <ebiggers@kernel.org>
Date: 2021-05-12 21:08:11
Also in: linux-arm-kernel

On Wed, May 12, 2021 at 08:44:33PM +0200, Ard Biesheuvel wrote:
There are corner cases where skcipher_walk_aead_[en|de]crypt() may be
invoked with a zero sized input, which is not rejected by the walker
code, but results in the skcipher_walk structure to not be fully
initialized. This will leave stale values in its page and buffer
members, which will be subsequently passed to kfree() or free_page() by
skcipher_walk_done(), resulting in a crash if those routines fail to
identify them as in valid inputs.

Fix this by setting page and buffer to NULL even if the size of the
input is zero.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Is this fixing an existing bug, or only a bug that got exposed by this patchset?
It would be helpful to make that clear (and if it fixes an existing bug, include
a Fixes tag).

Also, skcipher_walk_virt() doesn't set page and buffer to NULL, as it is
currently expected that skcipher_walk_done() is only called when
walk.nbytes != 0.  Is something different for skcipher_walk_aead_[en|de]crypt()?

- Eric
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help