From: Jonathan Cameron Date: Fri, 1 Nov 2024 13:39:16 +0000 (+0000) Subject: hw/cxl: Ensure there is enough data for the header in cmd_ccls_set_lsa() X-Git-Tag: v9.2.0-rc0~17^2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5300bdf5898dda5989215e183bccd555cc782b9a;p=thirdparty%2Fqemu.git hw/cxl: Ensure there is enough data for the header in cmd_ccls_set_lsa() The properties of the requested set command cannot be established if len_in is less than the size of the header. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-10-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 078782e8b90..f4a436e1728 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1503,8 +1503,8 @@ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd *cmd, const size_t hdr_len = offsetof(struct set_lsa_pl, data); *len_out = 0; - if (!len_in) { - return CXL_MBOX_SUCCESS; + if (len_in < hdr_len) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; } if (set_lsa_payload->offset + len_in > cvc->get_lsa_size(ct3d) + hdr_len) {