Skip to content

hw/cxl: Mailbox input parser hardening against invalid input.

Jonathan Cameron linux-cxl qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10hw/cxl: Check size of input data to dynamic capacity mailbox commandshw/cxl/cxl-mailbox-utils.c+18 -01 reply
2/10hw/cxl: Check input includes at least the header in cmd_features_set_feature()hw/cxl/cxl-mailbox-utils.c+3 -01 reply
3/10hw/cxl: Check input length is large enough in cmd_events_clear_records()hw/cxl/cxl-mailbox-utils.c+6 -01 reply
4/10hw/cxl: Check enough data in cmd_firmware_update_transfer()hw/cxl/cxl-mailbox-utils.c+4 -01 reply
5/10hw/cxl: Check the length of data requested fits in get_log()hw/cxl/cxl-mailbox-utils.c+1 -11 reply
6/10hw/cxl: Avoid accesses beyond the end of cel_log.hw/cxl/cxl-mailbox-utils.c+13 -91 reply
7/10hw/cxl: Ensuring enough data to read parameters in cmd_tunnel_management_cmd()hw/cxl/cxl-mailbox-utils.c+3 -01 reply
8/10hw/cxl: Check that writes do not go beyond end of target attributeshw/cxl/cxl-mailbox-utils.c+10 -03 replies
9/10hw/cxl: Ensure there is enough data for the header in cmd_ccls_set_lsa()hw/cxl/cxl-mailbox-utils.c+2 -21 reply
10/10hw/cxl: Ensure there is enough data to read the input header in cmd_get_physical_port_state()hw/cxl/cxl-mailbox-utils.c+3 -01 reply

Reviews trailers per patch

9 of 10 patches have a Reviewed-by or Acked-by.

PatchFan Ni
1/10R-b
2/10R-b
3/10R-b
4/10R-b
5/10
6/10R-b
7/10R-b
8/10R-b
9/10R-b
10/10R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH qemu 00/10] hw/cxl: Mailbox input parser hardening against invalid input.

The CXL device mailbox has some variable sized input commands. The payload length for each must be established using command especific structures.

If user space is either buggy or malicious, it may use size fields to indicate fields beyond the end of the payload sent. Some checks on this were missing and Esifiel picked up on this. I've tagged all these fixes with Esifiel's Reported-by as either they were in the report or are similar issues in other commands.

These can mostly be easily tested by using the raw mailbox commands option in Linux and injecting broken commands from user space.

A typical command needs to first check that there is enough data to get to the command specific sizing fields, then check the reported size is less than or equal to the available payload.

Note that I think it very unlikely anyone is currently using CXL emulation with a VM that they do not trust, but that may happen in future so good to fix these paths now.

Jonathan Cameron (10):
hw/cxl: Check size of input data to dynamic capacity mailbox commands hw/cxl: Check input includes at least the header in
cmd_features_set_feature()
hw/cxl: Check input length is large enough in
cmd_events_clear_records()
hw/cxl: Check enough data in cmd_firmware_update_transfer() hw/cxl: Check the length of data requested fits in get_log() hw/cxl: Avoid accesses beyond the end of cel_log.
hw/cxl: Ensuring enough data to read parameters in
cmd_tunnel_management_cmd()
hw/cxl: Check that writes do not go beyond end of target attributes hw/cxl: Ensure there is enough data for the header in

    cmd_ccls_set_lsa()

hw/cxl: Ensure there is enough data to read the input header in
cmd_get_physical_port_state()

 hw/cxl/cxl-mailbox-utils.c | 73 ++++++++++++++++++++++++++++++++------
 1 file changed, 62 insertions(+), 11 deletions(-)
Signature · 1 line
2.43.0