powerpc/pseries: Fix alignment of PLPKS structures and buffers
authorAndrew Donnellan <ajd@linux.ibm.com>
Fri, 10 Feb 2023 08:03:37 +0000 (19:03 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 12 Feb 2023 11:12:36 +0000 (22:12 +1100)
commitfcf63d6b8ab9b12c2ce1b4bde12a3c391029c998
tree19914360c5e6aa2c1f3a248c4ddb837657dbbb54
parentf74dcbfd27c647af9b7b83f3711c63712c677abd
powerpc/pseries: Fix alignment of PLPKS structures and buffers

A number of structures and buffers passed to PKS hcalls have alignment
requirements, which could on occasion cause problems:

- Authorisation structures must be 16-byte aligned and must not cross a
  page boundary

- Label structures must not cross page boundaries

- Password output buffers must not cross page boundaries

To ensure correct alignment, we adjust the allocation size of each of
these structures/buffers to be the closest power of 2 that is at least the
size of the structure/buffer (since kmalloc() guarantees that an
allocation of a power of 2 size will be aligned to at least that size).

Reported-by: Benjamin Gray <bgray@linux.ibm.com>
Fixes: 2454a7af0f2a ("powerpc/pseries: define driver for Platform KeyStore")
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Reviewed-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230210080401.345462-3-ajd@linux.ibm.com
arch/powerpc/platforms/pseries/plpks.c