From nobody Sat Nov 23 22:41:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730754756; cv=none; d=zohomail.com; s=zohoarc; b=Js4T8usz76ZPbtFqrs5ryQbN6xBSC1FFSyV2IXMcUzer+cnZ/BdTO84L8Mk24+99h79v6Rv4a9essdGu4ZceA4HqNZFV7yPBbxQA1TjMyBgKJ/KtlYehHcXXW3fn3/spqY1o3HZhCevv5ac0kjQRyncAVCRccsIo/TXSsc49plY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730754756; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YE3jbdd2VsjbSTZBjpl3sy5PbqS0FjP8JRPVWflkFi0=; b=cbuKe3n7CehbhlYF/i7cDl99d/hZCft1bhEZkpmZFsyuPh9kZZlOrwhPYkSynWvPtEgrKGd2K69EHTGvuzi8EIr8PLUIaC9STULkYxKbcQM3TxMtLdYhSZaQSHmzmyHbVwaK5H361rtNbeW5s0RvtpOAjrbsg+KHco2iEGn7DxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730754756008697.7279106616526; Mon, 4 Nov 2024 13:12:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Jp-0007rz-Co; Mon, 04 Nov 2024 16:09:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jl-0007jo-M2 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jk-0005VY-4t for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:57 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-m7AFdiuBPrq5RI4N4pvftw-1; Mon, 04 Nov 2024 16:08:54 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4316e350d6aso30653565e9.3 for ; Mon, 04 Nov 2024 13:08:54 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5e94cdsm164169865e9.28.2024.11.04.13.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754535; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YE3jbdd2VsjbSTZBjpl3sy5PbqS0FjP8JRPVWflkFi0=; b=eUtqMPOmZ75s0nydaP3FU6JBCUzhedqtsO5qiq/oXSbb/JIFJg7DvTMagqhRYB4HIxNA4o R/JdEPr7sCTWH1eT2/Hj4C5qymAT4bbybUDMb8i8EZ4Y/mLiCyCqHzot7AUKKYqoIyspJI n49nSwBDt/ZH7rxbBUsHP1Omw6WaG0g= X-MC-Unique: m7AFdiuBPrq5RI4N4pvftw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754532; x=1731359332; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YE3jbdd2VsjbSTZBjpl3sy5PbqS0FjP8JRPVWflkFi0=; b=sd9wpWUjP2pgSFpOsdOoquU6UoF6ifKuIvUQc25WSpTppVMQq7X345c/2cbCimfvzP GSIUniQrLcHigNc/WUcmPmby5zW3EQh7Qp4JJHHxZDQjl+nrsmLBxbarTbjceLeHRk+b zzRV5CuNXCT1laSllFF7njhAcVDoK6rZCVPD5DJ88h0pTWld/ByHpbSEmtwGIpnNeWoK kASvj5jdxTQZGdMTAc2VsYn+kf3lDDQ7ZmUf03TbIli9G+LkhDriKt/TekzN3vy4jqx9 ocBR07TcS1DZh6xWHAA3G3iECJ2nxECFjurVcCGZVBPP05ZbLs29Syv03t/tVrAsfz4q +lHw== X-Gm-Message-State: AOJu0Yx3cwW+5efokSyuaypMs6geFR+8uih6u2mMx54Rdp5VkCnudHm/ 4sQGF2/kxrYPqCDt17NQ9H5RLhpHUhH5iY6V/TF1RB+qwf+kQKL4+x+lDKJY8nHgyurwdyewfvk znlQNpyUtRaaMB3m/i6MNWyi82E/o+gof/FEpguX9GLg8qP8SJiA6vGRkr/BZ36PTNfmfStfxAr d3auhPcW2ryz0JMgWgM0I3CeFJDNhcgQ== X-Received: by 2002:a05:600c:5486:b0:431:51c0:c90f with SMTP id 5b1f17b1804b1-43283255472mr117030515e9.21.1730754531997; Mon, 04 Nov 2024 13:08:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyGuabMcOjD+Im0BD9FjrVzXqRAXS+HvFXGhxfx+Bhhq7+NF/W6JSKi1fFfo6plWoFBbOkeQ== X-Received: by 2002:a05:600c:5486:b0:431:51c0:c90f with SMTP id 5b1f17b1804b1-43283255472mr117030325e9.21.1730754531532; Mon, 04 Nov 2024 13:08:51 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 49/65] hw/cxl: Check input length is large enough in cmd_events_clear_records() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1730754756623116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Buggy software might write a message that is too short for either the header, or the header + the event data that is specified in the header. This may result in accesses beyond the range of the message allocated as a duplicate of the incoming message buffer. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e63140aefe..3cb499a24f 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -266,6 +266,12 @@ static CXLRetCode cmd_events_clear_records(const struc= t cxl_cmd *cmd, CXLClearEventPayload *pl; =20 pl =3D (CXLClearEventPayload *)payload_in; + + if (len_in < sizeof(*pl) || + len_in < sizeof(*pl) + sizeof(*pl->handle) * pl->nr_recs) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + *len_out =3D 0; return cxl_event_clear_records(cxlds, pl); } --=20 MST