powerpc/pseries: Enforce hcall result buffer validity and size
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ b9377ffc3a03cde558d76349a262a1adbb6d3112 · < 3ad0034910a57aa88ed9976b1431b7b8c84e0048| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
powerpc/pseries: Enforce hcall result buffer validity and size
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, | ^ ~~~~~~
From the CVE record · Linux
The Linux kernel’s powerpc/pseries hcall APIs did not enforce the required size of caller-provided result buffers. An undersized buffer could cause stack corruption, but the report identifies no real affected caller or attacker path; network access, authentication, and user-interaction requirements are not established.
Engineers running the Linux kernel on powerpc/pseries systems should check their builds; affected versions are not specified.