]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
crypto: ghash - fix unaligned memory access in ghash_setkey()
authorEric Biggers <ebiggers@google.com>
Thu, 30 May 2019 17:50:39 +0000 (10:50 -0700)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit21ec3f0decd48cbd0de3adf694f1636d31571636
tree1ac69c8656eaa1315a15b36120dee0de7e806157
parent71c204ad969556cc39f2c3187ba944a01683071b
crypto: ghash - fix unaligned memory access in ghash_setkey()

BugLink: https://bugs.launchpad.net/bugs/1839036
commit 5c6bc4dfa515738149998bb0db2481a4fdead979 upstream.

Changing ghash_mod_init() to be subsys_initcall made it start running
before the alignment fault handler has been installed on ARM.  In kernel
builds where the keys in the ghash test vectors happened to be
misaligned in the kernel image, this exposed the longstanding bug that
ghash_setkey() is incorrectly casting the key buffer (which can have any
alignment) to be128 for passing to gf128mul_init_4k_lle().

Fix this by memcpy()ing the key to a temporary buffer.

Don't fix it by setting an alignmask on the algorithm instead because
that would unnecessarily force alignment of the data too.

Fixes: 2cdc6899a88e ("crypto: ghash - Add GHASH digest algorithm for GCM")
Reported-by: Peter Robinson <pbrobinson@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
crypto/ghash-generic.c