From nobody Sat Nov 23 23:48:04 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=1730754846; cv=none; d=zohomail.com; s=zohoarc; b=IT6rpOmz3+GUXcHgmY3xNnkvhaeeR74nYzYtCHrfGKFUVHl1zXbRUu3m3GRl2bnE1gFIVtPr6ZAfu/vz8S/sDzGX8Ztw6htWyljsXmoppRyDTPoyel6u5yeQqVPBzZZkIBDDnPPRv58hJZqTZu6I1ZzUH9XOX50JqCe+q1/FAqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730754846; 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=PWXbuaXLWsxhC+1PBbOQmp6i/5Hl2ASTF0Q1ZdpmUUk=; b=nT8a6sE59/LdbKbofhtr5e+T4IRlHGMe3GLJDSUNDESgdmVVjECtnkcGxV/ivZAM5NSFide/D5JyhuveGxO2jpO+GHjWqa/dQ4nPgrn/ieYtQtHmFVBH6rTEP9eq9A8UlrK5wJitPOoGykHm553ISfEdYT+gqQUfxrGzoa7dJAc= 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 1730754846475112.38953560064272; Mon, 4 Nov 2024 13:14:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JA-0003P8-5p; Mon, 04 Nov 2024 16:08:20 -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 1t84Iv-0002uZ-Jn for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Iu-0005Rl-3W for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:05 -0500 Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-356-jtPZlLGSOnuHZM8vX2UfuA-1; Mon, 04 Nov 2024 16:08:02 -0500 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539eb3416cdso4957317e87.1 for ; Mon, 04 Nov 2024 13:07:59 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10e74casm14101459f8f.65.2024.11.04.13.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754483; 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=PWXbuaXLWsxhC+1PBbOQmp6i/5Hl2ASTF0Q1ZdpmUUk=; b=SmvK+zkPlqmquDV4mR0cOnFbuKsWDmynYwP841qiscd4XC0y8lsXOCMotywnfRoEM2B3mx 0qzdkyS7T79GYeg4wW4p67uOVKmAJr/1achDvKwhOfGceppL9m8hVCxw/QMFQNcut0nmvi Z5QC82K/fklDbnekvE/AsqehLHSDZu4= X-MC-Unique: jtPZlLGSOnuHZM8vX2UfuA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754478; x=1731359278; 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=PWXbuaXLWsxhC+1PBbOQmp6i/5Hl2ASTF0Q1ZdpmUUk=; b=aDg23AuzEUkK0cJOv+KJKl5iJah/S/NmNmAcr60rTa9p1zsahK/iF4Do5ScMe2Hd3c X3edD75U7yuDwRvuBpxyjTu62bGmIXLXxziGXSDJ7SLbnCIjFSDxrXHN1604LBnUgxTd bdsNUcfcXQusbDpTU2xbouuw3htx3z+zWWKkNFil6txtC90SSuEYYVB8KEA3734lYkKG BcV5ivcZgt1iwgFp6RPyr1FuSSqfWv6Yu1ByUe91Z96rTo50cbpmN+nBk7Tw5GbdPd3E pAvUIB65fO9wLNqic9Tk5xHE74lDKAUougGWWDnFcnGhHSE/lmJJFXv2FFkfOtsbdOA8 UEmw== X-Gm-Message-State: AOJu0YzEA7Gs/OrzN7YLB8MtsNzoPBBSIFUOSgO6mF3FtRE8/iSbKkFB heWfzrc7zI9VUWf2nLiN/+Uk7EtGIVljYRoDuXt2tEkD2EEFvdPHcsw4osiLNtdk1gg26PV7ReZ mv6Yupqencbdhpc1jLPSaVf1mQ75XhWF0p0z0Ik1kwKh+agGA+NHVqxRxcF5TLA/cphMz+l/x5d 3UrXQBoWPmsriijNudUJpnAV2OZyNWdw== X-Received: by 2002:a05:6512:1107:b0:539:f7ba:c982 with SMTP id 2adb3069b0e04-53b348ee5c3mr16096512e87.33.1730754477967; Mon, 04 Nov 2024 13:07:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY2/CcAbrmEEmarzllxlbzbd+M76HDi3y25SxQWP52VbzH04cyvDgvnGuCH9sLROeCBDEMtg== X-Received: by 2002:a05:6512:1107:b0:539:f7ba:c982 with SMTP id 2adb3069b0e04-53b348ee5c3mr16096491e87.33.1730754477400; Mon, 04 Nov 2024 13:07:57 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Dmitry Frolov , Jonathan Cameron , Fan Ni Subject: [PULL 35/65] hw/cxl: Fix uint32 overflow cxl-mailbox-utils.c 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.133.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_H3=0.001, RCVD_IN_MSPIKE_WL=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: 1730754847157116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Dmitry Frolov The sum offset + length may overflow uint32. Since this sum is compared with uint64_t return value of get_lsa_size(), it makes sense to choose uint64_t type for offset and length. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 3ebe676a3463 ("hw/cxl/device: Implement get/set Label Storage Area (= LSA)") Signed-off-by: Dmitry Frolov Link: https://lore.kernel.org/r/20240917080925.270597-2-frolov@swemel.ru Signed-off-by: Jonathan Cameron Message-Id: <20241014121902.2146424-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 9258e48f95..9f794e4655 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1445,7 +1445,7 @@ static CXLRetCode cmd_ccls_get_lsa(const struct cxl_c= md *cmd, } QEMU_PACKED *get_lsa; CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); - uint32_t offset, length; + uint64_t offset, length; =20 get_lsa =3D (void *)payload_in; offset =3D get_lsa->offset; --=20 MST