From nobody Sun Feb 8 20:22:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604069185; cv=none; d=zohomail.com; s=zohoarc; b=ezRwidBXp6/Iq/GUsjMPBjKSP5E16oh5s6CvbyX7t5uYUkcYsvwWyqQhQBb0yBcUTQ48vVnjH4LiepkSWYtZmRNmbaBPOxABxKSmZMLBeyofpKvPAfgNPTDkjmH63x45+qmwv1rIdhP1Lj9T9LiQftPaRgGARFCsh0vDQci127A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604069185; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=e0jB6jiJn8QGLsdv/mqDddEswZ7xIZ5m5iNf0wcCKNM=; b=CVUpKvHuRqjhlVBhwzb6gOFJS66vD8bEXx/7hYWxg/YY2oCLS80330auNcqT+qGvp4c+u+Ex/qRbISDnajBa8NkNRqcRy3dLKtRv/OsQYWFaO5BuDo/jmKeQ5JLytWysUDFpkI8T4IhdSClA/rX4mfmzYKrukb1F1Qdrb4ubYxk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604069185011672.440910867665; Fri, 30 Oct 2020 07:46:25 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-FyvF4JzpOleHSZRcKym-ow-1; Fri, 30 Oct 2020 10:46:22 -0400 Received: by mail-wm1-f70.google.com with SMTP id f7so713350wmc.0 for ; Fri, 30 Oct 2020 07:46:20 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (234.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.234]) by smtp.gmail.com with ESMTPSA id y20sm1132435wma.15.2020.10.30.07.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 07:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604069183; 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: content-transfer-encoding:content-transfer-encoding; bh=e0jB6jiJn8QGLsdv/mqDddEswZ7xIZ5m5iNf0wcCKNM=; b=GPFKI3web6D1g1SA6MFe/EK04hDwVzP69IEU/04DPId3S/Ea+SEtmWxXxdgKdK4rlUaAii W0R0gjOHA90/a956wA6XG/W18MDsIEwNwUS3iUj+mNGph5BNA3gz1l4HRPkPE+6TyZlq2P sJ1ienBpaT/myUOYZmNnsPVbVYtl0C8= X-MC-Unique: FyvF4JzpOleHSZRcKym-ow-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e0jB6jiJn8QGLsdv/mqDddEswZ7xIZ5m5iNf0wcCKNM=; b=SnoTnEQa93WZhZri+9l1u3JxDAwpgGDOGHRe87UEupkdP+sS0nG9HVwHAnwHD5MVeD HJMFaXkd9ZmtWtUBdLdXmJ1lFzaTINjpx1MXpXP5/eow929Tv60+VpH5xj9ijQSeXWUw yeF/mD//Ouc+QXQEXyykWMehWvKKEd4nu6pD8RmfIjtdqXvoHhOns5xlOZB2uQ6Zy5Fb nkLrcj1uSb2huaUAAv04EkSZW1ZtdXAIhxazo9mHiuh8+ZSY53cZg7ha0KUF7utL2JbJ HXF2N8EKSfonUF/cYOuAZ079qri2vj0dl82TABGcO9i7z8kcmkvVQp0Rmbe3/pXm9gY0 CQ1w== X-Gm-Message-State: AOAM532RO5N0AFvxxO7Vy+H4lBt+q2YotAIxdzd5EfiHVJE/2u9qgFe/ awA5GVVmyLlu4Qibi/HuPYwFAFTbgu/MXbCz1FZYgdH7p4wDRGO60yn7wgTS9fZWHnNG7km14ft QHPyCPeqDMGp5aw== X-Received: by 2002:a1c:4944:: with SMTP id w65mr3015454wma.50.1604069179851; Fri, 30 Oct 2020 07:46:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUr6X7yNMxn8YF2IWie8ctUePIVGCuADg/qj5Kk4caGoNBusFpOh+kjRcV2BqJYWpVuKtBzg== X-Received: by 2002:a1c:4944:: with SMTP id w65mr3015429wma.50.1604069179625; Fri, 30 Oct 2020 07:46:19 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH-for-5.2] hw/arm/smmuv3: Fix potential integer overflow (CID 1432363) Date: Fri, 30 Oct 2020 15:46:17 +0100 Message-Id: <20201030144617.1535064-1-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use the BIT_ULL() macro to ensure we use 64-bit arithmetic. This fixes the following Coverity issue (OVERFLOW_BEFORE_WIDEN): CID 1432363 (#1 of 1): Unintentional integer overflow: overflow_before_widen: Potentially overflowing expression 1 << scale with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type hwaddr (64 bits, unsigned). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Eric Auger --- hw/arm/smmuv3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 2017ba7a5a7..22607c37841 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -17,6 +17,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "hw/irq.h" #include "hw/sysbus.h" #include "migration/vmstate.h" @@ -864,7 +865,7 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cm= d) scale =3D CMD_SCALE(cmd); num =3D CMD_NUM(cmd); ttl =3D CMD_TTL(cmd); - num_pages =3D (num + 1) * (1 << (scale)); + num_pages =3D (num + 1) * BIT_ULL(scale); } =20 if (type =3D=3D SMMU_CMD_TLBI_NH_VA) { --=20 2.26.2