summaryrefslogtreecommitdiff
path: root/drivers/platform
diff options
context:
space:
mode:
authorNathan Lynch <nathanl@linux.ibm.com>2024-04-08 09:08:31 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-06-27 13:46:16 +0200
commit8aa11aa001576bf3b00dcb8559564ad7a3113588 (patch)
tree3cb7d40ee096ed104cd0293a9fc68d69846d4329 /drivers/platform
parentcf56640e9a42c68d4297e4b3ac5537a64bf8d1fd (diff)
downloadlinux-8aa11aa001576bf3b00dcb8559564ad7a3113588.tar.gz
linux-8aa11aa001576bf3b00dcb8559564ad7a3113588.tar.bz2
linux-8aa11aa001576bf3b00dcb8559564ad7a3113588.zip
powerpc/pseries: Enforce hcall result buffer validity and size
[ Upstream commit ff2e185cf73df480ec69675936c4ee75a445c3e4 ] plpar_hcall(), plpar_hcall9(), and related functions expect callers to provide valid result buffers of certain minimum size. Currently this is communicated only through comments in the code and the compiler has no idea. For example, if I write a bug like this: long retbuf[PLPAR_HCALL_BUFSIZE]; // should be PLPAR_HCALL9_BUFSIZE plpar_hcall9(H_ALLOCATE_VAS_WINDOW, retbuf, ...); This compiles with no diagnostics emitted, but likely results in stack corruption at runtime when plpar_hcall9() stores results past the end of the array. (To be clear this is a contrived example and I have not found a real instance yet.) To make this class of error less likely, we can use explicitly-sized array parameters instead of pointers in the declarations for the hcall APIs. When compiled with -Warray-bounds[1], the code above now provokes a diagnostic like this: error: array argument is too small; is of size 32, callee requires at least 72 [-Werror,-Warray-bounds] 60 | plpar_hcall9(H_ALLOCATE_VAS_WINDOW, retbuf, | ^ ~~~~~~ [1] Enabled for LLVM builds but not GCC for now. See commit 0da6e5fd6c37 ("gcc: disable '-Warray-bounds' for gcc-13 too") and related changes. Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240408-pseries-hvcall-retbuf-v1-1-ebc73d7253cf@linux.ibm.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/platform')
0 files changed, 0 insertions, 0 deletions