diff options
author | Andrew Donnellan <ajd@linux.ibm.com> | 2023-02-16 10:09:03 +0300 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2023-02-16 13:16:22 +0300 |
commit | 7096deb7b5387e7899655213b7430ab043ddda4f (patch) | |
tree | b9d2d71f07ca378a851bf750935c6e250c132b18 /arch | |
parent | 748ea32d2dbd813d3bd958117bde5191182f909a (diff) | |
download | linux-7096deb7b5387e7899655213b7430ab043ddda4f.tar.xz |
powerpc/pseries: Fix endianness issue when parsing PLPKS secvar flags
When a user updates a variable through the PLPKS secvar interface, we take
the first 8 bytes of the data written to the update attribute to pass
through to the H_PKS_SIGNED_UPDATE hcall as flags. These bytes are always
written in big-endian format.
Currently, the flags bytes are memcpy()ed into a u64, which is then loaded
into a register to pass as part of the hcall. This means that on LE
systems, the bytes are in the wrong order.
Use be64_to_cpup() instead, to ensure the flags bytes are byteswapped if
necessary.
Reported-by: Stefan Berger <stefanb@linux.ibm.com>
Fixes: ccadf154cb00 ("powerpc/pseries: Implement secvars for dynamic secure boot")
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230216070903.355091-1-ajd@linux.ibm.com
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/pseries/plpks-secvar.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/pseries/plpks-secvar.c b/arch/powerpc/platforms/pseries/plpks-secvar.c index f6c8888f4076..257fd1f8bc19 100644 --- a/arch/powerpc/platforms/pseries/plpks-secvar.c +++ b/arch/powerpc/platforms/pseries/plpks-secvar.c @@ -135,7 +135,8 @@ static int plpks_set_variable(const char *key, u64 key_len, u8 *data, goto err; var.namelen = rc * 2; - memcpy(&flags, data, sizeof(flags)); + // Flags are contained in the first 8 bytes of the buffer, and are always big-endian + flags = be64_to_cpup((__be64 *)data); var.datalen = data_size - sizeof(flags); var.data = data + sizeof(flags); |