From nobody Sat Nov 23 22:18:31 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1730680037; cv=none; d=zohomail.com; s=zohoarc; b=H6CqNuZgQ6JE2Z+Y+updgrgglbaHWenxylFf5l7y4ra/J4gKmSJ3T4iDwhtxJ5hzJGVB3ZuedHXSVztrm5KPzydP9zHmFM7uFmbcldrkOrx6JkULGgJQLvfY+1VbnTNlSFSKjRbyKgDY/et+iG6hTQYUQsB4W99sufHN8rYjpGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730680037; h=Content-Transfer-Encoding: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=Ftki89nEYstrfFSAin/yFBIlJQIjomoZE+uZMXBkVss=; b=duy9DGBFRspEdqOXdylqyKoHRfl2TXRlqPtUvm7dfNiKPrlnaN63wTdkjzyeNq7r+tx69MHepZBW6GIHzO5HCn9f0EpdBI7TPnJf3RaV17jvwt0HjXXb//1JYzRWti3QMuPWFfR/bcjc7o/sQSpLCde6Mw9jd1aDivGhzqTouTg= 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 1730680037089434.7383701313455; Sun, 3 Nov 2024 16:27:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7krN-0006gU-O4; Sun, 03 Nov 2024 19:22:23 -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 1t7kr5-0005Nc-BA; Sun, 03 Nov 2024 19:22:06 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t7kr3-0002kH-JH; Sun, 03 Nov 2024 19:22:02 -0500 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-720d14c8dbfso2325857b3a.0; Sun, 03 Nov 2024 16:22:00 -0800 (PST) Received: from wheely.local0.net (124-171-217-17.tpgi.com.au. [124.171.217.17]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ee45a0081esm5900648a12.59.2024.11.03.16.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 16:21:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730679719; x=1731284519; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ftki89nEYstrfFSAin/yFBIlJQIjomoZE+uZMXBkVss=; b=GvB9gOVu8LFfncOekovFH77bLyXmdcXz9QF8+wMZOWYfZVNKUbYZ0zq9Yi4MqEgHcb tWoDF8IMyjYQ1zfgOyro6+3eoPQ0YSh6KUW+Z17jwPeWOo9CSuX6h8+6PrRAu2ElSpKx oxKgcT1f3v/60nLBIPXOcDN/1D0tN3DDKks+yYaI+QXe6sGV5kTb/upmBvyfZDw3NWz1 IYZnkUPCdJNe70q4Iq94iVbfHcfA4PInJ9UQ3ThddST5fD+WHUGFPe0lEdD25sFR23sG +tUDOq3CN2KnC9R1OBVt8TEhbD3fM7iZF7vXnFxC7kc8Czrn5Ujhc162FOYtOgT07Ha8 fNtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730679719; x=1731284519; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ftki89nEYstrfFSAin/yFBIlJQIjomoZE+uZMXBkVss=; b=pV1j4IIYBVqGwyR+8XDVgQ3pZ7CPljL/RDVPT2TcBo7Q/rcoFTaUrYZ1GsSHD/g/Cj uR7sXEUZxI1n1bvse1mwC+E2pS+bu7BNN1QVEDc1nvvK/eOMAHuwz9n/tv9fue9w6wWe NVZDq06QNLAYSBQ/9/kUARknAbYHD8nSxauEurnJz+UWuNQh5/3L8jahK0AuWwhWpMU6 FeGIXjN9TixnxyJoCoUPnCqsYQNglvGunPxLzEsQW/bkE4sSv3c/znefoSXFdNmBkO4u IXDcxc9jw2ITjbJjWvj6V9nsBHLhVzQ2Sh30wVWXuOnN6MXoEzfUQEE7svGtEL7h6H8A 5KGQ== X-Forwarded-Encrypted: i=1; AJvYcCU5p25Kd/4uQ4J1WG+0NmKTPj52Ro9tz7Vx2M48BUASz1fwuqeqxwr7lZYW62rLKy9VVTNzuSyk2A==@nongnu.org X-Gm-Message-State: AOJu0YwJsOl8wEzapCSphzCeK5Tirf2657cO5kmF5aWq5tmfbfm3Bl0H jCCfH1Ivnd3DI6pgYwrUScjt5tCjSX/9k26auMqZtpLw1/i80OM+aF0t3A== X-Google-Smtp-Source: AGHT+IHO1sQuIOtze6zkEGzlWozl1J1Y8MlNv5lV+kDD4mmRWTnSES24uoqlMfixeLExFDykDj9XaA== X-Received: by 2002:a05:6a21:38f:b0:1d9:282f:3d17 with SMTP id adf61e73a8af0-1db91e53617mr22126673637.35.1730679718971; Sun, 03 Nov 2024 16:21:58 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , qemu-ppc@nongnu.org Subject: [PULL 47/67] ppc/xive: Fix ESB length overflow on 32-bit hosts Date: Mon, 4 Nov 2024 10:18:36 +1000 Message-ID: <20241104001900.682660-48-npiggin@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104001900.682660-1-npiggin@gmail.com> References: <20241104001900.682660-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::435; envelope-from=npiggin@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1730680038340116600 Content-Type: text/plain; charset="utf-8" The length of this region can be > 32-bits, which overflows size_t on 32-bit hosts. Change to uint64_t. Signed-off-by: Nicholas Piggin --- hw/intc/spapr_xive_kvm.c | 4 ++-- hw/intc/xive.c | 2 +- include/hw/ppc/xive.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 5789062379..7a86197fc9 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -720,7 +720,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,= uint32_t nr_servers, { SpaprXive *xive =3D SPAPR_XIVE(intc); XiveSource *xsrc =3D &xive->source; - size_t esb_len =3D xive_source_esb_len(xsrc); + uint64_t esb_len =3D xive_source_esb_len(xsrc); size_t tima_len =3D 4ull << TM_SHIFT; CPUState *cs; int fd; @@ -824,7 +824,7 @@ void kvmppc_xive_disconnect(SpaprInterruptController *i= ntc) { SpaprXive *xive =3D SPAPR_XIVE(intc); XiveSource *xsrc; - size_t esb_len; + uint64_t esb_len; =20 assert(xive->fd !=3D -1); =20 diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 5a02dd8e02..b600546e78 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1242,7 +1242,7 @@ static void xive_source_reset(void *dev) static void xive_source_realize(DeviceState *dev, Error **errp) { XiveSource *xsrc =3D XIVE_SOURCE(dev); - size_t esb_len =3D xive_source_esb_len(xsrc); + uint64_t esb_len =3D xive_source_esb_len(xsrc); =20 assert(xsrc->xive); =20 diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index 28c181faa2..3a65c2f29a 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -218,7 +218,7 @@ static inline bool xive_source_esb_has_2page(XiveSource= *xsrc) xsrc->esb_shift =3D=3D XIVE_ESB_4K_2PAGE; } =20 -static inline size_t xive_source_esb_len(XiveSource *xsrc) +static inline uint64_t xive_source_esb_len(XiveSource *xsrc) { return (1ull << xsrc->esb_shift) * xsrc->nr_irqs; } --=20 2.45.2