powerpc/pseries/papr-sysparm: Validate buffer object lengths
authorNathan Lynch <nathanl@linux.ibm.com>
Tue, 12 Dec 2023 17:01:57 +0000 (11:01 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 13 Dec 2023 10:38:21 +0000 (21:38 +1100)
commit35aae182bd7b422be3cefc08c12207bf2b973364
tree42b9db994df30b90293141e0a7d637eb3e443250
parent514f6ff4369a30bf0da71a1a09fd47b2fca5d76f
powerpc/pseries/papr-sysparm: Validate buffer object lengths

The ability to get and set system parameters will be exposed to user
space, so let's get a little more strict about malformed
papr_sysparm_buf objects.

* Create accessors for the length field of struct papr_sysparm_buf.
  The length is always stored in MSB order and this is better than
  spreading the necessary conversions all over.

* Reject attempts to submit invalid buffers to RTAS.

* Warn if RTAS returns a buffer with an invalid length, clamping the
  returned length to a safe value that won't overrun the buffer.

These are meant as precautionary measures to mitigate both firmware
and kernel bugs in this area, should they arise, but I am not aware of
any.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231212-papr-sys_rtas-vs-lockdown-v6-10-e9eafd0c8c6c@linux.ibm.com
arch/powerpc/platforms/pseries/papr-sysparm.c