crypto: aesni - prevent misaligned buffers on the stack
authorArd Biesheuvel <ardb@kernel.org>
Mon, 4 Jan 2021 15:55:46 +0000 (16:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 10:38:31 +0000 (11:38 +0100)
commit6e3b6710ea2ed9acbf10b548443c1df4845c470d
tree279b01176a29a78f979b715da48a5378ffadf45d
parente2c540e18140f4a71611238456f78c3d0598c804
crypto: aesni - prevent misaligned buffers on the stack

commit a13ed1d15b07a04b1f74b2df61ff7a5e47f45dd8 upstream.

The GCM mode driver uses 16 byte aligned buffers on the stack to pass
the IV to the asm helpers, but unfortunately, the x86 port does not
guarantee that the stack pointer is 16 byte aligned upon entry in the
first place. Since the compiler is not aware of this, it will not emit
the additional stack realignment sequence that is needed, and so the
alignment is not guaranteed to be more than 8 bytes.

So instead, allocate some padding on the stack, and realign the IV
pointer by hand.

Cc: <stable@vger.kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/crypto/aesni-intel_glue.c