From: Jonathan Cameron Date: Fri, 1 Nov 2024 13:39:14 +0000 (+0000) Subject: hw/cxl: Ensuring enough data to read parameters in cmd_tunnel_management_cmd() X-Git-Tag: v9.2.0-rc0~17^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c0f122419fbcd1e0bf2bc2a0a3ae6410bb2cda22;p=thirdparty%2Fqemu.git hw/cxl: Ensuring enough data to read parameters in cmd_tunnel_management_cmd() If len_in is less than the minimum spec allowed value, then return CXL_MBOX_INVALID_PAYLOAD_LENGTH Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-8-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 5e571955b63..a40d81219c6 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -151,6 +151,9 @@ static CXLRetCode cmd_tunnel_management_cmd(const struct cxl_cmd *cmd, in = (void *)payload_in; out = (void *)payload_out; + if (len_in < sizeof(*in)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } /* Enough room for minimum sized message - no payload */ if (in->size < sizeof(in->ccimessage)) { return CXL_MBOX_INVALID_PAYLOAD_LENGTH;