Skip to content

Commit 7096deb

Browse files
ajdlinuxmpe
authored andcommitted
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 <[email protected]> Fixes: ccadf15 ("powerpc/pseries: Implement secvars for dynamic secure boot") Signed-off-by: Andrew Donnellan <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 748ea32 commit 7096deb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/powerpc/platforms/pseries/plpks-secvar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ static int plpks_set_variable(const char *key, u64 key_len, u8 *data,
135135
goto err;
136136
var.namelen = rc * 2;
137137

138-
memcpy(&flags, data, sizeof(flags));
138+
// Flags are contained in the first 8 bytes of the buffer, and are always big-endian
139+
flags = be64_to_cpup((__be64 *)data);
139140

140141
var.datalen = data_size - sizeof(flags);
141142
var.data = data + sizeof(flags);

0 commit comments

Comments
 (0)