From nobody Mon Nov 23 04:36:05 2026 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=1792955634; cv=none; d=zohomail.com; s=zohoarc; b=M1aQUHg59NkmvYEAJ40+fzkbBBuegDUiw26eQTRL3YdxNJr8PsFn3HfSMBfwvNpGUG0SuSlZUKegV4xLgukuf9uKCMB4AuIX4eQvC/symqsvKb8+wTFvLDdT9NOYFuiuLg7A6Fj1jLlued131t9Cgot0lXtnc0MNLd6kf0SOfyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792955634; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RgiTHkc9c8syti7eZF+DEE4VABieA7WFxrhehFnEbO0=; b=bR5MCgeBBeJfvKdr81rKokvBijmFijWvhEzPPiS8qm6GAboz6eHc1XUxUfqkYkGmVs+lGD1GLPjIFcATO5QlFDp1jF/8YAj7cDpg0TOfSxUFsdyGiHO24Cg49jlAnrKHQMR/zaN5hptQbpIrd4uvCqohmYoNzdtOcUzH5F1INCs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792955634088692.5732833348765; Sun, 25 Oct 2026 12:13:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xL3ei-00077x-LC; Sun, 25 Oct 2026 15:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xL29C-0001AM-LW for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:42 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xL296-0007rK-V9 for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:39 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-48dfc0421d9so1955957f8f.1 for ; Sun, 25 Oct 2026 10:36:36 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd3555sm10886890f8f.42.2026.10.25.10.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 10:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792949795; x=1793554595; 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:content-type; bh=RgiTHkc9c8syti7eZF+DEE4VABieA7WFxrhehFnEbO0=; b=sKwDrJrI7TlwsNeFvcCWIka8pZGblHtN+ZozwHyz0hrqccEvFR/qFF1IN1dpPKcyt3 ECIJDhvFa42XNPB8ATFW6xav4c1jwYK9nkHikNHiGKLJIka0Q+Cxk68GqcQkzOYpub9+ hs8SyQx6FcXWzY3RuFLjBSk4pYl5WFwDXBxIyV9WdoWYYNeoe8kIhZ5UofOrQKUeX3Bs hgHxzCr9FGakmw1nwXWAikk5NaHN5A3Mn6HCgANIiRk9TDlbJDKyJ2iiiG2rJiXPi4El eOcJqOBAIXjBjADq3u0Sqcd75Rf1G0E6V2aYT6V1eEGYuIlwZXh3nKPDfL8C9jxuQJDN B7kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792949795; x=1793554595; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RgiTHkc9c8syti7eZF+DEE4VABieA7WFxrhehFnEbO0=; b=u+tlB3VMS4EL6Yr1WnhnW1ZQsqYTgdw92ohywQ1OqXP+Kwr2X0DzwTylR+NZTRScFg Ls86U1Ye7XcmHirGTCx4AZry8nwPHeGKrELAEJ5mB9XnRq54Cu4+C6MiEhnzeLxWvalO DIuJw8akFV1qXThttDglLgGF6JhZMhk054dKSO2d6tlbz61KfKEgwJ8tcJujavEJ4NbD PEayHKssFWW9Yq5HOxP/SUdtlvzrPHmL+fb7Ay2zJtv9StoHbINpcaL05tQK9mI+cHNt rThb8DLX7JWSa7BpA2mWl4XE/zaX30/c1hApWObdbVUVHBtshGW1j947g4UZujcYDIC7 v46A== X-Gm-Message-State: AFq9FYJZh4cZNtMLsowjgbF4ZSzv6fOohY0zyEExjAjqDWu9D85jmA5M nommKzCmJ+RntPNwpRyjBUKzorRkFc77vEI5sW3v5Nq5OSBQBY3wdDnYX5ob X-Gm-Gg: AYBFou0z0lXtPlP8DE1R3FHWDOu7dVVKvk6yrCmG1di+e5rFmoD0SsIjP5LLVG8ibcg c/f8IxA81GELnxM/SUvYPMQ9P4xJg1GMCeyvqBg8zSJQeDZQstcKt08ZJkhhWk26BFMxsovuopv S+0Ff0gPPjZHm2hL9yihR82eKQasR2qDcE4CUbrJBZrCyL9pPMOZWsmlsIyksDOmqGpEnEdcf+7 sDZNTdX6+FILaHsoqYcOAfLLC+wGQOarS1s/opgaCqvMl1pUebRpZDOcApssQ5I/EQVv06AQ4UU 5aBpibcwqC8FeJHbn/3M+VzX4VBh0vb70hHLhSN2BoDWGyMWHB5gqoi27mjBBA3aW0AbfH0hvO0 c/DuQUo+YZsaFW8ef06yX3S8ixDC8aGsYRiVP5Q4DaI1mrnyBID/UBgoO9uWAeI1MGztKd0s7M5 +azmKNoHJhq4aXH4aReUWQfll9nYKTtvb+9QLiF9XQArhqBGNZCBAHZRJKAxHTt33CdbUBFZHxf HI/sBKBszJQva4/EHC3eqzQbS7VQRenK8ahRw== X-Received: by 2002:a5d:6f0d:0:b0:487:f37:7ec4 with SMTP id ffacd0b85a97d-48e3eb85059mr7592379f8f.24.1792949794662; Sun, 25 Oct 2026 10:36:34 -0700 (PDT) From: Tristan Madani X-Google-Original-From: Tristan Madani To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, richard.henderson@linaro.org, hpoussin@reactos.org, arikalo@gmail.com, balaton@eik.bme.hu, qemu-ppc@nongnu.org, deller@gmx.de, pbonzini@redhat.com, fam@euphon.net, mark.cave-ayland@ilande.co.uk, kraxel@redhat.com, berrange@redhat.com Subject: [PATCH 1/8] hw/display/ati: fix integer overflow in Rage128 2D blit bounds check Date: Sun, 25 Oct 2026 17:36:18 +0000 Message-ID: <20261025173625.3372689-2-tristan@talencesecurity.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261025173625.3372689-1-tristan@talencesecurity.com> References: <20261025173625.3372689-1-tristan@talencesecurity.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=tristmd@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 25 Oct 2026 15:13:16 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1792955636900158500 Content-Type: text/plain; charset="utf-8" The VRAM bounds check in ati_2d_do_blt() computes (dst.y + dst.height) * dst_stride using signed 32-bit arithmetic. On Rage128, setup_2d_blt_ctx() multiplies dst_stride by bpp (up to 32), producing strides up to 524,256 bytes/row. With large dst.y + dst.height values, the signed int multiplication overflows to a negative value, causing the bounds check to evaluate false when it should reject the operation. The subsequent blit loop uses unsigned arithmetic for the same index computation, producing large positive offsets that write past the VRAM allocation into host process memory. Fix by using uint64_t for the offset computation and comparing against the VRAM size (offset-based) instead of doing pointer arithmetic that can also overflow. Apply the same fix to the source bounds check in the SRCCOPY path. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4646 Cc: qemu-stable@nongnu.org Signed-off-by: Tristan Madani --- hw/display/ati_2d.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 7a4a115..b9933fe 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -156,6 +156,8 @@ static bool ati_2d_do_blt(const ATI2DCtx *ctx, uint8_t = use_pixman) { QemuRect vis_src, vis_dst; unsigned int x, y, i, j, bypp =3D ctx->bpp / 8; + uint64_t dst_end, src_end; + uint64_t dst_off =3D ctx->dst_bits - ctx->vga->vram_ptr; const uint8_t *vram_end =3D ctx->vga->vram_ptr + ctx->vga->vram_size; =20 if (!ctx->bpp) { @@ -166,9 +168,11 @@ static bool ati_2d_do_blt(const ATI2DCtx *ctx, uint8_t= use_pixman) qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n"); return false; } + dst_end =3D dst_off + (uint64_t)ctx->dst.x * bypp + + (uint64_t)(ctx->dst.y + ctx->dst.height) * ctx->dst_stride; if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff || - ctx->dst_bits >=3D vram_end - bypp || ctx->dst_bits + ctx->dst.x *= bypp + - (ctx->dst.y + ctx->dst.height) * ctx->dst_stride >=3D vram_end - b= ypp) { + dst_off >=3D ctx->vga->vram_size || + dst_end >=3D ctx->vga->vram_size) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return false; } @@ -205,9 +209,10 @@ static bool ati_2d_do_blt(const ATI2DCtx *ctx, uint8_t= use_pixman) } if (!ctx->host_data_active && (vis_src.x > 0x3fff || vis_src.y > 0x3fff || - ctx->src_bits >=3D vram_end - bypp || - ctx->src_bits + vis_src.x * bypp + (vis_src.y + vis_dst.height= ) * - ctx->src_stride >=3D vram_end - bypp)) { + ctx->src_bits >=3D vram_end - bypp || (uint64_t)(ctx->src_bits= - + ctx->vga->vram_ptr) + (uint64_t)vis_src.x * bypp + + (uint64_t)(vis_src.y + vis_dst.height) * ctx->src_stride >=3D + ctx->vga->vram_size)) { qemu_log_mask(LOG_UNIMP, "blt outside vram not implemented\n"); return false; } --=20 2.53.0 From nobody Mon Nov 23 04:36:05 2026 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=1792955634; cv=none; d=zohomail.com; s=zohoarc; b=Mv4cb7gbz18W1l4tZ/WmTBpu4voQZNwiMH+AP0Oc7pN9ATKI9XhBxX25UXjHVBg2dAvp/wwb8sXPpSGcnr1PWRtk6JDH0xO11oTnxq1HmwGfu1f9soFFn7IlWCdOC0b+fu2ItOc5Ovobih7aUKCYm22WmHmGKkYPivnXNE94SHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792955634; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1YWTO96i43u688Xw9Jc6X3ctuvyGvDNY5EEACshF1qY=; b=mnMBcQYDyJihDVQrMuvXicIfKwVR/ABV6Eyu/AiNWRacQY5UyggkRzR6Yps1KkawXRaOeRgNfjD6o125NWUme6dzkz5OKxirkIpx8GrVuzCWty0UO5eRi9oH5Ue9q3lyJVz9KkH1KqXswj7dGrNfzpDmyyQGCHl9PJnej4fJbQw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792955634129756.8660668970865; Sun, 25 Oct 2026 12:13:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xL3ej-000786-Lj; Sun, 25 Oct 2026 15:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xL29G-0001IX-5c for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:46 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xL29C-0007sI-Ok for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:45 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-48b001cd92bso1291320f8f.2 for ; Sun, 25 Oct 2026 10:36:41 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd3555sm10886890f8f.42.2026.10.25.10.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 10:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792949800; x=1793554600; 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:content-type; bh=1YWTO96i43u688Xw9Jc6X3ctuvyGvDNY5EEACshF1qY=; b=dR3y9yU/aVzV3a0L2D4tizW5zrl6JeMDYx746yYX0decoeWacR4YqQH5zrWlrABOAL ePPaRLl/M5EtjnSthRE9Fg3mBhkuwYd5xwomQcTKlPukV7/61tymKI1m/jl16EaAvVeA B2rGAJoNJoLT+Rdc448QabhBvmfnU+zYVJ/8Ljf6D3XQ+0nzlA22YZO8PyLdYeP/AhMP vFK5TT+oVvIDGlE4GwMYC7yc/k2jj3Un3yRzDNdFELKNSdsYd94WXKlrJ0jf6QHo9hRn fAflR6fsvQ42as9ArXaFnBUjZhH/RnCpA8KZFcPink9jKZ/uAvlHsVL8e5UBMZL3u2/s Owwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792949800; x=1793554600; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1YWTO96i43u688Xw9Jc6X3ctuvyGvDNY5EEACshF1qY=; b=PrQMh1fb0CEkkPlhthGp0FW36ErQFjGHVejfsUVPdxv1f+0BBr1/XWG2gmsPw5KzVZ 7ABH0vgFAi0FiZmYMLMVveR98nOrgWSZ4wYEYyDSj9scw8pW6QNRTzaqgqSa0Tu4Otbp dhZZeA//xF1XHY8dH6BWoWSC/xq4+VBMQpZbW+IimOz3pAQ1jdQgMywAg7fiD671xMlI v090QAwWGKs+nr/yBhKjcT24n48dHdFXIulIyjzoAMG76hY+fXeU6oehBI5Wb3JG1LvL g1DrqC22Rl3opMeGmO0Z2+R5MxNseQp9ThZu/GgGUFHf6L/6ENJhe04pANOsDgfVDbDo Qufg== X-Gm-Message-State: AFq9FYJ6HxWKtR0zk3tLFL4AJgCJKe3muazi6HdI+MZ3G8j0sYTi9gro 4B/BBDxEICPipw8g2OJZSUzMivq6J80A04AAsdBGH+jpxlUM659ReDNhHVSQ X-Gm-Gg: AYBFou0aavFvHh5yJK8yZRnyErDLQejImO7YORCcZqgAGFyaRArq7Jl13+gBkRjaGQV 8A/SntSazYma3T4ZPMKJ17uQUr9T3gNbPMfgUXgvsMfGp9vmBvLKm2zVTcoBHb7JRr5R03Htxap sHB3uw1bBxtJm6wBAZGCEZSjn7WCPpbtD2oiMMPnucto/IfQLE6JIZu2TKW3v2Hr8ZZ8U8MyEx6 6hjW9xTcoMrDgB/ErZOseFk4hUIgUnzgc3DO+YIQGQAqs4iEFXmqqGX7VfuHrRpCkoalPXPtPLC zbBMKWQ2UamQxVKfeqcAXhkvNsVt9d7i4qfRPjsJqla/3hsYCzkKVUxt40n8wK6pvgQP24IhSHU 6apEmu3mGDXDFRvvrChr0oh0rI/XGR7seA6m8fVu6xIM3ILeSZkUGaqDwNx+dQHpZ8NrkvyBKdX Z2RPIMuQS0tX5TaIcPL0aip1+VLG4s9Zw/YN7WuchrNl8xkUgOxRTdTKdQpidPcCm74Po0kh36s cVdwZafT6e8kBXoEGk9VOXMxX9KK2f6LxwN8w== X-Received: by 2002:a05:6000:178f:b0:48e:3678:5112 with SMTP id ffacd0b85a97d-48e3eb82340mr6622755f8f.21.1792949799670; Sun, 25 Oct 2026 10:36:39 -0700 (PDT) From: Tristan Madani X-Google-Original-From: Tristan Madani To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, richard.henderson@linaro.org, hpoussin@reactos.org, arikalo@gmail.com, balaton@eik.bme.hu, qemu-ppc@nongnu.org, deller@gmx.de, pbonzini@redhat.com, fam@euphon.net, mark.cave-ayland@ilande.co.uk, kraxel@redhat.com, berrange@redhat.com Subject: [PATCH 2/8] hw/display/ati: reject 2D blit when width exceeds stride Date: Sun, 25 Oct 2026 17:36:19 +0000 Message-ID: <20261025173625.3372689-3-tristan@talencesecurity.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261025173625.3372689-1-tristan@talencesecurity.com> References: <20261025173625.3372689-1-tristan@talencesecurity.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=tristmd@gmail.com; helo=mail-wr1-x42c.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=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 25 Oct 2026 15:13:16 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1792955637022158500 Content-Type: text/plain; charset="utf-8" The VRAM bounds check in ati_2d_do_blt() validates the destination area using (dst.y + dst.height) * dst_stride, but does not validate that dst.width * bypp <=3D dst_stride. When a guest sets the blit width wider than the pitch, each row's memmove/fill extends past the stride-computed bound, writing up to 64 KB past the VRAM allocation boundary. This affects both Rage128 and Radeon models, and all blit paths (SRCCOPY memmove, PATCOPY fill, pixman_blt, pixman_fill, and host data blit). Reject the blit if the row width in bytes exceeds the destination (or source) stride. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4647 Cc: qemu-stable@nongnu.org Signed-off-by: Tristan Madani Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/display/ati_2d.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index b9933fe..3cc7602 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -168,6 +168,12 @@ static bool ati_2d_do_blt(const ATI2DCtx *ctx, uint8_t= use_pixman) qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n"); return false; } + if ((uint64_t)ctx->dst.width * bypp > (unsigned)ctx->dst_stride) { + qemu_log_mask(LOG_GUEST_ERROR, + "blt width (%u bytes) exceeds pitch (%d bytes)\n", + ctx->dst.width * bypp, ctx->dst_stride); + return false; + } dst_end =3D dst_off + (uint64_t)ctx->dst.x * bypp + (uint64_t)(ctx->dst.y + ctx->dst.height) * ctx->dst_stride; if (ctx->dst.x > 0x3fff || ctx->dst.y > 0x3fff || @@ -207,6 +213,10 @@ static bool ati_2d_do_blt(const ATI2DCtx *ctx, uint8_t= use_pixman) qemu_log_mask(LOG_GUEST_ERROR, "Zero source pitch\n"); return false; } + if ((uint64_t)vis_src.width * bypp > (unsigned)ctx->src_stride) { + qemu_log_mask(LOG_GUEST_ERROR, "blt src width exceeds pitch\n"= ); + return false; + } if (!ctx->host_data_active && (vis_src.x > 0x3fff || vis_src.y > 0x3fff || ctx->src_bits >=3D vram_end - bypp || (uint64_t)(ctx->src_bits= - --=20 2.53.0 From nobody Mon Nov 23 04:36:05 2026 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=1792955688; cv=none; d=zohomail.com; s=zohoarc; b=BF/Op7XjrGdOKkQkqS+SK09MTqunZJDg/ClRrVhhWbgiB+GV/qRgL4kZBvI9Kd/CSK2pclGOaYS61U8ukT4lTRz9L0XGPLb0jZE1oukuMRSsYRIq2yQKbZyymeLuOe6N0ADBvIhkGemcsDipfhi4FYOXK5cpwLUE3GpnLwu3m+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792955688; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Lkd/Fq1QJgUccZh9Elmt6YOYwvqSq1YSQVG1XDS6sF4=; b=GVQoB/H2Ks67dUOd0US3kZUzZ4BaAkIctsyLWsj1aTxAOtY811IYYroI1uUngz9BT9Gg/qvdfYqrgxC435lyZcc9bX1TVGKAfUZnoBruZVMG326D6lMmpSZU8cOkAv2KqpJL7viLr5ll7aV1kNPtZvtUbtMda0dXl65zd6wrUgM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792955688547401.0960110462713; Sun, 25 Oct 2026 12:14:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xL3et-0007EZ-SU; Sun, 25 Oct 2026 15:13:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xL29G-0001KD-LG for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:46 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xL29D-0007sZ-Ip for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:45 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-48e46e449e8so483041f8f.3 for ; Sun, 25 Oct 2026 10:36:43 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd3555sm10886890f8f.42.2026.10.25.10.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 10:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792949802; x=1793554602; 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:content-type; bh=Lkd/Fq1QJgUccZh9Elmt6YOYwvqSq1YSQVG1XDS6sF4=; b=I0+n1PhrT8+XpMIKLT3xq0ieF+gtcNQcCdvWp/PliFCtKEP+YvXWD5kX1BhW2Yvu1z CsfYU3M2Xa6l5gJITAeFACi3YL8uQjKNMr78UZcikzNubr2PE/89ZAwYI8ugOqYUYwzP wWyxuEy4PmxoVfaAyjhrv70Z2W0slShEo8StiPr4vHsf4bAJfsSnZCqW1wI5o/G67x3Z kJC0DBt6sjdrZAv6677zLhPIKXDp5A0YjF3A0zsHl5EdH3KM+E0zX0HNr6zZ9Xq2g/53 cP5C18jSv2MO3kRvdqPnD0Cjw07rBJekHH5L30USDjifIz7IazqIrUqB4srKFm4NH2/2 u46A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792949802; x=1793554602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Lkd/Fq1QJgUccZh9Elmt6YOYwvqSq1YSQVG1XDS6sF4=; b=G/GDRFmRR8lmVRZswqOpE+WP1FcqCWEm9gRTIRXd3jRFKwwMkMLwbNlI9StytLTtXP QdZfN01Bwhl72wglVpVHot9WengkEHjlSZgrly9Q94fXETrw2b6vUciksv7VTEkIi2B5 bw7urrdXYwUB24x1yr1rMdI2FOCWEbpVe9ZbSyiazXuYN69wL9eSDv5EeSncW2A5mZ0f Xj9atkNy08JfiR2kopCKbnMJ2ZNwJIeY+Vq/e1/Bv2cV07wXIv3zwvnPjoL7uKMU0lS6 B6ZOMqJgrNpBi+dCaTPRPYQ/am14vH9rWjQRt14Li2Nf7BHpH+1rjVQ5AUY3t2K+llYC Fnpw== X-Gm-Message-State: AFq9FYJ2FTIiI6Ngnqp+iG/PFsV6ko5uKJiuoPDO+ZmwJO9WdtPkZGXe cRrfVBaPIXIfPznAkFsndQc6CcG5x3XhH5jw2ospfF2t/Pmtndh9ZlwJ83k+ X-Gm-Gg: AYBFou1THjmvSwh1yVbyM5dalCAKo6cJVOIxwvhaLkQgQHzeyIF5fbBIboOLBbXF2NZ ypjf1Ep71is9amt0nbT6srEj+Zbg7wf4kPGbseTjsyQ85OQEY7Yfq7aHiHi1Qtit4Fk92P/ykIO sbKVYaF0+LAcPhjvzKt9CzoxVzOgNhqNi1hB14kS1RBPI4hmpN5Oyq1NKFFF1flktPxVQP6SY91 Iam5gdICJvqWnp7SjC+zvsWADrajEGn1RbqdyJ8KYhwOiT0M4V696a2qX7bJyoSGEGkBL2/OG3j O9DRw5EyljZNUoYOj+q5rJ3w3Gq6bjjfOpFWkKHjyS2iraM4by/goBVA9H9IAMgkWx6lKo42SBE t5Zvot1g3xU1x5bOoncR48Wf3KS4Kowy8c4FMMrvf5v+TjP+Tbpozoz8gkeXorB1I/ISBQs9jcu oizjxMsaAl72nyxE4RtMqF2YQFPPHVamcPSztsFIbAG5roFtmEICYE5x83T53h5SJb41nOEVzLu Q604VeonFeg1KboqW5tVUVesJL5JTtn0k1oeg== X-Received: by 2002:a05:6000:184e:b0:48e:b32:9d1c with SMTP id ffacd0b85a97d-48e3eb780demr7260920f8f.19.1792949801675; Sun, 25 Oct 2026 10:36:41 -0700 (PDT) From: Tristan Madani X-Google-Original-From: Tristan Madani To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, richard.henderson@linaro.org, hpoussin@reactos.org, arikalo@gmail.com, balaton@eik.bme.hu, qemu-ppc@nongnu.org, deller@gmx.de, pbonzini@redhat.com, fam@euphon.net, mark.cave-ayland@ilande.co.uk, kraxel@redhat.com, berrange@redhat.com Subject: [PATCH 3/8] hw/display/g364fb: validate top_of_screen against VRAM size Date: Sun, 25 Oct 2026 17:36:20 +0000 Message-ID: <20261025173625.3372689-4-tristan@talencesecurity.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261025173625.3372689-1-tristan@talencesecurity.com> References: <20261025173625.3372689-1-tristan@talencesecurity.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=tristmd@gmail.com; helo=mail-wr1-x42d.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=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 25 Oct 2026 15:13:16 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1792955689547158500 Content-Type: text/plain; charset="utf-8" The G364 framebuffer allows a guest to set top_of_screen to any 32-bit value without validation against the VRAM size. The display update function g364fb_draw_graphic8() computes its read pointer as memory_region_get_ram_ptr() + top_of_screen, reading past the allocated VRAM buffer when top_of_screen >=3D vram_size. The developers flagged this exact issue with an inline XXX comment ("XXX: out of range in vram?") but never added the check. Clamp top_of_screen to vram_size at the register write handler. Also add a safety check in the draw function. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4648 Cc: qemu-stable@nongnu.org Signed-off-by: Tristan Madani --- hw/display/g364fb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c index af54f1f..77e6646 100644 --- a/hw/display/g364fb.c +++ b/hw/display/g364fb.c @@ -126,7 +126,10 @@ static void g364fb_draw_graphic8(G364State *s) } =20 vram =3D memory_region_get_ram_ptr(&s->mem_vram) + s->top_of_screen; - /* XXX: out of range in vram? */ + if (s->top_of_screen >=3D s->vram_size) { + return; + } + data_display =3D dd =3D surface_data(surface); snap =3D memory_region_snapshot_and_clear_dirty(&s->mem_vram, 0, s->vr= am_size, DIRTY_MEMORY_VGA); @@ -404,6 +407,9 @@ static void g364fb_ctrl_write(void *opaque, break; case REG_TOP: s->top_of_screen =3D val; + if (s->top_of_screen >=3D s->vram_size) { + s->top_of_screen =3D 0; + } g364fb_invalidate_display(s); break; case REG_DISPLAY: --=20 2.53.0 From nobody Mon Nov 23 04:36:05 2026 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=1792955677; cv=none; d=zohomail.com; s=zohoarc; b=FZJPPqo5BMSRfJN5H2C74AT4INKcj9uVF19fFWxWpmjJthgPx/lYcj7NklWeqYIgb1kVvWWp726Zs+uakrHIm1N8+Kyce1R4lxtUhI0qnk/o5UH65LLhyIgR6icJNkYrDsidLwo3H/maUQhcrZ7E2LeqUumlivcEd6m76lj3pcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792955677; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BIp6gGM/K7KuZ7aiDnARnjxMxSArFmKK0RAQaA0vWNo=; b=RnActOuWnT29RB1Nj4WMWaMss4Y4ysB2uWQ06nT05KJzwrt01W/ygBRgkFnaw5r9ymc8p4rioPYhSpa+Vu2OPia5k7KGzPv40nLKEuvMZ13YkT5ryS42v4SnEQdAVyWsi4xnH2vgB5AExMzfVpHTLTp01nghnV9354aU1rzSsS0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792955677164749.5473703187268; Sun, 25 Oct 2026 12:14:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xL3ep-00079R-C3; Sun, 25 Oct 2026 15:13:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xL29H-0001PC-TU for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:48 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xL29F-0007tE-7M for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:47 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4a2072b9832so16837555e9.1 for ; Sun, 25 Oct 2026 10:36:44 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd3555sm10886890f8f.42.2026.10.25.10.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 10:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792949804; x=1793554604; 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:content-type; bh=BIp6gGM/K7KuZ7aiDnARnjxMxSArFmKK0RAQaA0vWNo=; b=ajUmrLiHy30G9Y87wEYCH38kETbXVsNeZ0ChZiN14d3liIuUVvn74XUHRrlI9pozSH FTQ3ZNK9DGO0MagwbB3hXoirU0GAjvDJqpaFCCYAm49Qc6ePlxzOYGiA1FoK719jClXA LCs4Y+9cOzMMDTbybR2sIT1KDHC25Pb/b7WiP4xY03i3uKfHlfJYRR2UefcwpIA13dDg c4E8GBDsEsJf8m+6DYMH35DFKCKulmLlbeI2LKfVTpRScYLOYKjLK78F0OodPx2yFcVc bGjsGse6PuoeLLorhgeMJR8/ljaiOqOBLb2BAARBOsf5qQwh8mBXmWDCZZBmHXM163Lc btOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792949804; x=1793554604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=BIp6gGM/K7KuZ7aiDnARnjxMxSArFmKK0RAQaA0vWNo=; b=RMr0Xe8bj8wzxDyl6l7Pd/yNK0j0x2DADgXun3cWP1ZeshysBfckv/7NfK7zaDtG68 ytbjV81ssEV/HfW2fWvs5C3ynFyUXAPogF7ePSUFJNXcUbJcOZMGxnc7Mw3eX5f/qiml zBYMM28BWARxR/pH6KnFXmEq5tN4qeQk57zNEhYoe93gtxxU1Av4uYlyTR2qWwJcFz1E PjYZRaQkPc1P+mDuS4I9EMwG6TmGbBfaQn+/l7FI500Iidqchbqsaet1bXYAuY4A7eIF CsBL2rPIUKrpW+v5v08FotGH1+uRHHqZNjVrqcy+Hl09jDRBdfA4VFj1T2uQ+IhJu1NW 7n6Q== X-Gm-Message-State: AFq9FYIM1obHvRqSq1vsARQYucvdbGFbtG7a+RoucGlPIcu2zFrHDyct Nj0+mz8c35Oq4cCaBejmP+zxDhtXIcqPMvfL9m+reEPwPQ7hpllzlIYE/c/r X-Gm-Gg: AYBFou1mZoSAE4jcjiNvl43UE/uF4JluKYxxdrmd1kdf99xDUM531eK+MawwLFTLc76 0jXvi0VebcPNUBnlZBBJeNR7t2Rp3by5rIxh8rt57P54L6NrNif+Trp03KiyiN4q3wOSz9zxWTk n1UFf2w0331ic09ArbWzQaKnRkisYCBBUqv4e6bbNW2JejXlgFHL8HmjsjXL/FC3DTXUPzgmfsd VnsYvrIaDimWxkgfQTQuqzvYvrkxRWBUTPuXoZIlUHGdC6+wd57ulDyVIyQWp0svzUdW1kcV2ne mnWjNMhAVDCn1zDah7XNlBX3mK1u2tFJFacSs3xKL97lwQRir9dwxqSgL6ClC8xomfNJ+//8sZ4 JktW2Nkx8XY1HV9Q/diO1qTdMnOMr/FoD9zHwqhSCvmJ1hKBSeUb1bFFb33OKCU7um460m0gIF2 Hb1nVNeHTXCoHYvALzQLSUfZLRbwX2tp2nE5c97bWkSeVEBzckd3Py2hNrMtldu8+rASrSOnufX LFq38TWUdgJjmc7Ed/os4b4k7zHjGiRrnBcouelCjVkok4CkEY0WrONdYM= X-Received: by 2002:a05:600c:21a:b0:4a2:d6cf:86e4 with SMTP id 5b1f17b1804b1-4a35ac92156mr62378695e9.10.1792949803647; Sun, 25 Oct 2026 10:36:43 -0700 (PDT) From: Tristan Madani X-Google-Original-From: Tristan Madani To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, richard.henderson@linaro.org, hpoussin@reactos.org, arikalo@gmail.com, balaton@eik.bme.hu, qemu-ppc@nongnu.org, deller@gmx.de, pbonzini@redhat.com, fam@euphon.net, mark.cave-ayland@ilande.co.uk, kraxel@redhat.com, berrange@redhat.com Subject: [PATCH 4/8] hw/display/sm501: validate framebuffer and cursor addresses Date: Sun, 25 Oct 2026 17:36:21 +0000 Message-ID: <20261025173625.3372689-5-tristan@talencesecurity.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261025173625.3372689-1-tristan@talencesecurity.com> References: <20261025173625.3372689-1-tristan@talencesecurity.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=tristmd@gmail.com; helo=mail-wm1-x333.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=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 25 Oct 2026 15:13:16 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1792955679881158500 Content-Type: text/plain; charset="utf-8" The SM501 display controller allows a guest to set the CRT/Panel framebuffer base address and hardware cursor address to values up to ~64 MB via the 0x3FFFFF0 mask. With VRAM sizes as small as 2-8 MB, these addresses exceed the actual VRAM allocation. sm501_update_display() reads pixel data from local_mem + fb_addr without bounds checking, and the hardware cursor path reads cursor pattern data from the same unvalidated address. The 2D engine path already validates VRAM bounds via sm501_rect_outside_vram(), but the display rendering path has no equivalent check. Add bounds validation in get_fb_addr() and get_hwc_address() to clamp the returned address to within the local memory region. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4649 Cc: qemu-stable@nongnu.org Signed-off-by: Tristan Madani --- hw/display/sm501.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index cacb6c8..b8e686a 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -592,7 +592,12 @@ static void set_new_local_mem_size_index(SM501State *s= , uint32_t idx) =20 static ram_addr_t get_fb_addr(SM501State *s, int crt) { - return (crt ? s->dc_crt_fb_addr : s->dc_panel_fb_addr) & 0x3FFFFF0; + ram_addr_t addr =3D (crt ? s->dc_crt_fb_addr : s->dc_panel_fb_addr) + & 0x3FFFFF0; + if (addr >=3D get_local_mem_size(s)) { + addr =3D 0; + } + return addr; } =20 static inline int get_width(SM501State *s, int crt) @@ -630,7 +635,12 @@ static inline int is_hwc_enabled(SM501State *state, in= t crt) static inline uint8_t *get_hwc_address(SM501State *state, int crt) { uint32_t addr =3D crt ? state->dc_crt_hwc_addr : state->dc_panel_hwc_a= ddr; - return state->local_mem + (addr & 0x03FFFFF0); + uint32_t offset =3D addr & 0x03FFFFF0; + + if (offset >=3D get_local_mem_size(state)) { + offset =3D 0; + } + return state->local_mem + offset; } =20 /** --=20 2.53.0 From nobody Mon Nov 23 04:36:05 2026 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=1792955689; cv=none; d=zohomail.com; s=zohoarc; b=kQ/e0y5nah396uHn8wNH0gnk9IpCpiROjr5B12ZN/LkAYTAMc0Em+W8lJuEEGALr9E/eIhs1rxi1siorsJTM9A6tIyglMAfAeDy/T6aOVWOA3Zz5PO4qs4y+Yy9ml3FtEffk8AGLOAPG+8B+zc9Z6KVriWoC/UFTJq9u8PMExI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792955689; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=msJI3Z0K76VklIMGwZtl1iOjdBjc5f9wydmB5y+3zso=; b=jhIYaUdEQdgbnwJBCBnh178HMXBAwHDsUYqyMh7sjIGXO7dOYizx+0n1rgBkVF1DFnGzwDN/Pepxc4pZdCod0wpIeEObdlFXg/LXLx61I/BWAR1UlNMZ6kkidoQZPUsjerkO1AJw9x0vI6ZBwHFL/u33OJgvSHlH+TqANqKkZbk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792955689818309.139646691586; Sun, 25 Oct 2026 12:14:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xL3er-0007DJ-St; Sun, 25 Oct 2026 15:13:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xL29K-0001Uk-PD for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:52 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450: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 1xL29I-0007uV-87 for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:50 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-48e0d1c095dso1363165f8f.1 for ; Sun, 25 Oct 2026 10:36:47 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd3555sm10886890f8f.42.2026.10.25.10.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 10:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792949807; x=1793554607; 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:content-type; bh=msJI3Z0K76VklIMGwZtl1iOjdBjc5f9wydmB5y+3zso=; b=bv3yqi97JhvEHKHqZ7eLJeuq5wwgxwTuLnGXSzcSqxX+gEN+jJw+607Nfe0fK/1BcT gT5mQ6dGAlZCM3shhqSSECED80dlyvry3lPlcjkkIl96p7IQvzlIkkqTVblOKVjomtO5 vTpVh4qDc1A8ImoODQMUAS00+9nSUj1QvsbxbJRvi5JpfoEOoSUQGGYTufp/9CgGE4My eB1X26M/DOPiCr2c9gAWqyU5DF6lINBvLxMuyz2RnN02++DtZWWapzMhe/QaB3ccL0+j S+tlntYpkFd8NZQ2YvNgZe/V0lW8wLIkYxu/cUYPUGyyj5RGlA5bmZi3gV+j7bzuITwf bKaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792949807; x=1793554607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=msJI3Z0K76VklIMGwZtl1iOjdBjc5f9wydmB5y+3zso=; b=VFnVmb7tKI9cpZczKtUbuwiaGUeUJtKUK5b2F4RiBnzRukS4+tctOcbpisV/PV7+LO w+cag4FBUkfqpuOvGFkS3uSg7/Sbxk8NU/oZF5FsLZKYOe6lfNLgOr1945Y8sRXawvVK 8LCUt84W1tDjpk8sTLTBx6ce/lNELNBsaQZqBGLFdu34cd8TWUT9YHZ0hKmy60gCbsh/ SAjlO0Q20ZuyhQDS/fETreD6nB3Pvz107+UJnKaRUJKX0JEPuvFcAIBIvtHjUEtXl+mU UMyYH9Ky2N5nMspsZddLtPm+AQfHK8iwkV3BfFa6cpQ4ToZOrrRqstPf7kkF97fHAR4B Fp/Q== X-Gm-Message-State: AFq9FYIc5+ihTzGVLQYiUGezZRyPcZR6JRa8Wh4gMPd1/VPhjr0G3wwr jyzBq7TRUjzY48hKPiuPTCRHmRDWrgO0DzkCYHeinBLvh6+LdpA3F8arODBP X-Gm-Gg: AYBFou197PtpyheTV29PL61Z7drKXXihgYD/A8C2Wdr80tX1jw/bmlRV692Rcyoyx92 lBXSiDRGdaoso6I4Aji6/d+VAPOziT0dWFQ5K7YWzWBy0iN6VeVDUsVGsH5LPPDOe5d+3eo3aQw R5Wu6lgck+5UeYb7sQ7yPCozO9vl12c/eXd1Hrt4CTj+HMRplzB+ViPbJvUWZN5am8UORg4RJzN N+Ouf1ZXg3Cy8CVLVzQggiCYlKsyLMOpFbAZjTz7BkuD/b8TU7V3zK2Gy0dbCKfxJmNbge/8gHl Z8Al4Xrc/HwOvi8lrF4fizOn22rAfrWDDmcqpAhM0N6kQcvJUByc0hUgoAjGu8WIIovTClqy3G9 0+bx6BxBmOiO63m6W/AEwShkLSZMAuDKYcSYsJpR4xAh7iMZ9Qs7lrHgfzoncVngbwX58RGTbR2 K0Q17gnIthnBOwhHYZFEO7gkDb+xBTQDZOUyZuclCa//+IvKEv662nILUyG0M2GD6LUf/tHoUGf ArSaC9hl754ixg7w173N6FX0ErOZ4fDaM0DGQ== X-Received: by 2002:a05:6000:22c8:b0:485:8a47:5b91 with SMTP id ffacd0b85a97d-48e3eba4598mr7980151f8f.46.1792949806570; Sun, 25 Oct 2026 10:36:46 -0700 (PDT) From: Tristan Madani X-Google-Original-From: Tristan Madani To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, richard.henderson@linaro.org, hpoussin@reactos.org, arikalo@gmail.com, balaton@eik.bme.hu, qemu-ppc@nongnu.org, deller@gmx.de, pbonzini@redhat.com, fam@euphon.net, mark.cave-ayland@ilande.co.uk, kraxel@redhat.com, berrange@redhat.com Subject: [PATCH 5/8] hw/scsi/ncr53c710: add instruction count limit to SCRIPTS engine Date: Sun, 25 Oct 2026 17:36:22 +0000 Message-ID: <20261025173625.3372689-6-tristan@talencesecurity.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261025173625.3372689-1-tristan@talencesecurity.com> References: <20261025173625.3372689-1-tristan@talencesecurity.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=tristmd@gmail.com; helo=mail-wr1-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=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 25 Oct 2026 15:13:17 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1792955691621158500 Content-Type: text/plain; charset="utf-8" The NCR710 SCSI controller's SCRIPTS engine executes guest-provided bytecode with no instruction count limit and no reentrancy guard. A malicious guest can craft a JUMP-to-self instruction, causing the QEMU main thread to loop indefinitely. This is the same class of vulnerability as CVE-2023-0330 in the LSI53C895A, where the fix added an instruction limit of 500 and a reentrancy limit of 8. The NCR710 implementation has neither. Add an instruction counter that yields to the event loop after NCR710_MAX_INSN (500) instructions, matching the LSI53C895A fix. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4650 Signed-off-by: Tristan Madani --- hw/scsi/ncr53c710.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index 57967e7..18da45a 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -51,6 +51,8 @@ #define NCR710_SCNTL0_ARB0 0x40 #define NCR710_SCNTL0_ARB1 0x80 =20 +#define NCR710_MAX_INSN 500 + /* SCNTL1 (0x01) - SCSI Control Register 1 */ #define NCR710_SCNTL1_RES0 0x01 #define NCR710_SCNTL1_RES1 0x02 @@ -1319,9 +1321,13 @@ void ncr710_execute_script(NCR710State *s) uint32_t insn; uint32_t addr; int opcode; + int insn_processed =3D 0; s->script_active =3D 1; =20 again: + if (++insn_processed > NCR710_MAX_INSN) { + return; + } insn =3D ncr710_read_dword(s, s->dsp); if (!insn) { /* --=20 2.53.0 From nobody Mon Nov 23 04:36:05 2026 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=1792955680; cv=none; d=zohomail.com; s=zohoarc; b=KROQmKlqTb5qjhl1/PFq9MjFnh8kRnDm+teaKFil0v4WddRN/O14jQA033XhYlYdnJFH0fzbQIQ2ARmMxqzt6PnoYUV1VE4GC6syNXiQIaKl3D4ydhuFwquOZgnAJ+mmx6YvUQDOzahb0HWjZ9T/FBHurIR1uhzgCNHe+V9iYQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792955680; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XDlhVrmFrGr+LQeBWw1XjdYQ3Aputztpbe8x+/SR4MY=; b=OBT+qjP9USQvcxAAzGhWuuFNx6L/FqHpzqVGyxS/4Km7qTw/KHPijPrk/S9JRoj7W+H2Qfkkycpj99U4nayxT6g2jW1jhi3qmUgaYKDYm1kzcfzKes1YHP69nFofMyx0Rfopppo1WKApfUnso1kGvcmp7fPj63TMXDC4KoKKzJU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792955680757535.7533690208448; Sun, 25 Oct 2026 12:14:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xL3ev-0007F7-Cf; Sun, 25 Oct 2026 15:13:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xL29M-0001Vq-Af for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:52 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xL29K-0007vA-G6 for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:51 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-48c5358fc28so2133596f8f.0 for ; Sun, 25 Oct 2026 10:36:50 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd3555sm10886890f8f.42.2026.10.25.10.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 10:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792949809; x=1793554609; 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:content-type; bh=XDlhVrmFrGr+LQeBWw1XjdYQ3Aputztpbe8x+/SR4MY=; b=PYtuGqwDHru1k3UTVYpv7leOrmX2ZuJGyfJKgbm8w+JVQEDx4aOiBrmVZ81dByDCZM MSAD9GVejAXzsiEOV/x/iGOUcbg0BEm7H+8RtVZYi8LpS34UGTzDfHkyihYmJfDTOt1Z qi8Sg7hFsjQn1/WWa2BeMqb1q4ruIL/2HoOTDJ+0iCWFCg/E0AZ6M5CGWfq+7/LGrK7S j36PtF4EylCrm+oN+Qwy9pFXMJLegW7nmcbo09ktSJtOqG3RpGkzVmc4xl4DIqYWxZBj SdBxCIYHIyeM/5TGj0QUnevOiKqdh7ikseTVBUDulNATEeSTlevxExG8PlKqpcaXloqR wiFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792949809; x=1793554609; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XDlhVrmFrGr+LQeBWw1XjdYQ3Aputztpbe8x+/SR4MY=; b=w9oxbYISoNrcpivcf4NQLS+L37U6MCgALhKlrgbzY91EYtk6wF/vsEMqT0ItOT4Iq+ jaPvKoSrAd2lAPt1xFnR9KxmFs/3KIgbjiWk2wlFFFgMeIiDg4WAb37RAG23oZfbsGOg AHJj2Giq/ltMYP5lwETuXx5PoAt5iZFDcWSEk3kgTfPdy1TMCLhdnOz0idLZQfh5tRUG 3ginhSU/HLyuqIsmXrXbSWGAS1/2wwDjxa86lMexeaUrnMDBI001uR50lNG1XQO9jkeI MQDtt72J2I/18+M5VZ3Uq19cgbUlY6MTLjUvtItDn2fA95mQVcCuyjz99VLyoHcHmKMW 7TxA== X-Gm-Message-State: AFq9FYJ02SfjbccwKt+/ARhrlviI5qumR8lKdjhUY7KLl6wOCO9N+WOc wKlPoM+5S8Zn4fybkW833rlgSK5m8IINIV9CDICRPJj175Vzptrp8V6he5gk X-Gm-Gg: AYBFou3iiFEd++zbOO9kmJh8BpWPlL3FQ0JatF8Ay9TyqT7u0dNrx/iIc7DTuJSXxGd +0aa71DAQTd3Q4ytjbNDS4Lt1AHw30xjiM6Di1AC+WldqqMAEA+vRtbA2F7roD/6puEobwhAkwA cEZ92DQPJg9b3u0gwNWe5doEvZMZXoR8itShkrzTtjfwJlfkhDqtCHs0Zyel2mGCSquM/Zuoqhi tVfnKKndHn9tpxCWxHSqkymATQC89jacUOQfdB/skA84TjGRIQZVPWjdOeWTabivxPFM0V37s4O 2peN3siBxbiOhxJ/H41sq1O2NYbcgEVP+dN7lfsd11ER9Eyz4RSckwbsN1Vv7kYwqoifdtyNw7x TJMxumBF4uTYee4R7NTNK37RjDyo+JFBOA1Gj/4kCBW/WWAkfLtzzekb0mmJyD4j/lZo4M2wg2c kfYGrXE/YWpKZ3OrgdB67IyXzANeBf1xHTG+8+Xc3ZxzDMzyAQ5DSSfaHZHI0DPR/mzPN9zJG2D OanPBjiL3bjCbyDcyFmvS+vq06RBeDE4xn93g== X-Received: by 2002:adf:fe8f:0:b0:48c:67d6:a87a with SMTP id ffacd0b85a97d-48e3eb8bdbbmr6049198f8f.32.1792949808915; Sun, 25 Oct 2026 10:36:48 -0700 (PDT) From: Tristan Madani X-Google-Original-From: Tristan Madani To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, richard.henderson@linaro.org, hpoussin@reactos.org, arikalo@gmail.com, balaton@eik.bme.hu, qemu-ppc@nongnu.org, deller@gmx.de, pbonzini@redhat.com, fam@euphon.net, mark.cave-ayland@ilande.co.uk, kraxel@redhat.com, berrange@redhat.com Subject: [PATCH 6/8] hw/display/tcx: validate blit source address against VRAM size Date: Sun, 25 Oct 2026 17:36:23 +0000 Message-ID: <20261025173625.3372689-7-tristan@talencesecurity.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261025173625.3372689-1-tristan@talencesecurity.com> References: <20261025173625.3372689-1-tristan@talencesecurity.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=tristmd@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 25 Oct 2026 15:13:16 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1792955681306158500 Content-Type: text/plain; charset="utf-8" The TCX blitter's source address (adsr) is extracted from the guest-written MMIO value as a 24-bit field (max 16 MB) but never validated against the VRAM allocation size. The standard TCX VRAM is 1 MB with a total allocation of 9 MB. A guest can trigger a blit with a source address up to 16 MB, causing memcpy() to read up to 7 MB past the allocation. The read data is copied into guest-visible VRAM, enabling host memory disclosure. Reading unmapped memory causes SIGSEGV. Both tcx_blit_writel() and tcx_rblit_writel() are affected. Add validation for both source and destination addresses. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4651 Cc: qemu-stable@nongnu.org Signed-off-by: Tristan Madani Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/display/tcx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/display/tcx.c b/hw/display/tcx.c index 2c33a9c..69a2b0e 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -575,6 +575,10 @@ static void tcx_blit_writel(void *opaque, hwaddr addr, addr =3D (addr >> 3) & 0xfffff; adsr =3D val & 0xffffff; len =3D ((val >> 24) & 0x1f) + 1; + if (addr + len > s->vram_size || + (adsr !=3D 0xffffff && adsr + len > s->vram_size)) { + return; + } if (adsr =3D=3D 0xffffff) { memset(&s->vram[addr], s->tmpblit, len); if (s->depth =3D=3D 24) { @@ -607,6 +611,10 @@ static void tcx_rblit_writel(void *opaque, hwaddr addr, addr =3D (addr >> 3) & 0xfffff; adsr =3D val & 0xffffff; len =3D ((val >> 24) & 0x1f) + 1; + if (addr + len > s->vram_size || + (adsr !=3D 0xffffff && adsr + len > s->vram_size)) { + return; + } if (adsr =3D=3D 0xffffff) { memset(&s->vram[addr], s->tmpblit, len); if (s->depth =3D=3D 24) { --=20 2.53.0 From nobody Mon Nov 23 04:36:05 2026 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=1792955689; cv=none; d=zohomail.com; s=zohoarc; b=iV+6WniTthD95vif7H+/HSvngbUUZ3ooiiAwSK7IJv47cBwuZsJB1t4dDE6OQcZZ7OKzi7LzLlSwITBHcma064lRNHSLDHYEJ6npQMTsBLbbaWD1cb4jyXKd5phx67XoBItA3vYCgdOxJ4zYS2QJEjmdeb6bim5yWfV0SuomdgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792955689; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=01/dUz0SaXyWuLdPdwDZCZ3MhYywK56OcRRDjbn84eE=; b=bIM3Ojj/+3EixFGPgCfO3ptUciqeFDbrtA56iUU6uqMYnRud5/JpvanJrWLE1dUpK/BCmkbOIA4ZpcDsyX5tqOqHIsvijTSwG4wje2La/b6IStmYJf4uPJu3TNIk87JytNW4LdnZDZ05TtgBEGB0SL8JyIPV1r9duc2S55EmhRY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792955689359422.9082065103097; Sun, 25 Oct 2026 12:14:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xL3el-00078c-HN; Sun, 25 Oct 2026 15:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xL29O-0001ao-CH for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:54 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xL29M-0007vc-Ee for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:53 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-48df4f540ebso1118930f8f.3 for ; Sun, 25 Oct 2026 10:36:52 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd3555sm10886890f8f.42.2026.10.25.10.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 10:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792949811; x=1793554611; 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:content-type; bh=01/dUz0SaXyWuLdPdwDZCZ3MhYywK56OcRRDjbn84eE=; b=iksbSA3mnd9a0KZyA1F0osX5St676tTAJSg0vMVqzPYSzgu9uYf5CfSbnglE0R1u/w i1fns3EHGcANGvwH+bVnnLG4TZP5kPA6t/d4s2aSSj7fygqvBhQ33tj/byUeqr52YPMN f+WsgnVSBveqikRvZS8R5JM3FBoQv/pyLoucWtaHDaSN30V73MQa3n6Kltq7DXDIRcoT +B0NrRvW1kffOjJ5uyqPGF+qxjtchSTa3HDxtf5KIf4e/pk6UAOvjbNwxwhhMRFPAlxZ QYBqz5TjiQjcAANzNMoALhTMmz6udUeP+twnazEdfPAl2ULrh4uXSX/Y8Zzv92plOefT FjgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792949811; x=1793554611; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=01/dUz0SaXyWuLdPdwDZCZ3MhYywK56OcRRDjbn84eE=; b=2nCl1ERXN1NgcegB0E7B/TGKCpjwDh4rpDL7tO51ejgBkemgsdfl8kbIMe1p5h2Dbt 4Iz954guyEJLOhEe+oAYuBrYrFQbl/vvtBNz5Ksm4AoVUwxq3MnMxTRLVgOrTPKyzD/K rd6xzcLebMkJDmq01D5kNz0N130VY7tHH+/GhmGcU5z5IxSBwCvt58LGOc1y8iwneK/1 nfOM/rU6y2GcJ+RRkA3l9h8tlGEUwkG1EJQfvtMdPKgwgAQ+R6dijPUvdOvs+Y00RrEy w35aBXZuII9fyNHlV4/BtVfUpeoAqPuIoVbu4bMUeSEVQdqsbKyxD9IPqat/gG0cGOdd qzxA== X-Gm-Message-State: AFq9FYIatc7n6X5yM9yK9AtNtBCGNIPp32hw8Qygyv86AKqMxdwqSgJT 5t86keMinXZx/1JyW7b8bh/R0Xo8USeBC5WcZyqyB/OFHW5Pv7eE09irthMC X-Gm-Gg: AYBFou3fmKIyYUrt//AfAi/ITD+V7qBiFELrQzRnmjgP9A6pHVBa45agxVFjekdO8ca +XufkQTHt5UOYyo1qIjYiVH6xVaGDIB99QDZw02jld65bKtbh9xmnVUt0Pdtbf0a4j1KjNIwwIk Wu+hA/Y2C35/gnqvXJ/pUplKDjy+TvIRAp5GArSb3LxZJQ55w7W4YAHkYtzHMFVAwzUyli2Aweq PhxStofZoi4HCyL5v5TQjKBG8M+bhS8Lah0fvJzAq/j3XtSPfrfdPeFMJ90gW0f6RRJkud2aasM gYEbZeAUkRtPn0n9Hdl6rJDSyAWJUJHHWsYsqCT3SqXrJ7CZcvktDeWzCRJbzIyRw9a0pK7rdHO FnHgbHlELbXgR4vO6fhG1D/By5J89MXHAgME1qFRKDGDqiTfqIdQbMP/60EJLakE0M7t1+2hFnS f/B4lxf7qjDW2wBM0cDBbfw68zaoMkFVIslXdHne1MWvIoeE68rbSD9z1VN/X7ffdza3SZjv8c4 hBixOvQBwzf1Kmaqe+XEHFa+1aESlZBcmldbA== X-Received: by 2002:a05:6000:98a:b0:48d:f4ea:49c9 with SMTP id ffacd0b85a97d-48e3eba8f38mr7718148f8f.54.1792949810957; Sun, 25 Oct 2026 10:36:50 -0700 (PDT) From: Tristan Madani X-Google-Original-From: Tristan Madani To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, richard.henderson@linaro.org, hpoussin@reactos.org, arikalo@gmail.com, balaton@eik.bme.hu, qemu-ppc@nongnu.org, deller@gmx.de, pbonzini@redhat.com, fam@euphon.net, mark.cave-ayland@ilande.co.uk, kraxel@redhat.com, berrange@redhat.com Subject: [PATCH 7/8] hw/display/artist: fix off-by-one in VRAM read bounds check Date: Sun, 25 Oct 2026 17:36:24 +0000 Message-ID: <20261025173625.3372689-8-tristan@talencesecurity.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261025173625.3372689-1-tristan@talencesecurity.com> References: <20261025173625.3372689-1-tristan@talencesecurity.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=tristmd@gmail.com; helo=mail-wr1-x431.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-Mailman-Approved-At: Sun, 25 Oct 2026 15:13:16 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1792955689544158500 Content-Type: text/plain; charset="utf-8" artist_vram_read() uses "offset > buf->size" instead of checking that the full uint32_t read fits within the buffer. This allows a 4-byte read at exactly buf->data + buf->size, entirely past the heap allocation. All write paths in the same file correctly use ">=3D" (artist_rop8, block_move, font_write16). A guest can trigger this via MMIO read addresses that produce offset =3D=3D buf->size. The read value is returned to the guest, leaking 4 bytes of adjacent host heap data. Fix by checking offset + sizeof(uint32_t) > buf->size. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4652 Cc: qemu-stable@nongnu.org Signed-off-by: Tristan Madani Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/display/artist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/artist.c b/hw/display/artist.c index 288d466..5f8cb30 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -882,7 +882,7 @@ static uint64_t artist_vram_read(void *opaque, hwaddr a= ddr, unsigned size) =20 offset =3D get_vram_offset(s, buf, addr >> 2, 0); =20 - if (offset > buf->size) { + if (offset + sizeof(uint32_t) > buf->size) { return 0; } =20 --=20 2.53.0 From nobody Mon Nov 23 04:36:05 2026 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=1792955634; cv=none; d=zohomail.com; s=zohoarc; b=Gph99phOProLg7Kt2AoYKBEzuPAflP8H5Y81GDgE5qPCyv2rDjN/d3ATcietCFaWBSq08w5mjK57FjvNchwitnbB8MZyrXUarkKI9BRzfARdDlm89M6K+D1bgJfcyMY/0NzmeayuQkiCqitHj64Prd5aeKzz/GOLayCxFqkLaBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792955634; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YyzHTYW0aPl8oKC5B+8AEtYCDjnBMpJYj371kM/t9UQ=; b=m4mSR3u1UlSGplF9ayy8lNnioOOpypR8Hzl4Tjwuz90yxtLtNbpctmXwQbysBXjOYCBwnRJyYfas3gdmf8fibqScCBwrC/Npo6yp3UzWtiMmZXLooc8gN4iX07SsNwf1Lvjy/7Nunre3dWDIyNVzEMPIX9zXyeUspjCd/Y7Qs+Q= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792955634128434.44413285792484; Sun, 25 Oct 2026 12:13:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xL3es-0007Du-SK; Sun, 25 Oct 2026 15:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xL29P-0001d9-U5 for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:56 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xL29O-0007vz-4C for qemu-devel@nongnu.org; Sun, 25 Oct 2026 13:36:55 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-48c4be28b82so1979439f8f.2 for ; Sun, 25 Oct 2026 10:36:53 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ecd3555sm10886890f8f.42.2026.10.25.10.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 10:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792949812; x=1793554612; 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:content-type; bh=YyzHTYW0aPl8oKC5B+8AEtYCDjnBMpJYj371kM/t9UQ=; b=fzKbDy6AsBmB5DzKCRuEvHBENfgLkkRIrBEBHVYs73gm1uO3xlSHCS7ldCPN+HWtjV gUbsGYyC0gpGucfirIhnMJgdi9S7kJr0yCJA3PZ5+jO/ZC8q3KUnJWlRgX4vtFh6BrZP HWPbgEtfecCsBBbKrxto//UmWRdnWfJ0udFH0R7lSbJBAxIinf1Ya8U/IgmedKpOn8Rw QK1dA0XUpWJ5PQZmtvjl68nJYRtAC/qn+HJrpp8SKlLeN4YMPgQjIXeoHdZMqo3iTuvb JOFwN39HWRJ1KZ9Gm6itbbCdVVRgIQ8MZW88kTygB4ibB+MSCUiaxHwsIzDi5oj93e7Z aVUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792949812; x=1793554612; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=YyzHTYW0aPl8oKC5B+8AEtYCDjnBMpJYj371kM/t9UQ=; b=GAw+sCxCz/yhVjJk+hlt5HtIC4GNH4fiic+Us3AO57utkFMXIwgvLRbMyHSKDBf7up 8buu3ACn5ehVEG4lyJUhfTnd7fIZX3RqaKZ0KdKHBW5io/UN9zYSw5p69/OPmpcJerIc 8z8Stu2hnLtGGjwD3HzUPY3SpO13rdAjfGsuXznLAZV9Pqju8LhDN98XVpSZ+x+uH4gf KGz8ZGqYfJH5t80Xrm31lxWZHWjB7t6e86et0IUcd3bNAr3MehB7o7xbsRyCIAEFbJeL 0HVkx0h2n082lHOK6WUcFZu+mgtQveQMNu15Af1mQ0ZCFcFmKb7eDEWppKzHx9V94yem dSVw== X-Gm-Message-State: AFq9FYK2de6Bsda9rm49sHYKlFRtkemNKa2T4pTSaT2WZMF9VQ0i0M04 0JGb0QRxc6rlHoWl051q/nKEfc4985oReHwMdscmtcwW/4zCof7Et8iDduXG X-Gm-Gg: AYBFou1c8KjU3oGDzQdufthkHRXXabNawrtZ7P3/lbAEEbI++nVtcdAttPN7YVgRSzV j4oc/Nxq2lAcMJoqMIOg4iPPYMUjT/0pwkn52hN8GwX1KbYE7Iy8bYNBzvHNFTIqwdYqZR1M3h9 Tt87aLheroVpZFZ6aTYJeYiohruhau+1BeQuTzm54XrxySAo7CFjCjW5bow0xUJeUDb9TD/p9C5 5Fx7VnQTUs6QCIt9bpcCeqK1GHmEnXVnKcG6K2D4P3kxPvHSc4d3xgmmsbag38eioMBXLAVt2j0 bCGsUhubWXKX2R5okSvhnsDRDP3GThVn3jFV1p5fux39gHzPkXwLUnUqAaIlGg3VHGnFJHKG7Xu cn2xJyWBfEhhXwWBxuI8DN51vQ0PDKzJ2l2cHI4ievjwqSqTC57AbgNFF97YlLRJoE7attTLKKs ZYOhTnOdvp8h2fPy/I0MxwnBCV+r3IIWIqsuneUk6r39KPT7B+jbw7bHksTH7ssVsPXwdM2yhP8 05UEXyBidl2msRNXqP1VOX4daNtMbeDw271Y3E= X-Received: by 2002:a05:6000:2312:b0:48d:faa4:5b66 with SMTP id ffacd0b85a97d-48e3eba7bd7mr7779477f8f.36.1792949812305; Sun, 25 Oct 2026 10:36:52 -0700 (PDT) From: Tristan Madani X-Google-Original-From: Tristan Madani To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, richard.henderson@linaro.org, hpoussin@reactos.org, arikalo@gmail.com, balaton@eik.bme.hu, qemu-ppc@nongnu.org, deller@gmx.de, pbonzini@redhat.com, fam@euphon.net, mark.cave-ayland@ilande.co.uk, kraxel@redhat.com, berrange@redhat.com Subject: [PATCH 8/8] hw/audio/gus: fix 16-bit DMA heap and stack buffer overflow Date: Sun, 25 Oct 2026 17:36:25 +0000 Message-ID: <20261025173625.3372689-9-tristan@talencesecurity.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261025173625.3372689-1-tristan@talencesecurity.com> References: <20261025173625.3372689-1-tristan@talencesecurity.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=tristmd@gmail.com; helo=mail-wr1-x429.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-Mailman-Approved-At: Sun, 25 Oct 2026 15:13:16 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1792955636880158500 Content-Type: text/plain; charset="utf-8" gus_dma_transferdata() processes DMA data in a byte-copy loop. When the GUS is configured with a 16-bit ISA DMA channel (gusdma >=3D 4), an extra byte is copied per iteration (the high byte of each 16-bit sample), doubling the effective transfer size. However, neither the source buffer (tmpbuf[4096] on the stack in GUS_read_DMA) nor the destination buffer (himem, sized for 1-byte-per-iteration) account for this doubling. With count=3D4096, the loop copies 8192 bytes total: - Source: 4096-byte over-read past tmpbuf (stack) - Destination: up to 4032-byte overflow past himem (heap) Fix by halving the loop count when operating on a 16-bit DMA channel, so the total bytes transferred never exceeds the buffer sizes. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4653 Cc: qemu-stable@nongnu.org Signed-off-by: Tristan Madani --- hw/audio/gusemu_hal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/audio/gusemu_hal.c b/hw/audio/gusemu_hal.c index f159978..1b0db02 100644 --- a/hw/audio/gusemu_hal.c +++ b/hw/audio/gusemu_hal.c @@ -534,6 +534,12 @@ void gus_dma_transferdata(GUSEmuState * state, char *d= ma_addr, unsigned int coun =20 if ((GUSregb(GUS41DMACtrl) & 0x80) && (!(GUSregb(GUS41DMACtrl) & 0x02)= )) msbmask =3D (const char) 0x80; /* invert MSB */ + + /* 16-bit DMA copies 2 bytes per iteration; halve count to stay in bou= nds */ + if (state->gusdma >=3D 4) { + count /=3D 2; + } + for (; count > 0; count--) { if (GUSregb(GUS41DMACtrl) & 0x40) --=20 2.53.0